Mercurial > hg > graal-compiler
comparison mxtool/mx.py @ 18899:8e8b4a6a85f5
Merge.
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 21 Jan 2015 19:01:13 +0100 |
parents | d199e643f23b f5cee3a0496c |
children | 7e500c20208c |
comparison
equal
deleted
inserted
replaced
18892:d199e643f23b | 18899:8e8b4a6a85f5 |
---|---|
1 #!/usr/bin/env python2.7 | 1 #!/usr/bin/env python2.7 |
2 # | 2 # |
3 # ---------------------------------------------------------------------------------------------------- | 3 # ---------------------------------------------------------------------------------------------------- |
4 # | 4 # |
5 # Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. | 5 # Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. |
6 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 6 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
7 # | 7 # |
8 # This code is free software; you can redistribute it and/or modify it | 8 # This code is free software; you can redistribute it and/or modify it |
9 # under the terms of the GNU General Public License version 2 only, as | 9 # under the terms of the GNU General Public License version 2 only, as |
10 # published by the Free Software Foundation. | 10 # published by the Free Software Foundation. |
552 Gets the class path composed of the distribution jars containing the | 552 Gets the class path composed of the distribution jars containing the |
553 annotation processors that will be applied when compiling this project. | 553 annotation processors that will be applied when compiling this project. |
554 """ | 554 """ |
555 def annotation_processors_path(self): | 555 def annotation_processors_path(self): |
556 aps = [project(ap) for ap in self.annotation_processors()] | 556 aps = [project(ap) for ap in self.annotation_processors()] |
557 if len(aps): | 557 libAps = [dep for dep in self.all_deps([], includeLibs=True, includeSelf=False) if dep.isLibrary() and hasattr(dep, 'annotationProcessor') and getattr(dep, 'annotationProcessor').lower() == 'true'] |
558 return os.pathsep.join([ap.definedAnnotationProcessorsDist.path for ap in aps if ap.definedAnnotationProcessorsDist]) | 558 if len(aps) + len(libAps): |
559 return os.pathsep.join([ap.definedAnnotationProcessorsDist.path for ap in aps if ap.definedAnnotationProcessorsDist] + [lib.get_path(False) for lib in libAps]) | |
559 return None | 560 return None |
561 | |
562 def uses_annotation_processor_library(self): | |
563 for dep in self.all_deps([], includeLibs=True, includeSelf=False): | |
564 if dep.isLibrary() and hasattr(dep, 'annotationProcessor'): | |
565 return True | |
566 return False | |
560 | 567 |
561 def update_current_annotation_processors_file(self): | 568 def update_current_annotation_processors_file(self): |
562 aps = self.annotation_processors() | 569 aps = self.annotation_processors() |
563 outOfDate = False | 570 outOfDate = False |
564 currentApsFile = join(self.suite.mxDir, 'currentAnnotationProcessors', self.name) | 571 currentApsFile = join(self.suite.mxDir, 'currentAnnotationProcessors', self.name) |
2136 warn("Could not find all classpaths: boot='" + str(self._bootclasspath) + "' extdirs='" + str(self._extdirs) + "' endorseddirs='" + str(self._endorseddirs) + "'") | 2143 warn("Could not find all classpaths: boot='" + str(self._bootclasspath) + "' extdirs='" + str(self._extdirs) + "' endorseddirs='" + str(self._endorseddirs) + "'") |
2137 self._bootclasspath = _filter_non_existant_paths(self._bootclasspath) | 2144 self._bootclasspath = _filter_non_existant_paths(self._bootclasspath) |
2138 self._extdirs = _filter_non_existant_paths(self._extdirs) | 2145 self._extdirs = _filter_non_existant_paths(self._extdirs) |
2139 self._endorseddirs = _filter_non_existant_paths(self._endorseddirs) | 2146 self._endorseddirs = _filter_non_existant_paths(self._endorseddirs) |
2140 | 2147 |
2148 def __repr__(self): | |
2149 return "JavaConfig(" + str(self.jdk) + ", " + str(self.debug_port) + ")" | |
2150 | |
2151 def __str__(self): | |
2152 return "Java " + str(self.version) + " (" + str(self.javaCompliance) + ") from " + str(self.jdk) | |
2153 | |
2141 def __hash__(self): | 2154 def __hash__(self): |
2142 return hash(self.jdk) | 2155 return hash(self.jdk) |
2143 | 2156 |
2144 def __cmp__(self, other): | 2157 def __cmp__(self, other): |
2145 if isinstance(other, JavaConfig): | 2158 if isinstance(other, JavaConfig): |
2146 return cmp(self.javaCompliance, other.javaCompliance) | 2159 compilanceCmp = cmp(self.javaCompliance, other.javaCompliance) |
2160 if compilanceCmp: | |
2161 return compilanceCmp | |
2162 versionCmp = cmp(self.version, other.version) | |
2163 if versionCmp: | |
2164 return versionCmp | |
2165 return cmp(self.jdk, other.jdk) | |
2147 raise TypeError() | 2166 raise TypeError() |
2148 | 2167 |
2149 def format_cmd(self, args, addDefaultArgs): | 2168 def format_cmd(self, args, addDefaultArgs): |
2150 if addDefaultArgs: | 2169 if addDefaultArgs: |
2151 return [self.java] + self.processArgs(args) | 2170 return [self.java] + self.processArgs(args) |
2443 log('JDT properties file {0} not found'.format(jdtProperties)) | 2462 log('JDT properties file {0} not found'.format(jdtProperties)) |
2444 else: | 2463 else: |
2445 with open(jdtProperties) as fp: | 2464 with open(jdtProperties) as fp: |
2446 origContent = fp.read() | 2465 origContent = fp.read() |
2447 content = origContent | 2466 content = origContent |
2448 if args.jdt_warning_as_error: | 2467 if self.proj.uses_annotation_processor_library(): |
2468 # unfortunately, the command line compiler doesn't let us ignore warnings for generated files only | |
2469 content = content.replace('=warning', '=ignore') | |
2470 elif args.jdt_warning_as_error: | |
2449 content = content.replace('=warning', '=error') | 2471 content = content.replace('=warning', '=error') |
2450 if not args.jdt_show_task_tags: | 2472 if not args.jdt_show_task_tags: |
2451 content = content + '\norg.eclipse.jdt.core.compiler.problem.tasks=ignore' | 2473 content = content + '\norg.eclipse.jdt.core.compiler.problem.tasks=ignore' |
2452 if origContent != content: | 2474 if origContent != content: |
2453 jdtPropertiesTmp = jdtProperties + '.tmp' | 2475 jdtPropertiesTmp = jdtProperties + '.tmp' |
3590 srcDir = join(p.dir, src) | 3612 srcDir = join(p.dir, src) |
3591 if not exists(srcDir): | 3613 if not exists(srcDir): |
3592 os.mkdir(srcDir) | 3614 os.mkdir(srcDir) |
3593 out.element('classpathentry', {'kind' : 'src', 'path' : src}) | 3615 out.element('classpathentry', {'kind' : 'src', 'path' : src}) |
3594 | 3616 |
3595 if len(p.annotation_processors()) > 0: | 3617 processorPath = p.annotation_processors_path() |
3618 if processorPath: | |
3596 genDir = p.source_gen_dir() | 3619 genDir = p.source_gen_dir() |
3597 if not exists(genDir): | 3620 if not exists(genDir): |
3598 os.mkdir(genDir) | 3621 os.mkdir(genDir) |
3599 out.element('classpathentry', {'kind' : 'src', 'path' : 'src_gen'}) | 3622 out.open('classpathentry', {'kind' : 'src', 'path' : 'src_gen'}) |
3623 if p.uses_annotation_processor_library(): | |
3624 # ignore warnings produced by third-party annotation processors | |
3625 out.open('attributes') | |
3626 out.element('attribute', {'name' : 'ignore_optional_problems', 'value' : 'true'}) | |
3627 out.close('attributes') | |
3628 out.close('classpathentry') | |
3629 | |
3600 if files: | 3630 if files: |
3601 files.append(genDir) | 3631 files.append(genDir) |
3602 | 3632 |
3603 # Every Java program depends on a JRE | 3633 # Every Java program depends on a JRE |
3604 out.element('classpathentry', {'kind' : 'con', 'path' : 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-' + str(p.javaCompliance)}) | 3634 out.element('classpathentry', {'kind' : 'con', 'path' : 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-' + str(p.javaCompliance)}) |
3774 esdict[name] = os.path.abspath(join(projectSettingsDir, name)) | 3804 esdict[name] = os.path.abspath(join(projectSettingsDir, name)) |
3775 | 3805 |
3776 # copy a possibly modified file to the project's .settings directory | 3806 # copy a possibly modified file to the project's .settings directory |
3777 for name, path in esdict.iteritems(): | 3807 for name, path in esdict.iteritems(): |
3778 # ignore this file altogether if this project has no annotation processors | 3808 # ignore this file altogether if this project has no annotation processors |
3779 if name == "org.eclipse.jdt.apt.core.prefs" and not len(p.annotation_processors()) > 0: | 3809 if name == "org.eclipse.jdt.apt.core.prefs" and not processorPath: |
3780 continue | 3810 continue |
3781 | 3811 |
3782 with open(path) as f: | 3812 with open(path) as f: |
3783 content = f.read() | 3813 content = f.read() |
3784 content = content.replace('${javaCompliance}', str(p.javaCompliance)) | 3814 content = content.replace('${javaCompliance}', str(p.javaCompliance)) |
3785 if len(p.annotation_processors()) > 0: | 3815 if processorPath: |
3786 content = content.replace('org.eclipse.jdt.core.compiler.processAnnotations=disabled', 'org.eclipse.jdt.core.compiler.processAnnotations=enabled') | 3816 content = content.replace('org.eclipse.jdt.core.compiler.processAnnotations=disabled', 'org.eclipse.jdt.core.compiler.processAnnotations=enabled') |
3787 update_file(join(settingsDir, name), content) | 3817 update_file(join(settingsDir, name), content) |
3788 if files: | 3818 if files: |
3789 files.append(join(settingsDir, name)) | 3819 files.append(join(settingsDir, name)) |
3790 | 3820 |
3791 processorPath = p.annotation_processors_path() | |
3792 if processorPath: | 3821 if processorPath: |
3793 out = XMLDoc() | 3822 out = XMLDoc() |
3794 out.open('factorypath') | 3823 out.open('factorypath') |
3795 out.element('factorypathentry', {'kind' : 'PLUGIN', 'id' : 'org.eclipse.jst.ws.annotations.core', 'enabled' : 'true', 'runInBatchMode' : 'false'}) | 3824 out.element('factorypathentry', {'kind' : 'PLUGIN', 'id' : 'org.eclipse.jst.ws.annotations.core', 'enabled' : 'true', 'runInBatchMode' : 'false'}) |
3796 for e in processorPath.split(os.pathsep): | 3825 for e in processorPath.split(os.pathsep): |