Mercurial > hg > truffle
comparison mxtool/mx.py @ 11222:8f33568d693d
Merge
author | Christos Kotselidis <christos.kotselidis@oracle.com> |
---|---|
date | Tue, 06 Aug 2013 14:39:47 +0200 |
parents | 13d0d29aa15c |
children | d89a5dbaaaf6 |
comparison
equal
deleted
inserted
replaced
11221:8d4bd13c6983 | 11222:8f33568d693d |
---|---|
1547 argfileName = join(p.dir, 'javafilelist.txt') | 1547 argfileName = join(p.dir, 'javafilelist.txt') |
1548 argfile = open(argfileName, 'wb') | 1548 argfile = open(argfileName, 'wb') |
1549 argfile.write('\n'.join(javafilelist)) | 1549 argfile.write('\n'.join(javafilelist)) |
1550 argfile.close() | 1550 argfile.close() |
1551 | 1551 |
1552 javacArgs = [] | 1552 processorArgs = [] |
1553 if java().debug_port is not None: | |
1554 javacArgs += ['-J-Xdebug', '-J-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=' + str(java().debug_port)] | |
1555 | 1553 |
1556 ap = p.annotation_processors() | 1554 ap = p.annotation_processors() |
1557 if len(ap) > 0: | 1555 if len(ap) > 0: |
1558 processorPath = classpath(ap, resolve=True) | 1556 processorPath = classpath(ap, resolve=True) |
1559 genDir = p.source_gen_dir(); | 1557 genDir = p.source_gen_dir(); |
1560 if exists(genDir): | 1558 if exists(genDir): |
1561 shutil.rmtree(genDir) | 1559 shutil.rmtree(genDir) |
1562 os.mkdir(genDir) | 1560 os.mkdir(genDir) |
1563 javacArgs += ['-processorpath', join(processorPath), '-s', genDir] | 1561 processorArgs += ['-processorpath', join(processorPath), '-s', genDir] |
1564 else: | 1562 else: |
1565 javacArgs += ['-proc:none'] | 1563 processorArgs += ['-proc:none'] |
1566 | 1564 |
1567 toBeDeleted = [argfileName] | 1565 toBeDeleted = [argfileName] |
1568 try: | 1566 try: |
1569 compliance = str(p.javaCompliance) if p.javaCompliance is not None else args.compliance | 1567 compliance = str(p.javaCompliance) if p.javaCompliance is not None else args.compliance |
1570 if jdtJar is None: | 1568 if jdtJar is None: |
1571 log('Compiling Java sources for {0} with javac...'.format(p.name)) | 1569 log('Compiling Java sources for {0} with javac...'.format(p.name)) |
1572 javacCmd = [java().javac, '-g', '-J-Xmx1g', '-source', compliance, '-classpath', cp, '-d', outputDir] + javacArgs + ['@' + argfile.name] | 1570 |
1571 | |
1572 javacCmd = [java().javac, '-g', '-J-Xmx1g', '-source', compliance, '-classpath', cp, '-d', outputDir] | |
1573 if java().debug_port is not None: | |
1574 javacCmd += ['-J-Xdebug', '-J-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=' + str(java().debug_port)] | |
1575 javacCmd += processorArgs | |
1576 javacCmd += ['@' + argfile.name] | |
1577 | |
1573 if not args.warnAPI: | 1578 if not args.warnAPI: |
1574 javacCmd.append('-XDignore.symbol.file') | 1579 javacCmd.append('-XDignore.symbol.file') |
1575 run(javacCmd) | 1580 run(javacCmd) |
1576 else: | 1581 else: |
1577 log('Compiling Java sources for {0} with JDT...'.format(p.name)) | 1582 log('Compiling Java sources for {0} with JDT...'.format(p.name)) |
1578 jdtArgs = [java().java, '-Xmx1g', '-jar', jdtJar, | 1583 |
1584 jdtArgs = [java().java, '-Xmx1g'] | |
1585 if java().debug_port is not None: | |
1586 jdtArgs += ['-Xdebug', '-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=' + str(java().debug_port)] | |
1587 | |
1588 jdtArgs += [ '-jar', jdtJar, | |
1579 '-' + compliance, | 1589 '-' + compliance, |
1580 '-cp', cp, '-g', '-enableJavadoc', | 1590 '-cp', cp, '-g', '-enableJavadoc', |
1581 '-d', outputDir] + javacArgs | 1591 '-d', outputDir] |
1592 jdtArgs += processorArgs | |
1593 | |
1594 | |
1582 jdtProperties = join(p.dir, '.settings', 'org.eclipse.jdt.core.prefs') | 1595 jdtProperties = join(p.dir, '.settings', 'org.eclipse.jdt.core.prefs') |
1583 rootJdtProperties = join(p.suite.dir, 'mx', 'eclipse-settings', 'org.eclipse.jdt.core.prefs') | 1596 rootJdtProperties = join(p.suite.dir, 'mx', 'eclipse-settings', 'org.eclipse.jdt.core.prefs') |
1584 if not exists(jdtProperties) or os.path.getmtime(jdtProperties) < os.path.getmtime(rootJdtProperties): | 1597 if not exists(jdtProperties) or os.path.getmtime(jdtProperties) < os.path.getmtime(rootJdtProperties): |
1585 # Try to fix a missing properties file by running eclipseinit | 1598 # Try to fix a missing properties file by running eclipseinit |
1586 eclipseinit([], buildProcessorJars=False) | 1599 eclipseinit([], buildProcessorJars=False) |
1597 toBeDeleted.append(jdtPropertiesTmp) | 1610 toBeDeleted.append(jdtPropertiesTmp) |
1598 jdtArgs += ['-properties', jdtPropertiesTmp] | 1611 jdtArgs += ['-properties', jdtPropertiesTmp] |
1599 else: | 1612 else: |
1600 jdtArgs += ['-properties', jdtProperties] | 1613 jdtArgs += ['-properties', jdtProperties] |
1601 jdtArgs.append('@' + argfile.name) | 1614 jdtArgs.append('@' + argfile.name) |
1615 | |
1602 run(jdtArgs) | 1616 run(jdtArgs) |
1603 finally: | 1617 finally: |
1604 for n in toBeDeleted: | 1618 for n in toBeDeleted: |
1605 os.remove(n) | 1619 os.remove(n) |
1606 | 1620 |
3262 matches.append(classname) | 3276 matches.append(classname) |
3263 if logToConsole: | 3277 if logToConsole: |
3264 log(classname) | 3278 log(classname) |
3265 return matches | 3279 return matches |
3266 | 3280 |
3281 def select_items(candidates): | |
3282 """ | |
3283 Presents a command line interface for selecting one or more items from a sequence. | |
3284 """ | |
3285 if len(candidates) == 0: | |
3286 return [] | |
3287 elif len(candidates) > 1: | |
3288 log('[0] <all>') | |
3289 for i in range(0, len(candidates)): | |
3290 log('[{0}] {1}'.format(i + 1, candidates[i])) | |
3291 s = raw_input('Enter number of selection: ') | |
3292 try: | |
3293 si = int(s) | |
3294 except: | |
3295 si = 0 | |
3296 if si == 0 or si not in range(1, len(candidates) + 1): | |
3297 return candidates | |
3298 else: | |
3299 return [candidates[si - 1]] | |
3300 | |
3267 def javap(args): | 3301 def javap(args): |
3268 """disassemble classes matching given pattern with javap""" | 3302 """disassemble classes matching given pattern with javap""" |
3269 | 3303 |
3270 javap = java().javap | 3304 javap = java().javap |
3271 if not exists(javap): | 3305 if not exists(javap): |
3272 abort('The javap executable does not exists: ' + javap) | 3306 abort('The javap executable does not exists: ' + javap) |
3273 else: | 3307 else: |
3274 run([javap, '-private', '-verbose', '-classpath', classpath()] + findclass(args, logToConsole=False)) | 3308 candidates = findclass(args, logToConsole=False) |
3309 if len(candidates) == 0: | |
3310 log('no matches') | |
3311 selection = select_items(candidates) | |
3312 run([javap, '-private', '-verbose', '-classpath', classpath()] + selection) | |
3275 | 3313 |
3276 def show_projects(args): | 3314 def show_projects(args): |
3277 """show all loaded projects""" | 3315 """show all loaded projects""" |
3278 for s in suites(): | 3316 for s in suites(): |
3279 projectsFile = join(s.dir, 'mx', 'projects') | 3317 projectsFile = join(s.dir, 'mx', 'projects') |