Mercurial > hg > graal-jvmci-8
comparison mxtool/mx.py @ 9857:719a290b8a23
added optional annotationProcessorForDependents attribute for a project to inject itself as an annotation processor for all dependents
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 04 Jun 2013 15:22:10 +0200 |
parents | 394f38496856 |
children | e063474076dd |
comparison
equal
deleted
inserted
replaced
9856:fbeda9df497d | 9857:719a290b8a23 |
---|---|
144 | 144 |
145 _projects = dict() | 145 _projects = dict() |
146 _libs = dict() | 146 _libs = dict() |
147 _dists = dict() | 147 _dists = dict() |
148 _suites = dict() | 148 _suites = dict() |
149 _annotationProcessors = None | |
149 _mainSuite = None | 150 _mainSuite = None |
150 _opts = None | 151 _opts = None |
151 _java = None | 152 _java = None |
152 | 153 |
153 """ | 154 """ |
407 imported by the Java sources of this project.""" | 408 imported by the Java sources of this project.""" |
408 self._init_packages_and_imports() | 409 self._init_packages_and_imports() |
409 return self._imported_java_packages | 410 return self._imported_java_packages |
410 | 411 |
411 def annotation_processors(self): | 412 def annotation_processors(self): |
412 if not hasattr(self, '_transitiveAnnotationProcessors'): | 413 if not hasattr(self, '_annotationProcessors'): |
413 ap = set() | 414 ap = set() |
414 if hasattr(self, '_annotationProcessors'): | 415 if hasattr(self, '_declaredAnnotationProcessors'): |
415 ap = set(self._annotationProcessors) | 416 ap = set(self._declaredAnnotationProcessors) |
416 for name in self.deps: | 417 |
417 dep = _projects.get(name, None) | 418 # find dependencies that auto-inject themselves as annotation processors to all dependents |
418 if dep is not None: | 419 allDeps = self.all_deps([], includeLibs=False, includeSelf=False, includeAnnotationProcessors=False) |
419 ap.update(dep.annotation_processors()) | 420 for p in allDeps: |
420 self._transitiveAnnotationProcessors = list(ap) | 421 if hasattr(p, 'annotationProcessorForDependents') and p.annotationProcessorForDependents.lower() == 'true': |
421 return self._transitiveAnnotationProcessors | 422 ap.add(p.name) |
423 self._annotationProcessors = list(ap) | |
424 return self._annotationProcessors | |
422 | 425 |
423 class Library(Dependency): | 426 class Library(Dependency): |
424 def __init__(self, suite, name, path, mustExist, urls, sourcePath, sourceUrls): | 427 def __init__(self, suite, name, path, mustExist, urls, sourcePath, sourceUrls): |
425 Dependency.__init__(self, suite, name) | 428 Dependency.__init__(self, suite, name) |
426 self.path = path.replace('/', os.sep) | 429 self.path = path.replace('/', os.sep) |
536 p.checkstyleProj = attrs.pop('checkstyle', name) | 539 p.checkstyleProj = attrs.pop('checkstyle', name) |
537 p.native = attrs.pop('native', '') == 'true' | 540 p.native = attrs.pop('native', '') == 'true' |
538 if not p.native and p.javaCompliance is None: | 541 if not p.native and p.javaCompliance is None: |
539 abort('javaCompliance property required for non-native project ' + name) | 542 abort('javaCompliance property required for non-native project ' + name) |
540 if len(ap) > 0: | 543 if len(ap) > 0: |
541 p._annotationProcessors = ap | 544 p._declaredAnnotationProcessors = ap |
542 p.__dict__.update(attrs) | 545 p.__dict__.update(attrs) |
543 self.projects.append(p) | 546 self.projects.append(p) |
544 | 547 |
545 for name, attrs in libsMap.iteritems(): | 548 for name, attrs in libsMap.iteritems(): |
546 path = attrs.pop('path') | 549 path = attrs.pop('path') |
739 def projects(): | 742 def projects(): |
740 """ | 743 """ |
741 Get the list of all loaded projects. | 744 Get the list of all loaded projects. |
742 """ | 745 """ |
743 return _projects.values() | 746 return _projects.values() |
747 | |
748 def annotation_processors(): | |
749 """ | |
750 Get the list of all loaded projects that define an annotation processor. | |
751 """ | |
752 global _annotationProcessors | |
753 if _annotationProcessors is None: | |
754 ap = set() | |
755 for p in projects(): | |
756 ap.update(p.annotation_processors()) | |
757 _annotationProcessors = list(ap) | |
758 return _annotationProcessors | |
744 | 759 |
745 def distribution(name, fatalIfMissing=True): | 760 def distribution(name, fatalIfMissing=True): |
746 """ | 761 """ |
747 Get the distribution for a given name. This will abort if the named distribution does | 762 Get the distribution for a given name. This will abort if the named distribution does |
748 not exist and 'fatalIfMissing' is true. | 763 not exist and 'fatalIfMissing' is true. |
1682 log('Wrote backup of {0} modified files to {1}'.format(len(modified), backup)) | 1697 log('Wrote backup of {0} modified files to {1}'.format(len(modified), backup)) |
1683 return 1 | 1698 return 1 |
1684 return 0 | 1699 return 0 |
1685 | 1700 |
1686 def processorjars(): | 1701 def processorjars(): |
1687 projects = set() | |
1688 | 1702 |
1703 projs = set() | |
1689 for p in sorted_deps(): | 1704 for p in sorted_deps(): |
1690 if _isAnnotationProcessorDependency(p): | 1705 if _isAnnotationProcessorDependency(p): |
1691 projects.add(p) | 1706 projs.add(p) |
1692 | 1707 |
1693 if len(projects) <= 0: | 1708 if len(projs) < 0: |
1694 return | 1709 return |
1695 | 1710 |
1696 pnames = [p.name for p in projects] | 1711 pnames = [p.name for p in projs] |
1697 build(['--projects', ",".join(pnames)]) | 1712 build(['--projects', ",".join(pnames)]) |
1698 archive(pnames) | 1713 archive(pnames) |
1699 | 1714 |
1700 def archive(args): | 1715 def archive(args): |
1701 """create jar files for projects and distributions""" | 1716 """create jar files for projects and distributions""" |
2346 | 2361 |
2347 def _isAnnotationProcessorDependency(p): | 2362 def _isAnnotationProcessorDependency(p): |
2348 """ | 2363 """ |
2349 Determines if a given project is part of an annotation processor. | 2364 Determines if a given project is part of an annotation processor. |
2350 """ | 2365 """ |
2351 processors = set() | 2366 return p in sorted_deps(annotation_processors()) |
2352 | |
2353 for otherProject in projects(): | |
2354 if len(p.annotation_processors()) > 0: | |
2355 for processorName in otherProject.annotation_processors(): | |
2356 processors.add(project(processorName, fatalIfMissing=True)) | |
2357 | |
2358 if p in processors: | |
2359 return True | |
2360 | |
2361 for otherProject in processors: | |
2362 deps = otherProject.all_deps([], True) | |
2363 if p in deps: | |
2364 return True | |
2365 | |
2366 return False | |
2367 | 2367 |
2368 def _genEclipseBuilder(dotProjectDoc, p, name, mxCommand, refresh=True, async=False, logToConsole=False, xmlIndent='\t', xmlStandalone=None): | 2368 def _genEclipseBuilder(dotProjectDoc, p, name, mxCommand, refresh=True, async=False, logToConsole=False, xmlIndent='\t', xmlStandalone=None): |
2369 launchOut = XMLDoc(); | 2369 launchOut = XMLDoc(); |
2370 consoleOn = 'true' if logToConsole else 'false' | 2370 consoleOn = 'true' if logToConsole else 'false' |
2371 launchOut.open('launchConfiguration', {'type' : 'org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType'}) | 2371 launchOut.open('launchConfiguration', {'type' : 'org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType'}) |