Mercurial > hg > graal-jvmci-8
comparison mxtool/mx.py @ 18635:a8b46348b79f
mx: converted format strings to be python 2.6 compliant
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 05 Dec 2014 08:20:06 +0100 |
parents | 23de014b38ab |
children | dcf5cd3c6da9 |
comparison
equal
deleted
inserted
replaced
18634:b4071daf1892 | 18635:a8b46348b79f |
---|---|
107 if d not in deps: | 107 if d not in deps: |
108 deps.append(d) | 108 deps.append(d) |
109 try: | 109 try: |
110 excl = [dependency(d) for d in self.excludedDependencies] | 110 excl = [dependency(d) for d in self.excludedDependencies] |
111 except SystemExit as e: | 111 except SystemExit as e: |
112 abort('invalid excluded dependency for {} distribution: {}'.format(self.name, e)) | 112 abort('invalid excluded dependency for {0} distribution: {1}'.format(self.name, e)) |
113 return deps + [d for d in sorted_deps(self.deps, includeLibs=includeLibs) if d not in excl] | 113 return deps + [d for d in sorted_deps(self.deps, includeLibs=includeLibs) if d not in excl] |
114 | 114 |
115 def __str__(self): | 115 def __str__(self): |
116 return self.name | 116 return self.name |
117 | 117 |
696 self.sourceSha1 = sourceSha1 | 696 self.sourceSha1 = sourceSha1 |
697 self.deps = deps | 697 self.deps = deps |
698 abspath = _make_absolute(path, self.suite.dir) | 698 abspath = _make_absolute(path, self.suite.dir) |
699 if not optional and not exists(abspath): | 699 if not optional and not exists(abspath): |
700 if not len(urls): | 700 if not len(urls): |
701 abort('Non-optional library {} must either exist at {} or specify one or more URLs from which it can be retrieved'.format(name, abspath)) | 701 abort('Non-optional library {0} must either exist at {1} or specify one or more URLs from which it can be retrieved'.format(name, abspath)) |
702 | 702 |
703 def _checkSha1PropertyCondition(propName, cond, inputPath): | 703 def _checkSha1PropertyCondition(propName, cond, inputPath): |
704 if not cond: | 704 if not cond: |
705 absInputPath = _make_absolute(inputPath, self.suite.dir) | 705 absInputPath = _make_absolute(inputPath, self.suite.dir) |
706 if exists(absInputPath): | 706 if exists(absInputPath): |
707 abort('Missing "{}" property for library {}. Add the following line to projects file:\nlibrary@{}@{}={}'.format(propName, name, name, propName, sha1OfFile(absInputPath))) | 707 abort('Missing "{0}" property for library {1}. Add the following line to projects file:\nlibrary@{2}@{3}={4}'.format(propName, name, name, propName, sha1OfFile(absInputPath))) |
708 abort('Missing "{}" property for library {}'.format(propName, name)) | 708 abort('Missing "{0}" property for library {1}'.format(propName, name)) |
709 | 709 |
710 _checkSha1PropertyCondition('sha1', sha1, path) | 710 _checkSha1PropertyCondition('sha1', sha1, path) |
711 _checkSha1PropertyCondition('sourceSha1', not sourcePath or sourceSha1, sourcePath) | 711 _checkSha1PropertyCondition('sourceSha1', not sourcePath or sourceSha1, sourcePath) |
712 | 712 |
713 for url in urls: | 713 for url in urls: |
1179 except SystemExit: | 1179 except SystemExit: |
1180 path = None | 1180 path = None |
1181 finally: | 1181 finally: |
1182 d.optional = True | 1182 d.optional = True |
1183 if not path: | 1183 if not path: |
1184 logv('[omitting optional library {} as {} does not exist]'.format(d, d.path)) | 1184 logv('[omitting optional library {0} as {1} does not exist]'.format(d, d.path)) |
1185 del _libs[d.name] | 1185 del _libs[d.name] |
1186 self.libs.remove(d) | 1186 self.libs.remove(d) |
1187 elif d.isProject(): | 1187 elif d.isProject(): |
1188 if java(d.javaCompliance) is None: | 1188 if java(d.javaCompliance) is None: |
1189 logv('[omitting project {} as Java compliance {} cannot be satisfied by configured JDKs]'.format(d, d.javaCompliance)) | 1189 logv('[omitting project {0} as Java compliance {1} cannot be satisfied by configured JDKs]'.format(d, d.javaCompliance)) |
1190 del _projects[d.name] | 1190 del _projects[d.name] |
1191 self.projects.remove(d) | 1191 self.projects.remove(d) |
1192 else: | 1192 else: |
1193 for name in list(d.deps): | 1193 for name in list(d.deps): |
1194 jreLib = _jreLibs.get(name) | 1194 jreLib = _jreLibs.get(name) |
1195 if jreLib: | 1195 if jreLib: |
1196 if not jreLib.is_present_in_jdk(java(d.javaCompliance)): | 1196 if not jreLib.is_present_in_jdk(java(d.javaCompliance)): |
1197 if jreLib.optional: | 1197 if jreLib.optional: |
1198 logv('[omitting project {} as dependency {} is missing]'.format(d, name)) | 1198 logv('[omitting project {0} as dependency {1} is missing]'.format(d, name)) |
1199 del _projects[d.name] | 1199 del _projects[d.name] |
1200 self.projects.remove(d) | 1200 self.projects.remove(d) |
1201 else: | 1201 else: |
1202 abort('JRE library {} required by {} not found'.format(jreLib, d)) | 1202 abort('JRE library {0} required by {1} not found'.format(jreLib, d)) |
1203 elif not dependency(name, fatalIfMissing=False): | 1203 elif not dependency(name, fatalIfMissing=False): |
1204 logv('[omitting project {} as dependency {} is missing]'.format(d, name)) | 1204 logv('[omitting project {0} as dependency {1} is missing]'.format(d, name)) |
1205 del _projects[d.name] | 1205 del _projects[d.name] |
1206 self.projects.remove(d) | 1206 self.projects.remove(d) |
1207 for dist in _dists.itervalues(): | 1207 for dist in _dists.itervalues(): |
1208 for name in list(dist.deps): | 1208 for name in list(dist.deps): |
1209 if not dependency(name, fatalIfMissing=False): | 1209 if not dependency(name, fatalIfMissing=False): |
1210 logv('[omitting {} from distribution {}]'.format(name, dist)) | 1210 logv('[omitting {0} from distribution {1}]'.format(name, dist)) |
1211 dist.deps.remove(name) | 1211 dist.deps.remove(name) |
1212 | 1212 |
1213 if hasattr(self, 'mx_post_parse_cmd_line'): | 1213 if hasattr(self, 'mx_post_parse_cmd_line'): |
1214 self.mx_post_parse_cmd_line(opts) | 1214 self.mx_post_parse_cmd_line(opts) |
1215 | 1215 |
2225 p.terminate() | 2225 p.terminate() |
2226 else: | 2226 else: |
2227 _kill_process_group(p.pid, signal.SIGKILL) | 2227 _kill_process_group(p.pid, signal.SIGKILL) |
2228 except BaseException as e: | 2228 except BaseException as e: |
2229 if is_alive(p): | 2229 if is_alive(p): |
2230 log('error while killing subprocess {} "{}": {}'.format(p.pid, ' '.join(args), e)) | 2230 log('error while killing subprocess {0} "{1}": {2}'.format(p.pid, ' '.join(args), e)) |
2231 | 2231 |
2232 if _opts and _opts.verbose: | 2232 if _opts and _opts.verbose: |
2233 import traceback | 2233 import traceback |
2234 traceback.print_stack() | 2234 traceback.print_stack() |
2235 raise SystemExit(codeOrMessage) | 2235 raise SystemExit(codeOrMessage) |
2302 | 2302 |
2303 def __str__(self): | 2303 def __str__(self): |
2304 return self.proj.name | 2304 return self.proj.name |
2305 | 2305 |
2306 def logCompilation(self, compiler): | 2306 def logCompilation(self, compiler): |
2307 log('Compiling Java sources for {} with {}... [{}]'.format(self.proj.name, compiler, self.reason)) | 2307 log('Compiling Java sources for {0} with {1}... [{2}]'.format(self.proj.name, compiler, self.reason)) |
2308 | 2308 |
2309 def execute(self): | 2309 def execute(self): |
2310 argfileName = join(self.proj.dir, 'javafilelist.txt') | 2310 argfileName = join(self.proj.dir, 'javafilelist.txt') |
2311 argfile = open(argfileName, 'wb') | 2311 argfile = open(argfileName, 'wb') |
2312 argfile.write('\n'.join(map(_cygpathU2W, self.javafilelist))) | 2312 argfile.write('\n'.join(map(_cygpathU2W, self.javafilelist))) |
2686 worklist = sortWorklist(worklist) | 2686 worklist = sortWorklist(worklist) |
2687 | 2687 |
2688 failed += joinTasks(active) | 2688 failed += joinTasks(active) |
2689 if len(failed): | 2689 if len(failed): |
2690 for t in failed: | 2690 for t in failed: |
2691 log('Compiling {} failed'.format(t.proj.name)) | 2691 log('Compiling {0} failed'.format(t.proj.name)) |
2692 abort('{} Java compilation tasks failed'.format(len(failed))) | 2692 abort('{0} Java compilation tasks failed'.format(len(failed))) |
2693 | 2693 |
2694 if args.java: | 2694 if args.java: |
2695 for dist in sorted_dists(): | 2695 for dist in sorted_dists(): |
2696 if dist not in updatedAnnotationProcessorDists: | 2696 if dist not in updatedAnnotationProcessorDists: |
2697 archive(['@' + dist.name]) | 2697 archive(['@' + dist.name]) |
3037 # Remove non-canonical candidates | 3037 # Remove non-canonical candidates |
3038 for c in list(candidates): | 3038 for c in list(candidates): |
3039 candidates.difference_update(c.all_deps([], False, False)) | 3039 candidates.difference_update(c.all_deps([], False, False)) |
3040 candidates = [d.name for d in candidates] | 3040 candidates = [d.name for d in candidates] |
3041 | 3041 |
3042 abort('{} does not use any packages defined in these projects: {}\nComputed project dependencies: {}'.format( | 3042 abort('{0} does not use any packages defined in these projects: {1}\nComputed project dependencies: {2}'.format( |
3043 p, ', '.join(ignoredDeps), ','.join(candidates))) | 3043 p, ', '.join(ignoredDeps), ','.join(candidates))) |
3044 | 3044 |
3045 excess = frozenset(p.deps) - set(p.canonical_deps()) | 3045 excess = frozenset(p.deps) - set(p.canonical_deps()) |
3046 if len(excess) != 0: | 3046 if len(excess) != 0: |
3047 nonCanonical.append(p) | 3047 nonCanonical.append(p) |
3164 source = [None] | 3164 source = [None] |
3165 def start_element(name, attrs): | 3165 def start_element(name, attrs): |
3166 if name == 'file': | 3166 if name == 'file': |
3167 source[0] = attrs['name'] | 3167 source[0] = attrs['name'] |
3168 elif name == 'error': | 3168 elif name == 'error': |
3169 errors.append('{}:{}: {}'.format(source[0], attrs['line'], attrs['message'])) | 3169 errors.append('{0}:{1}: {2}'.format(source[0], attrs['line'], attrs['message'])) |
3170 | 3170 |
3171 xp = xml.parsers.expat.ParserCreate() | 3171 xp = xml.parsers.expat.ParserCreate() |
3172 xp.StartElementHandler = start_element | 3172 xp.StartElementHandler = start_element |
3173 with open(auditfileName) as fp: | 3173 with open(auditfileName) as fp: |
3174 xp.ParseFile(fp) | 3174 xp.ParseFile(fp) |
4780 dotErr = None | 4780 dotErr = None |
4781 try: | 4781 try: |
4782 if not 'version' in subprocess.check_output(['dot', '-V'], stderr=subprocess.STDOUT): | 4782 if not 'version' in subprocess.check_output(['dot', '-V'], stderr=subprocess.STDOUT): |
4783 dotErr = 'dot -V does not print a string containing "version"' | 4783 dotErr = 'dot -V does not print a string containing "version"' |
4784 except subprocess.CalledProcessError as e: | 4784 except subprocess.CalledProcessError as e: |
4785 dotErr = 'error calling "dot -V": {}'.format(e) | 4785 dotErr = 'error calling "dot -V": {0}'.format(e) |
4786 except OSError as e: | 4786 except OSError as e: |
4787 dotErr = 'error calling "dot -V": {}'.format(e) | 4787 dotErr = 'error calling "dot -V": {0}'.format(e) |
4788 | 4788 |
4789 if dotErr != None: | 4789 if dotErr != None: |
4790 abort('cannot generate dependency graph: ' + dotErr) | 4790 abort('cannot generate dependency graph: ' + dotErr) |
4791 | 4791 |
4792 dot = join(tmpbase, 'all', str(args.dot_output_base) + '.dot') | 4792 dot = join(tmpbase, 'all', str(args.dot_output_base) + '.dot') |
4822 with open(svg, 'w') as fp: | 4822 with open(svg, 'w') as fp: |
4823 fp.write(content) | 4823 fp.write(content) |
4824 | 4824 |
4825 # Create HTML that embeds the svg file in an <object> frame | 4825 # Create HTML that embeds the svg file in an <object> frame |
4826 with open(html, 'w') as fp: | 4826 with open(html, 'w') as fp: |
4827 print >> fp, '<html><body><object data="{}.svg" type="image/svg+xml"></object></body></html>'.format(args.dot_output_base) | 4827 print >> fp, '<html><body><object data="{0}.svg" type="image/svg+xml"></object></body></html>'.format(args.dot_output_base) |
4828 | 4828 |
4829 if exists(args.base): | 4829 if exists(args.base): |
4830 shutil.rmtree(args.base) | 4830 shutil.rmtree(args.base) |
4831 if args.tmp: | 4831 if args.tmp: |
4832 shutil.copytree(tmpbase, args.base) | 4832 shutil.copytree(tmpbase, args.base) |