comparison mxtool/mx.py @ 15601:4aeb0b80324f

mx distributions: allow to specify dependencies between distributions
author Bernhard Urban <bernhard.urban@jku.at>
date Mon, 12 May 2014 22:37:14 +0200
parents c3869fe3d917
children 83c69954bbaa
comparison
equal deleted inserted replaced
15600:2a5f05654bc6 15601:4aeb0b80324f
60 60
61 """ 61 """
62 A distribution is a jar or zip file containing the output from one or more Java projects. 62 A distribution is a jar or zip file containing the output from one or more Java projects.
63 """ 63 """
64 class Distribution: 64 class Distribution:
65 def __init__(self, suite, name, path, sourcesPath, deps, excludedDependencies): 65 def __init__(self, suite, name, path, sourcesPath, deps, excludedDependencies, distDependency):
66 self.suite = suite 66 self.suite = suite
67 self.name = name 67 self.name = name
68 self.path = path.replace('/', os.sep) 68 self.path = path.replace('/', os.sep)
69 self.path = _make_absolute(self.path, suite.dir) 69 self.path = _make_absolute(self.path, suite.dir)
70 self.sourcesPath = _make_absolute(sourcesPath.replace('/', os.sep), suite.dir) if sourcesPath else None 70 self.sourcesPath = _make_absolute(sourcesPath.replace('/', os.sep), suite.dir) if sourcesPath else None
71 self.deps = deps 71 self.deps = deps
72 self.update_listeners = set() 72 self.update_listeners = set()
73 self.excludedDependencies = excludedDependencies 73 self.excludedDependencies = excludedDependencies
74 self.distDependency = distDependency
74 75
75 def sorted_deps(self, includeLibs=False): 76 def sorted_deps(self, includeLibs=False):
76 try: 77 try:
77 excl = [dependency(d) for d in self.excludedDependencies] 78 excl = [dependency(d) for d in self.excludedDependencies]
78 except SystemExit as e: 79 except SystemExit as e:
122 for arcname in lp.namelist(): 123 for arcname in lp.namelist():
123 overwriteCheck(srcArc.zf, arcname, lpath + '!' + arcname) 124 overwriteCheck(srcArc.zf, arcname, lpath + '!' + arcname)
124 srcArc.zf.writestr(arcname, lp.read(arcname)) 125 srcArc.zf.writestr(arcname, lp.read(arcname))
125 else: 126 else:
126 p = dep 127 p = dep
128
129 if self.distDependency and p in _dists[self.distDependency].sorted_deps():
130 logv("Excluding {0} from {1} because it's provided by the dependency {2}".format(p.name, self.path, self.distDependency))
131 continue
132
127 # skip a Java project if its Java compliance level is "higher" than the configured JDK 133 # skip a Java project if its Java compliance level is "higher" than the configured JDK
128 jdk = java(p.javaCompliance) 134 jdk = java(p.javaCompliance)
129 if not jdk: 135 if not jdk:
130 log('Excluding {0} from {2} (Java compliance level {1} required)'.format(p.name, p.javaCompliance, self.path)) 136 log('Excluding {0} from {2} (Java compliance level {1} required)'.format(p.name, p.javaCompliance, self.path))
131 continue 137 continue
747 for name, attrs in distsMap.iteritems(): 753 for name, attrs in distsMap.iteritems():
748 path = attrs.pop('path') 754 path = attrs.pop('path')
749 sourcesPath = attrs.pop('sourcesPath', None) 755 sourcesPath = attrs.pop('sourcesPath', None)
750 deps = pop_list(attrs, 'dependencies') 756 deps = pop_list(attrs, 'dependencies')
751 exclDeps = pop_list(attrs, 'exclude') 757 exclDeps = pop_list(attrs, 'exclude')
752 d = Distribution(self, name, path, sourcesPath, deps, exclDeps) 758 distDep = attrs.pop('distDependency', None)
759 d = Distribution(self, name, path, sourcesPath, deps, exclDeps, distDep)
753 d.__dict__.update(attrs) 760 d.__dict__.update(attrs)
754 self.dists.append(d) 761 self.dists.append(d)
755 762
756 if self.name is None: 763 if self.name is None:
757 abort('Missing "suite=<name>" in ' + projectsFile) 764 abort('Missing "suite=<name>" in ' + projectsFile)