Mercurial > hg > graal-compiler
comparison mxtool/mx.py @ 6535:f938212e56ab
Improvements of annotation processor functionality in mx script; allow javac to be run in debugger in order to debug annotation processor
author | Christian Wimmer <christian.wimmer@oracle.com> |
---|---|
date | Mon, 08 Oct 2012 19:46:12 -0700 |
parents | 250babea75d5 |
children | a748e4d44694 |
comparison
equal
deleted
inserted
replaced
6534:feb579677b58 | 6535:f938212e56ab |
---|---|
250 def source_dirs(self): | 250 def source_dirs(self): |
251 """ | 251 """ |
252 Get the directories in which the sources of this project are found. | 252 Get the directories in which the sources of this project are found. |
253 """ | 253 """ |
254 return [join(self.dir, s) for s in self.srcDirs] | 254 return [join(self.dir, s) for s in self.srcDirs] |
255 | |
256 def source_gen_dir(self): | |
257 """ | |
258 Get the directory in which source files generated by the annotation processor are found/placed. | |
259 """ | |
260 if self.native: | |
261 return None | |
262 return join(self.dir, 'src_gen') | |
255 | 263 |
256 def output_dir(self): | 264 def output_dir(self): |
257 """ | 265 """ |
258 Get the directory in which the class files of this project are found/placed. | 266 Get the directory in which the class files of this project are found/placed. |
259 """ | 267 """ |
1253 parser.add_argument('-f', action='store_true', dest='force', help='force build (disables timestamp checking)') | 1261 parser.add_argument('-f', action='store_true', dest='force', help='force build (disables timestamp checking)') |
1254 parser.add_argument('-c', action='store_true', dest='clean', help='removes existing build output') | 1262 parser.add_argument('-c', action='store_true', dest='clean', help='removes existing build output') |
1255 parser.add_argument('--source', dest='compliance', help='Java compliance level', default=str(javaCompliance)) | 1263 parser.add_argument('--source', dest='compliance', help='Java compliance level', default=str(javaCompliance)) |
1256 parser.add_argument('--Wapi', action='store_true', dest='warnAPI', help='show warnings about using internal APIs') | 1264 parser.add_argument('--Wapi', action='store_true', dest='warnAPI', help='show warnings about using internal APIs') |
1257 parser.add_argument('--projects', action='store', help='comma separated projects to build (omit to build all projects)') | 1265 parser.add_argument('--projects', action='store', help='comma separated projects to build (omit to build all projects)') |
1266 parser.add_argument('--only', action='store', help='comma separated projects to build, without checking their dependencies (omit to build all projects)') | |
1258 parser.add_argument('--no-java', action='store_false', dest='java', help='do not build Java projects') | 1267 parser.add_argument('--no-java', action='store_false', dest='java', help='do not build Java projects') |
1259 parser.add_argument('--no-native', action='store_false', dest='native', help='do not build native projects') | 1268 parser.add_argument('--no-native', action='store_false', dest='native', help='do not build native projects') |
1260 parser.add_argument('--jdt', help='Eclipse installation or path to ecj.jar for using the Eclipse batch compiler (default: ' + defaultEcjPath + ')', default=defaultEcjPath, metavar='<path>') | 1269 parser.add_argument('--jdt', help='Eclipse installation or path to ecj.jar for using the Eclipse batch compiler (default: ' + defaultEcjPath + ')', default=defaultEcjPath, metavar='<path>') |
1261 parser.add_argument('--jdt-warning-as-error', action='store_true', help='convert all Eclipse batch compiler warnings to errors') | 1270 parser.add_argument('--jdt-warning-as-error', action='store_true', help='convert all Eclipse batch compiler warnings to errors') |
1262 | 1271 |
1282 | 1291 |
1283 projects = None | 1292 projects = None |
1284 if args.projects is not None: | 1293 if args.projects is not None: |
1285 projects = args.projects.split(',') | 1294 projects = args.projects.split(',') |
1286 | 1295 |
1287 for p in sorted_deps(projects): | 1296 if args.only is not None: |
1297 sortedProjects = [project(name) for name in args.only.split(',')] | |
1298 else: | |
1299 sortedProjects = sorted_deps(projects) | |
1300 | |
1301 for p in sortedProjects: | |
1288 if p.native: | 1302 if p.native: |
1289 if args.native: | 1303 if args.native: |
1290 log('Calling GNU make {0}...'.format(p.dir)) | 1304 log('Calling GNU make {0}...'.format(p.dir)) |
1291 | 1305 |
1292 if args.clean: | 1306 if args.clean: |
1389 argfileName = join(p.dir, 'javafilelist.txt') | 1403 argfileName = join(p.dir, 'javafilelist.txt') |
1390 argfile = open(argfileName, 'wb') | 1404 argfile = open(argfileName, 'wb') |
1391 argfile.write('\n'.join(javafilelist)) | 1405 argfile.write('\n'.join(javafilelist)) |
1392 argfile.close() | 1406 argfile.close() |
1393 | 1407 |
1408 javacArgs = [] | |
1409 if java().debug_port is not None: | |
1410 javacArgs += ['-J-Xdebug', '-J-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=' + str(java().debug_port)] | |
1411 | |
1394 if hasattr(p, 'annotationProcessors') and len(p.annotationProcessors) > 0: | 1412 if hasattr(p, 'annotationProcessors') and len(p.annotationProcessors) > 0: |
1395 annotationProcessors = [] | 1413 annotationProcessors = [] |
1396 for apProject in p.annotationProcessors: | 1414 for apProject in p.annotationProcessors: |
1397 apClasses = project(apProject).annotationProcessorClasses | 1415 apClasses = project(apProject).annotationProcessorClasses |
1398 if len(apClasses) == 0: | 1416 if len(apClasses) == 0: |
1399 abort("Project " + p + " specifies " + apProject + " as an annotation processor but " + apProject + " does not specifiy any annotation processor class") | 1417 abort("Project " + p + " specifies " + apProject + " as an annotation processor but " + apProject + " does not specifiy any annotation processor class") |
1400 annotationProcessors += apClasses | 1418 annotationProcessors += apClasses |
1401 | 1419 |
1402 apArgs = ['-processor', ",".join(annotationProcessors)] | 1420 genDir = p.source_gen_dir(); |
1421 if exists(genDir): | |
1422 shutil.rmtree(genDir) | |
1423 os.mkdir(genDir) | |
1424 javacArgs += ['-processor', ",".join(annotationProcessors), "-s", genDir] | |
1403 else: | 1425 else: |
1404 apArgs = [] | 1426 javacArgs += ['-proc:none'] |
1405 | 1427 |
1406 toBeDeleted = [argfileName] | 1428 toBeDeleted = [argfileName] |
1407 try: | 1429 try: |
1408 if jdtJar is None: | 1430 if jdtJar is None: |
1409 log('Compiling Java sources for {0} with javac...'.format(p.name)) | 1431 log('Compiling Java sources for {0} with javac...'.format(p.name)) |
1410 javacCmd = [java().javac, '-g', '-J-Xmx1g', '-source', args.compliance, '-classpath', cp, '-d', outputDir] + apArgs + ['@' + argfile.name] | 1432 javacCmd = [java().javac, '-g', '-J-Xmx1g', '-source', args.compliance, '-classpath', cp, '-d', outputDir] + javacArgs + ['@' + argfile.name] |
1411 if not args.warnAPI: | 1433 if not args.warnAPI: |
1412 javacCmd.append('-XDignore.symbol.file') | 1434 javacCmd.append('-XDignore.symbol.file') |
1413 run(javacCmd) | 1435 run(javacCmd) |
1414 else: | 1436 else: |
1415 log('Compiling Java sources for {0} with JDT...'.format(p.name)) | 1437 log('Compiling Java sources for {0} with JDT...'.format(p.name)) |
1416 jdtArgs = [java().java, '-Xmx1g', '-jar', jdtJar, | 1438 jdtArgs = [java().java, '-Xmx1g', '-jar', jdtJar, |
1417 '-' + args.compliance, | 1439 '-' + args.compliance, |
1418 '-cp', cp, '-g', '-enableJavadoc', | 1440 '-cp', cp, '-g', '-enableJavadoc', |
1419 '-d', outputDir] + apArgs | 1441 '-d', outputDir] + javacArgs |
1420 jdtProperties = join(p.dir, '.settings', 'org.eclipse.jdt.core.prefs') | 1442 jdtProperties = join(p.dir, '.settings', 'org.eclipse.jdt.core.prefs') |
1421 if not exists(jdtProperties): | 1443 if not exists(jdtProperties): |
1422 # Try to fix a missing properties file by running eclipseinit | 1444 # Try to fix a missing properties file by running eclipseinit |
1423 eclipseinit([]) | 1445 eclipseinit([]) |
1424 if not exists(jdtProperties): | 1446 if not exists(jdtProperties): |
1976 path = join(eclipseSettingsDir, name) | 1998 path = join(eclipseSettingsDir, name) |
1977 if isfile(path): | 1999 if isfile(path): |
1978 with open(join(eclipseSettingsDir, name)) as f: | 2000 with open(join(eclipseSettingsDir, name)) as f: |
1979 content = f.read() | 2001 content = f.read() |
1980 content = content.replace('${javaCompliance}', str(p.javaCompliance)) | 2002 content = content.replace('${javaCompliance}', str(p.javaCompliance)) |
2003 if hasattr(p, 'annotationProcessors') and len(p.annotationProcessors) > 0: | |
2004 content = content.replace('org.eclipse.jdt.core.compiler.processAnnotations=disabled', 'org.eclipse.jdt.core.compiler.processAnnotations=enabled') | |
1981 update_file(join(settingsDir, name), content) | 2005 update_file(join(settingsDir, name), content) |
1982 | 2006 |
1983 if hasattr(p, 'annotationProcessors') and len(p.annotationProcessors) > 0: | 2007 if hasattr(p, 'annotationProcessors') and len(p.annotationProcessors) > 0: |
1984 out = XMLDoc() | 2008 out = XMLDoc() |
1985 out.open('factorypath') | 2009 out.open('factorypath') |