comparison mxtool/mx.py @ 18641:e22a21b27036

Merge.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Sun, 07 Dec 2014 20:43:33 +0100
parents dcf5cd3c6da9
children beb33138029c
comparison
equal deleted inserted replaced
18640:02b5114b74c1 18641:e22a21b27036
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:
878 additional = d.get(s) 878 additional = d.get(s)
879 if additional: 879 if additional:
880 if not existing: 880 if not existing:
881 suite[s] = additional 881 suite[s] = additional
882 else: 882 else:
883 conflicting = additional.keys() & existing.keys() 883 conflicting = frozenset(additional.keys()) & frozenset(existing.keys())
884 if conflicting: 884 if conflicting:
885 abort(modulePath + ' redefines: ' + ', '.join(conflicting)) 885 abort(modulePath + ' redefines: ' + ', '.join(conflicting))
886 existing.update(additional) 886 existing.update(additional)
887 distExtensions = d.get('distribution_extensions') 887 distExtensions = d.get('distribution_extensions')
888 if distExtensions: 888 if distExtensions:
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
1670 args = sys.argv[1:] 1670 args = sys.argv[1:]
1671 1671
1672 self.add_argument('commandAndArgs', nargs=REMAINDER, metavar='command args...') 1672 self.add_argument('commandAndArgs', nargs=REMAINDER, metavar='command args...')
1673 1673
1674 opts = self.parse_args() 1674 opts = self.parse_args()
1675
1676 global _opts
1677 _opts = opts
1675 1678
1676 # Give the timeout options a default value to avoid the need for hasattr() tests 1679 # Give the timeout options a default value to avoid the need for hasattr() tests
1677 opts.__dict__.setdefault('timeout', 0) 1680 opts.__dict__.setdefault('timeout', 0)
1678 opts.__dict__.setdefault('ptimeout', 0) 1681 opts.__dict__.setdefault('ptimeout', 0)
1679 1682
2207 If 'codeOrMessage' is a plain integer, it specifies the system exit status; 2210 If 'codeOrMessage' is a plain integer, it specifies the system exit status;
2208 if it is None, the exit status is zero; if it has another type (such as a string), 2211 if it is None, the exit status is zero; if it has another type (such as a string),
2209 the object's value is printed and the exit status is one. 2212 the object's value is printed and the exit status is one.
2210 """ 2213 """
2211 2214
2212 if _opts.killwithsigquit: 2215 if _opts and _opts.killwithsigquit:
2213 _send_sigquit() 2216 _send_sigquit()
2214 2217
2215 def is_alive(p): 2218 def is_alive(p):
2216 if isinstance(p, subprocess.Popen): 2219 if isinstance(p, subprocess.Popen):
2217 return p.poll() is None 2220 return p.poll() is None
2225 p.terminate() 2228 p.terminate()
2226 else: 2229 else:
2227 _kill_process_group(p.pid, signal.SIGKILL) 2230 _kill_process_group(p.pid, signal.SIGKILL)
2228 except BaseException as e: 2231 except BaseException as e:
2229 if is_alive(p): 2232 if is_alive(p):
2230 log('error while killing subprocess {} "{}": {}'.format(p.pid, ' '.join(args), e)) 2233 log('error while killing subprocess {0} "{1}": {2}'.format(p.pid, ' '.join(args), e))
2231 2234
2232 if _opts and _opts.verbose: 2235 if _opts and _opts.verbose:
2233 import traceback 2236 import traceback
2234 traceback.print_stack() 2237 traceback.print_stack()
2235 raise SystemExit(codeOrMessage) 2238 raise SystemExit(codeOrMessage)
2302 2305
2303 def __str__(self): 2306 def __str__(self):
2304 return self.proj.name 2307 return self.proj.name
2305 2308
2306 def logCompilation(self, compiler): 2309 def logCompilation(self, compiler):
2307 log('Compiling Java sources for {} with {}... [{}]'.format(self.proj.name, compiler, self.reason)) 2310 log('Compiling Java sources for {0} with {1}... [{2}]'.format(self.proj.name, compiler, self.reason))
2308 2311
2309 def execute(self): 2312 def execute(self):
2310 argfileName = join(self.proj.dir, 'javafilelist.txt') 2313 argfileName = join(self.proj.dir, 'javafilelist.txt')
2311 argfile = open(argfileName, 'wb') 2314 argfile = open(argfileName, 'wb')
2312 argfile.write('\n'.join(map(_cygpathU2W, self.javafilelist))) 2315 argfile.write('\n'.join(map(_cygpathU2W, self.javafilelist)))
2686 worklist = sortWorklist(worklist) 2689 worklist = sortWorklist(worklist)
2687 2690
2688 failed += joinTasks(active) 2691 failed += joinTasks(active)
2689 if len(failed): 2692 if len(failed):
2690 for t in failed: 2693 for t in failed:
2691 log('Compiling {} failed'.format(t.proj.name)) 2694 log('Compiling {0} failed'.format(t.proj.name))
2692 abort('{} Java compilation tasks failed'.format(len(failed))) 2695 abort('{0} Java compilation tasks failed'.format(len(failed)))
2693 2696
2694 if args.java: 2697 if args.java:
2695 for dist in sorted_dists(): 2698 for dist in sorted_dists():
2696 if dist not in updatedAnnotationProcessorDists: 2699 if dist not in updatedAnnotationProcessorDists:
2697 archive(['@' + dist.name]) 2700 archive(['@' + dist.name])
3037 # Remove non-canonical candidates 3040 # Remove non-canonical candidates
3038 for c in list(candidates): 3041 for c in list(candidates):
3039 candidates.difference_update(c.all_deps([], False, False)) 3042 candidates.difference_update(c.all_deps([], False, False))
3040 candidates = [d.name for d in candidates] 3043 candidates = [d.name for d in candidates]
3041 3044
3042 abort('{} does not use any packages defined in these projects: {}\nComputed project dependencies: {}'.format( 3045 abort('{0} does not use any packages defined in these projects: {1}\nComputed project dependencies: {2}'.format(
3043 p, ', '.join(ignoredDeps), ','.join(candidates))) 3046 p, ', '.join(ignoredDeps), ','.join(candidates)))
3044 3047
3045 excess = frozenset(p.deps) - set(p.canonical_deps()) 3048 excess = frozenset(p.deps) - set(p.canonical_deps())
3046 if len(excess) != 0: 3049 if len(excess) != 0:
3047 nonCanonical.append(p) 3050 nonCanonical.append(p)
3164 source = [None] 3167 source = [None]
3165 def start_element(name, attrs): 3168 def start_element(name, attrs):
3166 if name == 'file': 3169 if name == 'file':
3167 source[0] = attrs['name'] 3170 source[0] = attrs['name']
3168 elif name == 'error': 3171 elif name == 'error':
3169 errors.append('{}:{}: {}'.format(source[0], attrs['line'], attrs['message'])) 3172 errors.append('{0}:{1}: {2}'.format(source[0], attrs['line'], attrs['message']))
3170 3173
3171 xp = xml.parsers.expat.ParserCreate() 3174 xp = xml.parsers.expat.ParserCreate()
3172 xp.StartElementHandler = start_element 3175 xp.StartElementHandler = start_element
3173 with open(auditfileName) as fp: 3176 with open(auditfileName) as fp:
3174 xp.ParseFile(fp) 3177 xp.ParseFile(fp)
4780 dotErr = None 4783 dotErr = None
4781 try: 4784 try:
4782 if not 'version' in subprocess.check_output(['dot', '-V'], stderr=subprocess.STDOUT): 4785 if not 'version' in subprocess.check_output(['dot', '-V'], stderr=subprocess.STDOUT):
4783 dotErr = 'dot -V does not print a string containing "version"' 4786 dotErr = 'dot -V does not print a string containing "version"'
4784 except subprocess.CalledProcessError as e: 4787 except subprocess.CalledProcessError as e:
4785 dotErr = 'error calling "dot -V": {}'.format(e) 4788 dotErr = 'error calling "dot -V": {0}'.format(e)
4786 except OSError as e: 4789 except OSError as e:
4787 dotErr = 'error calling "dot -V": {}'.format(e) 4790 dotErr = 'error calling "dot -V": {0}'.format(e)
4788 4791
4789 if dotErr != None: 4792 if dotErr != None:
4790 abort('cannot generate dependency graph: ' + dotErr) 4793 abort('cannot generate dependency graph: ' + dotErr)
4791 4794
4792 dot = join(tmpbase, 'all', str(args.dot_output_base) + '.dot') 4795 dot = join(tmpbase, 'all', str(args.dot_output_base) + '.dot')
4822 with open(svg, 'w') as fp: 4825 with open(svg, 'w') as fp:
4823 fp.write(content) 4826 fp.write(content)
4824 4827
4825 # Create HTML that embeds the svg file in an <object> frame 4828 # Create HTML that embeds the svg file in an <object> frame
4826 with open(html, 'w') as fp: 4829 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) 4830 print >> fp, '<html><body><object data="{0}.svg" type="image/svg+xml"></object></body></html>'.format(args.dot_output_base)
4828 4831
4829 if exists(args.base): 4832 if exists(args.base):
4830 shutil.rmtree(args.base) 4833 shutil.rmtree(args.base)
4831 if args.tmp: 4834 if args.tmp:
4832 shutil.copytree(tmpbase, args.base) 4835 shutil.copytree(tmpbase, args.base)
5175 _primary_suite = _loadSuite(primarySuiteMxDir, True) 5178 _primary_suite = _loadSuite(primarySuiteMxDir, True)
5176 else: 5179 else:
5177 abort('no primary suite found') 5180 abort('no primary suite found')
5178 5181
5179 opts, commandAndArgs = _argParser._parse_cmd_line() 5182 opts, commandAndArgs = _argParser._parse_cmd_line()
5180 5183 assert _opts == opts
5181 global _opts, _java_homes 5184
5182 _opts = opts 5185 global _java_homes
5183 defaultJdk = JavaConfig(opts.java_home, opts.java_dbg_port) 5186 defaultJdk = JavaConfig(opts.java_home, opts.java_dbg_port)
5184 _java_homes = [defaultJdk] 5187 _java_homes = [defaultJdk]
5185 if opts.extra_java_homes: 5188 if opts.extra_java_homes:
5186 for java_home in opts.extra_java_homes.split(os.pathsep): 5189 for java_home in opts.extra_java_homes.split(os.pathsep):
5187 extraJdk = JavaConfig(java_home, opts.java_dbg_port) 5190 extraJdk = JavaConfig(java_home, opts.java_dbg_port)