changeset 16629:be59a1d39281

respect dependency order between distributions when building them
author Doug Simon <doug.simon@oracle.com>
date Thu, 31 Jul 2014 14:43:37 +0200
parents d3fec84757ed
children 2f4487a0b588
files mx/mx_graal.py mxtool/mx.py
diffstat 2 files changed, 20 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/mx/mx_graal.py	Thu Jul 31 13:42:56 2014 +0200
+++ b/mx/mx_graal.py	Thu Jul 31 14:43:37 2014 +0200
@@ -535,7 +535,7 @@
         # Store SHA1 in generated Java class and append class to specified jar
         javaSource = join(_graal_home, 'GeneratedSourcesSha1.java')
         javaClass = join(_graal_home, 'GeneratedSourcesSha1.class')
-        with open (javaSource, 'w') as fp:
+        with open(javaSource, 'w') as fp:
             print >> fp, 'class GeneratedSourcesSha1 { private static final String value = "' + sha1 + '"; }'
         subprocess.check_call([mx.java().javac, '-d', _graal_home, javaSource], stderr=subprocess.PIPE, stdout=subprocess.PIPE)
         zf = zipfile.ZipFile(dist.path, 'a')
--- a/mxtool/mx.py	Thu Jul 31 13:42:56 2014 +0200
+++ b/mxtool/mx.py	Thu Jul 31 14:43:37 2014 +0200
@@ -1006,7 +1006,7 @@
                             logv('[omitting project {} as dependency {} is missing]'.format(d, name))
                             del _projects[d.name]
                             self.projects.remove(d)
-        for dist in _dists.values():
+        for dist in _dists.itervalues():
             for name in list(dist.deps):
                 if not dependency(name, fatalIfMissing=False):
                     logv('[omitting {} from distribution {}]'.format(name, dist))
@@ -1315,6 +1315,23 @@
 
     return sorted_project_deps(projects, includeLibs=includeLibs, includeJreLibs=includeJreLibs, includeAnnotationProcessors=includeAnnotationProcessors)
 
+def sorted_dists():
+    """
+    Gets distributions sorted such that each distribution comes after
+    any distributions it depends upon.
+    """
+    dists = []
+    def add_dist(dist):
+        if not dist in dists:
+            for depDist in [distribution(name) for name in dist.distDependencies]:
+                add_dist(depDist)
+            if not dist in dists:
+                dists.append(dist)
+
+    for d in _dists.itervalues():
+        add_dist(d)
+    return dists
+
 def sorted_project_deps(projects, includeLibs=False, includeJreLibs=False, includeAnnotationProcessors=False):
     deps = []
     for p in projects:
@@ -2392,7 +2409,7 @@
                 log('Compiling {} failed'.format(t.proj.name))
             abort('{} Java compilation tasks failed'.format(len(failed)))
 
-    for dist in _dists.values():
+    for dist in sorted_dists():
         archive(['@' + dist.name])
 
     if suppliedParser:
@@ -3457,12 +3474,6 @@
     if buildProcessorJars:
         files += _processorjars_suite(suite)
 
-    projToDist = dict()
-    for dist in _dists.values():
-        distDeps = dist.sorted_deps()
-        for p in distDeps:
-            projToDist[p.name] = (dist, [dep.name for dep in distDeps])
-
     for p in suite.projects:
         if p.native:
             continue