# HG changeset patch # User Doug Simon # Date 1366373155 -7200 # Node ID c8f4e1081c0b37d7681bd1b7361d87fa2a5328cf # Parent 123991e4fbd870d7da2916e9642ea12c215a5e0b support for referencing commands in other suites (e.g. mx.suite('graal').commands.build([])) diff -r 123991e4fbd8 -r c8f4e1081c0b mx/projects --- a/mx/projects Fri Apr 19 11:51:20 2013 +0200 +++ b/mx/projects Fri Apr 19 14:05:55 2013 +0200 @@ -1,5 +1,7 @@ # The format of this file is described in the documentation for my.py. +suite=graal + library@JDK_TOOLS@path=${JAVA_HOME}/lib/tools.jar library@JDK_TOOLS@optional=true diff -r 123991e4fbd8 -r c8f4e1081c0b mxtool/mx.py --- a/mxtool/mx.py Fri Apr 19 11:51:20 2013 +0200 +++ b/mxtool/mx.py Fri Apr 19 14:05:55 2013 +0200 @@ -459,7 +459,11 @@ self._load_env(mxDir) self._load_commands(mxDir) self._load_includes(mxDir) - + self.name = d # re-initialized in _load_projects + + def __str__(self): + return self.name + def _load_projects(self, mxDir): libsMap = dict() projsMap = dict() @@ -475,8 +479,11 @@ parts = key.split('@') - if len(parts) == 2: - pass + if len(parts) == 1: + if parts[0] != 'suite': + abort('Single part property must be "suite": ' + key) + self.name = value + continue if len(parts) != 3: abort('Property name does not have 3 parts separated by "@": ' + key) kind, name, attr = parts @@ -539,6 +546,9 @@ d = Distribution(self, name, path, deps) d.__dict__.update(attrs) self.dists.append(d) + + if self.name is None: + abort('Missing "suite=" in ' + projectsFile) def _load_commands(self, mxDir): commands = join(mxDir, 'commands.py') @@ -547,7 +557,8 @@ sys.path.insert(0, mxDir) mod = __import__('commands') - sys.modules[join(mxDir, 'commands')] = sys.modules.pop('commands') + self.commands = sys.modules.pop('commands') + sys.modules[join(mxDir, 'commands')] = self.commands # revert the Python path del sys.path[0] @@ -582,6 +593,7 @@ def _post_init(self, opts): mxDir = join(self.dir, 'mx') self._load_projects(mxDir) + _suites[self.name] = self for p in self.projects: existing = _projects.get(p.name) if existing is not None: @@ -703,6 +715,15 @@ """ return _suites.values() +def suite(name, fatalIfMissing=True): + """ + Get the suite for a given name. + """ + s = _suites.get(name) + if s is None and fatalIfMissing: + abort('suite named ' + name + ' not found') + return s + def projects(): """ Get the list of all loaded projects.