comparison mxtool/mx.py @ 4180:383c1272cd1f

Fixed gate script such that JAVA_HOME can be set in env file.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Mon, 02 Jan 2012 22:18:16 +0100
parents d1b26c17910a
children 71a2cd79c375
comparison
equal deleted inserted replaced
4179:816a4408a853 4180:383c1272cd1f
228 self.dir = dir 228 self.dir = dir
229 self.projects = [] 229 self.projects = []
230 self.libs = [] 230 self.libs = []
231 self.includes = [] 231 self.includes = []
232 self.commands = None 232 self.commands = None
233 self._load(join(dir, 'mx'), primary=primary) 233 self.primary = primary
234 self._load_env(join(dir, 'mx'))
234 235
235 def _load_projects(self, mxDir): 236 def _load_projects(self, mxDir):
236 libsMap = dict() 237 libsMap = dict()
237 projsMap = dict() 238 projsMap = dict()
238 projectsFile = join(mxDir, 'projects') 239 projectsFile = join(mxDir, 'projects')
325 for line in f: 326 for line in f:
326 line = line.strip() 327 line = line.strip()
327 if len(line) != 0 and line[0] != '#': 328 if len(line) != 0 and line[0] != '#':
328 key, value = line.split('=', 1) 329 key, value = line.split('=', 1)
329 os.environ[key.strip()] = expandvars_in_property(value.strip()) 330 os.environ[key.strip()] = expandvars_in_property(value.strip())
330 331
331 def _load(self, mxDir, primary): 332 def _post_init(self, opts):
332 self._load_env(mxDir) 333 mxDir = join(self.dir, 'mx')
333 self._load_includes(mxDir) 334 self._load_includes(mxDir)
334 self._load_projects(mxDir) 335 self._load_projects(mxDir)
335 if primary: 336 if self.primary:
336 self._load_commands(mxDir) 337 self._load_commands(mxDir)
338 if commands is not None and hasattr(commands, 'mx_post_parse_cmd_line'):
339 commands.mx_post_parse_cmd_line(opts)
340 for p in self.projects:
341 existing = _projects.get(p.name)
342 if existing is not None:
343 abort('cannot override project ' + p.name + ' in ' + p.dir + " with project of the same name in " + existing.dir)
344 _projects[p.name] = p
345 for l in self.libs:
346 existing = _libs.get(l.name)
347 if existing is not None:
348 abort('cannot redefine library ' + l.name)
349 _libs[l.name] = l
337 350
338 def get_os(): 351 def get_os():
339 """ 352 """
340 Get a canonical form of sys.platform. 353 Get a canonical form of sys.platform.
341 """ 354 """
355 if not exists(mxDir) or not isdir(mxDir): 368 if not exists(mxDir) or not isdir(mxDir):
356 return 369 return
357 if not _suites.has_key(dir): 370 if not _suites.has_key(dir):
358 suite = Suite(dir, primary) 371 suite = Suite(dir, primary)
359 _suites[dir] = suite 372 _suites[dir] = suite
360 for p in suite.projects:
361 existing = _projects.get(p.name)
362 if existing is not None:
363 abort('cannot override project ' + p.name + ' in ' + p.dir + " with project of the same name in " + existing.dir)
364 _projects[p.name] = p
365 for l in suite.libs:
366 existing = _libs.get(l.name)
367 if existing is not None:
368 abort('cannot redefine library ' + l.name)
369 _libs[l.name] = l
370 373
371 def suites(): 374 def suites():
372 """ 375 """
373 Get the list of all loaded suites. 376 Get the list of all loaded suites.
374 """ 377 """
1146 d = join(path, 'mx') 1149 d = join(path, 'mx')
1147 if exists(d) and isdir(d): 1150 if exists(d) and isdir(d):
1148 _loadSuite(path) 1151 _loadSuite(path)
1149 1152
1150 cwdMxDir = join(os.getcwd(), 'mx') 1153 cwdMxDir = join(os.getcwd(), 'mx')
1154 if exists(cwdMxDir) and isdir(cwdMxDir):
1155 _loadSuite(os.getcwd(), True)
1151 1156
1152 opts, commandAndArgs = _argParser._parse_cmd_line() 1157 opts, commandAndArgs = _argParser._parse_cmd_line()
1153 1158
1154 global _opts, _java 1159 global _opts, _java
1155 _opts = opts 1160 _opts = opts
1156 _java = JavaConfig(opts) 1161 _java = JavaConfig(opts)
1157 1162
1158 if exists(cwdMxDir) and isdir(cwdMxDir):
1159 _loadSuite(os.getcwd(), True)
1160
1161 for s in suites(): 1163 for s in suites():
1162 if s.commands is not None and hasattr(s.commands, 'mx_post_parse_cmd_line'): 1164 s._post_init(opts)
1163 s.commands.mx_post_parse_cmd_line(opts)
1164 1165
1165 if len(commandAndArgs) == 0: 1166 if len(commandAndArgs) == 0:
1166 _argParser.print_help() 1167 _argParser.print_help()
1167 return 1168 return
1168 1169