changeset 21043:5ea65fe64368

Check distributions overlap in gate
author Gilles Duboscq <gilles.m.duboscq@oracle.com>
date Mon, 20 Apr 2015 18:27:46 +0200
parents 38b39b75500c
children 43cec8244540 934c6ec83d62
files mx/mx_graal.py mxtool/mx.py
diffstat 2 files changed, 17 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mx/mx_graal.py	Mon Apr 20 14:40:48 2015 +0200
+++ b/mx/mx_graal.py	Mon Apr 20 18:27:46 2015 +0200
@@ -1412,6 +1412,7 @@
     parser = ArgumentParser(prog='mx buildvms')
     parser.add_argument('--vms', help='a comma separated list of VMs to build (default: ' + vmsDefault + ')', metavar='<args>', default=vmsDefault)
     parser.add_argument('--builds', help='a comma separated list of build types (default: ' + vmbuildsDefault + ')', metavar='<args>', default=vmbuildsDefault)
+    parser.add_argument('--check-distributions', action='store_true', dest='check_distributions', help='check built distributions for overlap')
     parser.add_argument('-n', '--no-check', action='store_true', help='omit running "java -version" after each build')
     parser.add_argument('-c', '--console', action='store_true', help='send build output to console instead of log file')
 
@@ -1420,6 +1421,7 @@
     builds = args.builds.split(',')
 
     allStart = time.time()
+    check_dists_args = ['--check-distributions'] if args.check_distributions else []
     for v in vms:
         if not isVMSupported(v):
             mx.log('The ' + v + ' VM is not supported on this platform - skipping')
@@ -1435,14 +1437,14 @@
                 mx.log('BEGIN: ' + v + '-' + vmbuild + '\t(see: ' + logFile + ')')
                 verbose = ['-v'] if mx._opts.verbose else []
                 # Run as subprocess so that output can be directed to a file
-                cmd = [sys.executable, '-u', join('mxtool', 'mx.py')] + verbose + ['--vm', v, '--vmbuild', vmbuild, 'build']
+                cmd = [sys.executable, '-u', join('mxtool', 'mx.py')] + verbose + ['--vm', v, '--vmbuild', vmbuild, 'build'] + check_dists_args
                 mx.logv("executing command: " + str(cmd))
                 subprocess.check_call(cmd, cwd=_graal_home, stdout=log, stderr=subprocess.STDOUT)
                 duration = datetime.timedelta(seconds=time.time() - start)
                 mx.log('END:   ' + v + '-' + vmbuild + '\t[' + str(duration) + ']')
             else:
                 with VM(v, vmbuild):
-                    build([])
+                    build(check_dists_args)
             if not args.no_check:
                 vmargs = ['-version']
                 if v == 'graal':
@@ -1525,7 +1527,7 @@
 def _basic_gate_body(args, tasks):
     # Build server-hosted-graal now so we can run the unit tests
     with Task('BuildHotSpotGraalHosted: product', tasks) as t:
-        if t: buildvms(['--vms', 'server', '--builds', 'product'])
+        if t: buildvms(['--vms', 'server', '--builds', 'product', '--check-distributions'])
 
     # Run unit tests on server-hosted-graal
     with VM('server', 'product'):
@@ -1539,7 +1541,7 @@
 
     # Build the other VM flavors
     with Task('BuildHotSpotGraalOthers: fastdebug,product', tasks) as t:
-        if t: buildvms(['--vms', 'graal,server', '--builds', 'fastdebug,product'])
+        if t: buildvms(['--vms', 'graal,server', '--builds', 'fastdebug,product', '--check-distributions'])
 
     with VM('graal', 'fastdebug'):
         with Task('BootstrapWithSystemAssertions:fastdebug', tasks) as t:
--- a/mxtool/mx.py	Mon Apr 20 14:40:48 2015 +0200
+++ b/mxtool/mx.py	Mon Apr 20 18:27:46 2015 +0200
@@ -101,7 +101,7 @@
 A distribution is a jar or zip file containing the output from one or more Java projects.
 """
 class Distribution:
-    def __init__(self, suite, name, path, sourcesPath, deps, mainClass, excludedDependencies, distDependencies, javaCompliance):
+    def __init__(self, suite, name, path, sourcesPath, deps, mainClass, excludedDependencies, distDependencies, javaCompliance, isProcessorDistribution=False):
         self.suite = suite
         self.name = name
         self.path = path.replace('/', os.sep)
@@ -113,6 +113,7 @@
         self.excludedDependencies = excludedDependencies
         self.distDependencies = distDependencies
         self.javaCompliance = JavaCompliance(javaCompliance) if javaCompliance else None
+        self.isProcessorDistribution = isProcessorDistribution
 
     def sorted_deps(self, includeLibs=False, transitive=False):
         deps = []
@@ -1090,7 +1091,7 @@
                 exclDeps = []
                 distDeps = []
                 javaCompliance = None
-                d = Distribution(self, dname, path, sourcesPath, deps, mainClass, exclDeps, distDeps, javaCompliance)
+                d = Distribution(self, dname, path, sourcesPath, deps, mainClass, exclDeps, distDeps, javaCompliance, True)
                 d.subDir = os.path.relpath(os.path.dirname(p.dir), self.dir)
                 self.dists.append(d)
                 p.definedAnnotationProcessors = annotationProcessors
@@ -2563,6 +2564,7 @@
     parser.add_argument('-p', action='store_true', dest='parallelize', help='parallelizes Java compilation if possible')
     parser.add_argument('--source', dest='compliance', help='Java compliance level for projects without an explicit one')
     parser.add_argument('--Wapi', action='store_true', dest='warnAPI', help='show warnings about using internal APIs')
+    parser.add_argument('--check-distributions', action='store_true', dest='check_distributions', help='check built distributions for overlap')
     parser.add_argument('--projects', action='store', help='comma separated projects to build (omit to build all projects)')
     parser.add_argument('--only', action='store', help='comma separated projects to build, without checking their dependencies (omit to build all projects)')
     parser.add_argument('--no-java', action='store_false', dest='java', help='do not build Java projects')
@@ -2790,9 +2792,16 @@
             abort('{0} Java compilation tasks failed'.format(len(failed)))
 
     if args.java:
+        files = []
         for dist in sorted_dists():
             if dist not in updatedAnnotationProcessorDists:
                 archive(['@' + dist.name])
+            if args.check_distributions and not dist.isProcessorDistribution:
+                with zipfile.ZipFile(dist.path, 'r') as zf:
+                    files.extend([member for member in zf.namelist() if not member.startswith('META-INF/services')])
+        dups = set([x for x in files if files.count(x) > 1])
+        if len(dups) > 0:
+            abort('Distributions overlap! duplicates: ' + str(dups))
 
     if suppliedParser:
         return args