Mercurial > hg > graal-compiler
comparison mxtool/mx.py @ 16327:5f01f7c48d40
Merge with 5cdcb94a7cf7d9782107cc582f3e4b50000d5d1f
author | Stefan Anzinger <stefan.anzinger@gmail.com> |
---|---|
date | Mon, 30 Jun 2014 12:02:19 +0200 |
parents | f5437f2db322 |
children | 9fe3cb463079 |
comparison
equal
deleted
inserted
replaced
16326:51f392557124 | 16327:5f01f7c48d40 |
---|---|
100 if not hasattr(zf, '_provenance'): | 100 if not hasattr(zf, '_provenance'): |
101 zf._provenance = {} | 101 zf._provenance = {} |
102 existingSource = zf._provenance.get(arcname, None) | 102 existingSource = zf._provenance.get(arcname, None) |
103 isOverwrite = False | 103 isOverwrite = False |
104 if existingSource and existingSource != source: | 104 if existingSource and existingSource != source: |
105 log('warning: ' + self.path + ': avoid overwrite of ' + arcname + '\n new: ' + source + '\n old: ' + existingSource) | 105 if arcname[-1] != os.path.sep: |
106 logv('warning: ' + self.path + ': avoid overwrite of ' + arcname + '\n new: ' + source + '\n old: ' + existingSource) | |
106 isOverwrite = True | 107 isOverwrite = True |
107 zf._provenance[arcname] = source | 108 zf._provenance[arcname] = source |
108 return isOverwrite | 109 return isOverwrite |
109 | 110 |
110 if self.mainClass: | 111 if self.mainClass: |
1976 | 1977 |
1977 try: | 1978 try: |
1978 if not self.jdtJar: | 1979 if not self.jdtJar: |
1979 mainJava = java() | 1980 mainJava = java() |
1980 if not args.error_prone: | 1981 if not args.error_prone: |
1981 self.logCompilation('javac') | 1982 javac = args.alt_javac if args.alt_javac else mainJava.javac |
1982 javacCmd = [mainJava.javac, '-g', '-J-Xmx1g', '-source', compliance, '-target', compliance, '-classpath', cp, '-d', outputDir, '-bootclasspath', jdk.bootclasspath(), '-endorseddirs', jdk.endorseddirs(), '-extdirs', jdk.extdirs()] | 1983 self.logCompilation('javac' if not args.alt_javac else args.alt_javac) |
1984 javacCmd = [javac, '-g', '-J-Xmx1g', '-source', compliance, '-target', compliance, '-classpath', cp, '-d', outputDir, '-bootclasspath', jdk.bootclasspath(), '-endorseddirs', jdk.endorseddirs(), '-extdirs', jdk.extdirs()] | |
1983 if jdk.debug_port is not None: | 1985 if jdk.debug_port is not None: |
1984 javacCmd += ['-J-Xdebug', '-J-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=' + str(jdk.debug_port)] | 1986 javacCmd += ['-J-Xdebug', '-J-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=' + str(jdk.debug_port)] |
1985 javacCmd += processorArgs | 1987 javacCmd += processorArgs |
1986 javacCmd += ['@' + argfile.name] | 1988 javacCmd += ['@' + argfile.name] |
1987 | 1989 |
2061 parser.add_argument('--only', action='store', help='comma separated projects to build, without checking their dependencies (omit to build all projects)') | 2063 parser.add_argument('--only', action='store', help='comma separated projects to build, without checking their dependencies (omit to build all projects)') |
2062 parser.add_argument('--no-java', action='store_false', dest='java', help='do not build Java projects') | 2064 parser.add_argument('--no-java', action='store_false', dest='java', help='do not build Java projects') |
2063 parser.add_argument('--no-native', action='store_false', dest='native', help='do not build native projects') | 2065 parser.add_argument('--no-native', action='store_false', dest='native', help='do not build native projects') |
2064 parser.add_argument('--jdt-warning-as-error', action='store_true', help='convert all Eclipse batch compiler warnings to errors') | 2066 parser.add_argument('--jdt-warning-as-error', action='store_true', help='convert all Eclipse batch compiler warnings to errors') |
2065 parser.add_argument('--jdt-show-task-tags', action='store_true', help='show task tags as Eclipse batch compiler warnings') | 2067 parser.add_argument('--jdt-show-task-tags', action='store_true', help='show task tags as Eclipse batch compiler warnings') |
2068 parser.add_argument('--alt-javac', dest='alt_javac', help='path to alternative javac executable', metavar='<path>') | |
2066 compilerSelect = parser.add_mutually_exclusive_group() | 2069 compilerSelect = parser.add_mutually_exclusive_group() |
2067 compilerSelect.add_argument('--error-prone', dest='error_prone', help='path to error-prone.jar', metavar='<path>') | 2070 compilerSelect.add_argument('--error-prone', dest='error_prone', help='path to error-prone.jar', metavar='<path>') |
2068 compilerSelect.add_argument('--jdt', help='path to ecj.jar, the Eclipse batch compiler', default=_defaultEcjPath(), metavar='<path>') | 2071 compilerSelect.add_argument('--jdt', help='path to ecj.jar, the Eclipse batch compiler', default=_defaultEcjPath(), metavar='<path>') |
2069 compilerSelect.add_argument('--force-javac', action='store_true', dest='javac', help='use javac despite ecj.jar is found or not') | 2072 compilerSelect.add_argument('--force-javac', action='store_true', dest='javac', help='use javac whether ecj.jar is found or not') |
2070 | 2073 |
2071 if suppliedParser: | 2074 if suppliedParser: |
2072 parser.add_argument('remainder', nargs=REMAINDER, metavar='...') | 2075 parser.add_argument('remainder', nargs=REMAINDER, metavar='...') |
2073 | 2076 |
2074 args = parser.parse_args(args) | 2077 args = parser.parse_args(args) |
2844 suppliedParser = parser is not None | 2847 suppliedParser = parser is not None |
2845 | 2848 |
2846 parser = parser if suppliedParser else ArgumentParser(prog='mx clean') | 2849 parser = parser if suppliedParser else ArgumentParser(prog='mx clean') |
2847 parser.add_argument('--no-native', action='store_false', dest='native', help='do not clean native projects') | 2850 parser.add_argument('--no-native', action='store_false', dest='native', help='do not clean native projects') |
2848 parser.add_argument('--no-java', action='store_false', dest='java', help='do not clean Java projects') | 2851 parser.add_argument('--no-java', action='store_false', dest='java', help='do not clean Java projects') |
2852 parser.add_argument('--no-dist', action='store_false', dest='dist', help='do not delete distributions') | |
2849 | 2853 |
2850 args = parser.parse_args(args) | 2854 args = parser.parse_args(args) |
2851 | 2855 |
2852 def _rmtree(dirPath): | 2856 def _rmtree(dirPath): |
2853 path = dirPath | 2857 path = dirPath |
2854 if get_os() == 'windows': | 2858 if get_os() == 'windows': |
2855 path = unicode("\\\\?\\" + dirPath) | 2859 path = unicode("\\\\?\\" + dirPath) |
2856 shutil.rmtree(path) | 2860 shutil.rmtree(path) |
2861 | |
2862 def _rmIfExists(name): | |
2863 if os.path.isfile(name): | |
2864 os.unlink(name) | |
2857 | 2865 |
2858 for p in projects_opt_limit_to_suites(): | 2866 for p in projects_opt_limit_to_suites(): |
2859 if p.native: | 2867 if p.native: |
2860 if args.native: | 2868 if args.native: |
2861 run([gmake_cmd(), '-C', p.dir, 'clean']) | 2869 run([gmake_cmd(), '-C', p.dir, 'clean']) |
2875 | 2883 |
2876 for configName in ['netbeans-config.zip', 'eclipse-config.zip']: | 2884 for configName in ['netbeans-config.zip', 'eclipse-config.zip']: |
2877 config = TimeStampFile(join(p.suite.mxDir, configName)) | 2885 config = TimeStampFile(join(p.suite.mxDir, configName)) |
2878 if config.exists(): | 2886 if config.exists(): |
2879 os.unlink(config.path) | 2887 os.unlink(config.path) |
2888 | |
2889 if args.dist: | |
2890 for d in _dists.keys(): | |
2891 log('Removing distribution {0}...'.format(d)) | |
2892 _rmIfExists(distribution(d).path) | |
2893 _rmIfExists(distribution(d).sourcesPath) | |
2880 | 2894 |
2881 if suppliedParser: | 2895 if suppliedParser: |
2882 return args | 2896 return args |
2883 | 2897 |
2884 def about(args): | 2898 def about(args): |
4147 """find directories corresponding to deleted Java projects and delete them""" | 4161 """find directories corresponding to deleted Java projects and delete them""" |
4148 for suite in suites(True): | 4162 for suite in suites(True): |
4149 projectDirs = [p.dir for p in suite.projects] | 4163 projectDirs = [p.dir for p in suite.projects] |
4150 for dirpath, dirnames, files in os.walk(suite.dir): | 4164 for dirpath, dirnames, files in os.walk(suite.dir): |
4151 if dirpath == suite.dir: | 4165 if dirpath == suite.dir: |
4152 # no point in traversing .hg | 4166 # no point in traversing .hg or lib/ |
4153 if '.hg' in dirnames: | 4167 dirnames[:] = [d for d in dirnames if d not in ['.hg', 'lib']] |
4154 dirnames.remove('.hg') | |
4155 elif dirpath in projectDirs: | 4168 elif dirpath in projectDirs: |
4156 # don't traverse subdirs of an existing project in this suite | 4169 # don't traverse subdirs of an existing project in this suite |
4157 dirnames[:] = [] | 4170 dirnames[:] = [] |
4158 else: | 4171 else: |
4159 projectConfigFiles = frozenset(['.classpath', 'nbproject']) | 4172 projectConfigFiles = frozenset(['.classpath', 'nbproject']) |
4472 def _kwArg(kwargs): | 4485 def _kwArg(kwargs): |
4473 if len(kwargs) > 0: | 4486 if len(kwargs) > 0: |
4474 return kwargs.pop(0) | 4487 return kwargs.pop(0) |
4475 return None | 4488 return None |
4476 | 4489 |
4477 def findclass(args, logToConsole=True): | 4490 def findclass(args, logToConsole=True, matcher=lambda string, classname: string in classname): |
4478 """find all classes matching a given substring""" | 4491 """find all classes matching a given substring""" |
4479 matches = [] | 4492 matches = [] |
4480 for entry, filename in classpath_walk(includeBootClasspath=True): | 4493 for entry, filename in classpath_walk(includeBootClasspath=True): |
4481 if filename.endswith('.class'): | 4494 if filename.endswith('.class'): |
4482 if isinstance(entry, zipfile.ZipFile): | 4495 if isinstance(entry, zipfile.ZipFile): |
4483 classname = filename.replace('/', '.') | 4496 classname = filename.replace('/', '.') |
4484 else: | 4497 else: |
4485 classname = filename.replace(os.sep, '.') | 4498 classname = filename.replace(os.sep, '.') |
4486 classname = classname[:-len('.class')] | 4499 classname = classname[:-len('.class')] |
4487 for a in args: | 4500 for a in args: |
4488 if a in classname: | 4501 if matcher(a, classname): |
4489 matches.append(classname) | 4502 matches.append(classname) |
4490 if logToConsole: | 4503 if logToConsole: |
4491 log(classname) | 4504 log(classname) |
4492 return matches | 4505 return matches |
4493 | 4506 |