Mercurial > hg > graal-jvmci-8
comparison mxtool/mx.py @ 9854:394f38496856
made projects inherit annotation processors from dependencies
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 04 Jun 2013 00:33:42 +0200 |
parents | 931f9ced42ad |
children | 719a290b8a23 |
comparison
equal
deleted
inserted
replaced
9853:e45c7720b46b | 9854:394f38496856 |
---|---|
217 """ | 217 """ |
218 Add the transitive set of dependencies for this project, including | 218 Add the transitive set of dependencies for this project, including |
219 libraries if 'includeLibs' is true, to the 'deps' list. | 219 libraries if 'includeLibs' is true, to the 'deps' list. |
220 """ | 220 """ |
221 childDeps = list(self.deps) | 221 childDeps = list(self.deps) |
222 if includeAnnotationProcessors and hasattr(self, 'annotationProcessors') and len(self.annotationProcessors) > 0: | 222 if includeAnnotationProcessors and len(self.annotation_processors()) > 0: |
223 childDeps = self.annotationProcessors + childDeps | 223 childDeps = self.annotation_processors() + childDeps |
224 if self in deps: | 224 if self in deps: |
225 return deps | 225 return deps |
226 for name in childDeps: | 226 for name in childDeps: |
227 assert name != self.name | 227 assert name != self.name |
228 dep = _libs.get(name, None) | 228 dep = _libs.get(name, None) |
406 """Get the immutable set of Java packages defined by other Java projects that are | 406 """Get the immutable set of Java packages defined by other Java projects that are |
407 imported by the Java sources of this project.""" | 407 imported by the Java sources of this project.""" |
408 self._init_packages_and_imports() | 408 self._init_packages_and_imports() |
409 return self._imported_java_packages | 409 return self._imported_java_packages |
410 | 410 |
411 def annotation_processors(self): | |
412 if not hasattr(self, '_transitiveAnnotationProcessors'): | |
413 ap = set() | |
414 if hasattr(self, '_annotationProcessors'): | |
415 ap = set(self._annotationProcessors) | |
416 for name in self.deps: | |
417 dep = _projects.get(name, None) | |
418 if dep is not None: | |
419 ap.update(dep.annotation_processors()) | |
420 self._transitiveAnnotationProcessors = list(ap) | |
421 return self._transitiveAnnotationProcessors | |
411 | 422 |
412 class Library(Dependency): | 423 class Library(Dependency): |
413 def __init__(self, suite, name, path, mustExist, urls, sourcePath, sourceUrls): | 424 def __init__(self, suite, name, path, mustExist, urls, sourcePath, sourceUrls): |
414 Dependency.__init__(self, suite, name) | 425 Dependency.__init__(self, suite, name) |
415 self.path = path.replace('/', os.sep) | 426 self.path = path.replace('/', os.sep) |
525 p.checkstyleProj = attrs.pop('checkstyle', name) | 536 p.checkstyleProj = attrs.pop('checkstyle', name) |
526 p.native = attrs.pop('native', '') == 'true' | 537 p.native = attrs.pop('native', '') == 'true' |
527 if not p.native and p.javaCompliance is None: | 538 if not p.native and p.javaCompliance is None: |
528 abort('javaCompliance property required for non-native project ' + name) | 539 abort('javaCompliance property required for non-native project ' + name) |
529 if len(ap) > 0: | 540 if len(ap) > 0: |
530 p.annotationProcessors = ap | 541 p._annotationProcessors = ap |
531 p.__dict__.update(attrs) | 542 p.__dict__.update(attrs) |
532 self.projects.append(p) | 543 self.projects.append(p) |
533 | 544 |
534 for name, attrs in libsMap.iteritems(): | 545 for name, attrs in libsMap.iteritems(): |
535 path = attrs.pop('path') | 546 path = attrs.pop('path') |
1513 | 1524 |
1514 javacArgs = [] | 1525 javacArgs = [] |
1515 if java().debug_port is not None: | 1526 if java().debug_port is not None: |
1516 javacArgs += ['-J-Xdebug', '-J-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=' + str(java().debug_port)] | 1527 javacArgs += ['-J-Xdebug', '-J-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=' + str(java().debug_port)] |
1517 | 1528 |
1518 if hasattr(p, 'annotationProcessors') and len(p.annotationProcessors) > 0: | 1529 ap = p.annotation_processors() |
1519 processorPath = classpath(p.annotationProcessors, resolve=True) | 1530 if len(ap) > 0: |
1531 processorPath = classpath(ap, resolve=True) | |
1520 genDir = p.source_gen_dir(); | 1532 genDir = p.source_gen_dir(); |
1521 if exists(genDir): | 1533 if exists(genDir): |
1522 shutil.rmtree(genDir) | 1534 shutil.rmtree(genDir) |
1523 os.mkdir(genDir) | 1535 os.mkdir(genDir) |
1524 javacArgs += ['-processorpath', join(processorPath), '-s', genDir] | 1536 javacArgs += ['-processorpath', join(processorPath), '-s', genDir] |
2170 srcDir = join(p.dir, src) | 2182 srcDir = join(p.dir, src) |
2171 if not exists(srcDir): | 2183 if not exists(srcDir): |
2172 os.mkdir(srcDir) | 2184 os.mkdir(srcDir) |
2173 out.element('classpathentry', {'kind' : 'src', 'path' : src}) | 2185 out.element('classpathentry', {'kind' : 'src', 'path' : src}) |
2174 | 2186 |
2175 if hasattr(p, 'annotationProcessors') and len(p.annotationProcessors) > 0: | 2187 if len(p.annotation_processors()) > 0: |
2176 genDir = p.source_gen_dir(); | 2188 genDir = p.source_gen_dir(); |
2177 if not exists(genDir): | 2189 if not exists(genDir): |
2178 os.mkdir(genDir) | 2190 os.mkdir(genDir) |
2179 out.element('classpathentry', {'kind' : 'src', 'path' : 'src_gen'}) | 2191 out.element('classpathentry', {'kind' : 'src', 'path' : 'src_gen'}) |
2180 | 2192 |
2294 os.mkdir(settingsDir) | 2306 os.mkdir(settingsDir) |
2295 | 2307 |
2296 eclipseSettingsDir = join(suite.dir, 'mx', 'eclipse-settings') | 2308 eclipseSettingsDir = join(suite.dir, 'mx', 'eclipse-settings') |
2297 if exists(eclipseSettingsDir): | 2309 if exists(eclipseSettingsDir): |
2298 for name in os.listdir(eclipseSettingsDir): | 2310 for name in os.listdir(eclipseSettingsDir): |
2299 if name == "org.eclipse.jdt.apt.core.prefs" and not (hasattr(p, 'annotationProcessors') and len(p.annotationProcessors) > 0): | 2311 if name == "org.eclipse.jdt.apt.core.prefs" and not len(p.annotation_processors()) > 0: |
2300 continue | 2312 continue |
2301 path = join(eclipseSettingsDir, name) | 2313 path = join(eclipseSettingsDir, name) |
2302 if isfile(path): | 2314 if isfile(path): |
2303 with open(join(eclipseSettingsDir, name)) as f: | 2315 with open(join(eclipseSettingsDir, name)) as f: |
2304 content = f.read() | 2316 content = f.read() |
2305 content = content.replace('${javaCompliance}', str(p.javaCompliance)) | 2317 content = content.replace('${javaCompliance}', str(p.javaCompliance)) |
2306 if hasattr(p, 'annotationProcessors') and len(p.annotationProcessors) > 0: | 2318 if len(p.annotation_processors()) > 0: |
2307 content = content.replace('org.eclipse.jdt.core.compiler.processAnnotations=disabled', 'org.eclipse.jdt.core.compiler.processAnnotations=enabled') | 2319 content = content.replace('org.eclipse.jdt.core.compiler.processAnnotations=disabled', 'org.eclipse.jdt.core.compiler.processAnnotations=enabled') |
2308 update_file(join(settingsDir, name), content) | 2320 update_file(join(settingsDir, name), content) |
2309 | 2321 |
2310 if hasattr(p, 'annotationProcessors') and len(p.annotationProcessors) > 0: | 2322 if len(p.annotation_processors()) > 0: |
2311 out = XMLDoc() | 2323 out = XMLDoc() |
2312 out.open('factorypath') | 2324 out.open('factorypath') |
2313 out.element('factorypathentry', {'kind' : 'PLUGIN', 'id' : 'org.eclipse.jst.ws.annotations.core', 'enabled' : 'true', 'runInBatchMode' : 'false'}) | 2325 out.element('factorypathentry', {'kind' : 'PLUGIN', 'id' : 'org.eclipse.jst.ws.annotations.core', 'enabled' : 'true', 'runInBatchMode' : 'false'}) |
2314 for ap in p.annotationProcessors: | 2326 for ap in p.annotation_processors(): |
2315 apProject = project(ap) | 2327 apProject = project(ap) |
2316 for dep in apProject.all_deps([], True): | 2328 for dep in apProject.all_deps([], True): |
2317 if dep.isLibrary(): | 2329 if dep.isLibrary(): |
2318 if not hasattr(dep, 'eclipse.container') and not hasattr(dep, 'eclipse.project'): | 2330 if not hasattr(dep, 'eclipse.container') and not hasattr(dep, 'eclipse.project'): |
2319 if dep.mustExist: | 2331 if dep.mustExist: |
2337 Determines if a given project is part of an annotation processor. | 2349 Determines if a given project is part of an annotation processor. |
2338 """ | 2350 """ |
2339 processors = set() | 2351 processors = set() |
2340 | 2352 |
2341 for otherProject in projects(): | 2353 for otherProject in projects(): |
2342 if hasattr(otherProject, 'annotationProcessors') and len(otherProject.annotationProcessors) > 0: | 2354 if len(p.annotation_processors()) > 0: |
2343 for processorName in otherProject.annotationProcessors: | 2355 for processorName in otherProject.annotation_processors(): |
2344 processors.add(project(processorName, fatalIfMissing=True)) | 2356 processors.add(project(processorName, fatalIfMissing=True)) |
2345 | 2357 |
2346 if p in processors: | 2358 if p in processors: |
2347 return True | 2359 return True |
2348 | 2360 |
2444 out.open('data', {'xmlns' : 'http://www.netbeans.org/ns/j2se-project/3'}) | 2456 out.open('data', {'xmlns' : 'http://www.netbeans.org/ns/j2se-project/3'}) |
2445 out.element('name', data=p.name) | 2457 out.element('name', data=p.name) |
2446 out.element('explicit-platform', {'explicit-source-supported' : 'true'}) | 2458 out.element('explicit-platform', {'explicit-source-supported' : 'true'}) |
2447 out.open('source-roots') | 2459 out.open('source-roots') |
2448 out.element('root', {'id' : 'src.dir'}) | 2460 out.element('root', {'id' : 'src.dir'}) |
2449 if hasattr(p, 'annotationProcessors') and len(p.annotationProcessors) > 0: | 2461 if len(p.annotation_processors()) > 0: |
2450 out.element('root', {'id' : 'src.ap-source-output.dir'}) | 2462 out.element('root', {'id' : 'src.ap-source-output.dir'}) |
2451 out.close('source-roots') | 2463 out.close('source-roots') |
2452 out.open('test-roots') | 2464 out.open('test-roots') |
2453 out.close('test-roots') | 2465 out.close('test-roots') |
2454 out.close('data') | 2466 out.close('data') |
2484 jdkPlatform = 'JDK_' + str(java().version) | 2496 jdkPlatform = 'JDK_' + str(java().version) |
2485 | 2497 |
2486 annotationProcessorEnabled = "false" | 2498 annotationProcessorEnabled = "false" |
2487 annotationProcessorReferences = "" | 2499 annotationProcessorReferences = "" |
2488 annotationProcessorSrcFolder = "" | 2500 annotationProcessorSrcFolder = "" |
2489 if hasattr(p, 'annotationProcessors') and len(p.annotationProcessors) > 0: | 2501 if len(p.annotation_processors()) > 0: |
2490 annotationProcessorEnabled = "true" | 2502 annotationProcessorEnabled = "true" |
2491 annotationProcessorSrcFolder = "src.ap-source-output.dir=${build.generated.sources.dir}/ap-source-output" | 2503 annotationProcessorSrcFolder = "src.ap-source-output.dir=${build.generated.sources.dir}/ap-source-output" |
2492 | 2504 |
2493 content = """ | 2505 content = """ |
2494 annotation.processing.enabled=""" + annotationProcessorEnabled + """ | 2506 annotation.processing.enabled=""" + annotationProcessorEnabled + """ |
2576 | 2588 |
2577 javacClasspath = [] | 2589 javacClasspath = [] |
2578 | 2590 |
2579 deps = p.all_deps([], True) | 2591 deps = p.all_deps([], True) |
2580 annotationProcessorOnlyDeps = [] | 2592 annotationProcessorOnlyDeps = [] |
2581 if hasattr(p, 'annotationProcessors') and len(p.annotationProcessors) > 0: | 2593 if len(p.annotation_processors()) > 0: |
2582 for ap in p.annotationProcessors: | 2594 for ap in p.annotation_processors(): |
2583 apProject = project(ap) | 2595 apProject = project(ap) |
2584 if not apProject in deps: | 2596 if not apProject in deps: |
2585 deps.append(apProject) | 2597 deps.append(apProject) |
2586 annotationProcessorOnlyDeps.append(apProject) | 2598 annotationProcessorOnlyDeps.append(apProject) |
2587 | 2599 |