comparison mxtool/mx.py @ 13358:e1a50eac0eac

Add a version number for the mxtool and support for requesting a minimum mx version in a suite
author Gilles Duboscq <duboscq@ssw.jku.at>
date Tue, 17 Dec 2013 14:43:41 +0100
parents 9c3c915b5f56
children eb7bc1fd38de
comparison
equal deleted inserted replaced
13357:dad7737243c6 13358:e1a50eac0eac
673 self.libs = [] 673 self.libs = []
674 self.dists = [] 674 self.dists = []
675 self.imports = [] 675 self.imports = []
676 self.commands = None 676 self.commands = None
677 self.primary = primary 677 self.primary = primary
678 self.requiredMxVersion = None
678 self.name = _suitename(mxDir) # validated in _load_projects 679 self.name = _suitename(mxDir) # validated in _load_projects
679 if load: 680 if load:
680 # load suites bottom up to make sure command overriding works properly 681 # load suites bottom up to make sure command overriding works properly
681 self._load_imports() 682 self._load_imports()
682 self._load_env() 683 self._load_env()
712 key, value = line.split('=', 1) 713 key, value = line.split('=', 1)
713 714
714 parts = key.split('@') 715 parts = key.split('@')
715 716
716 if len(parts) == 1: 717 if len(parts) == 1:
717 if parts[0] != 'suite': 718 if parts[0] == 'suite':
719 if self.name != value:
720 abort('suite name in project file does not match ' + _suitename(self.mxDir))
721 elif parts[0] == 'mxversion':
722 try:
723 self.requiredMxVersion = JavaVersion(value)
724 except AssertionError as ae:
725 abort('Exception while parsing "mxversion" in project file: ' + str(ae))
726 else:
718 abort('Single part property must be "suite": ' + key) 727 abort('Single part property must be "suite": ' + key)
719 if self.name != value: 728
720 abort('suite name in project file does not match ' + _suitename(self.mxDir))
721 continue 729 continue
722 if len(parts) != 3: 730 if len(parts) != 3:
723 abort('Property name does not have 3 parts separated by "@": ' + key) 731 abort('Property name does not have 3 parts separated by "@": ' + key)
724 kind, name, attr = parts 732 kind, name, attr = parts
725 if kind == 'project': 733 if kind == 'project':
887 key, value = line.split('=', 1) 895 key, value = line.split('=', 1)
888 os.environ[key.strip()] = expandvars_in_property(value.strip()) 896 os.environ[key.strip()] = expandvars_in_property(value.strip())
889 897
890 def _post_init(self, opts): 898 def _post_init(self, opts):
891 self._load_projects() 899 self._load_projects()
900 if self.requiredMxVersion is None:
901 warn("This suite does not express any required mx version. Consider adding 'mxversion=<version>' to your projects file.")
902 elif self.requiredMxVersion > version:
903 abort("This suite requires mx version " + str(self.requiredMxVersion) + " while your current mx verion is " + str(version) + ". Please update mx.")
892 # set the global data structures, checking for conflicts unless _check_global_structures is False 904 # set the global data structures, checking for conflicts unless _check_global_structures is False
893 for p in self.projects: 905 for p in self.projects:
894 existing = _projects.get(p.name) 906 existing = _projects.get(p.name)
895 if existing is not None and _check_global_structures: 907 if existing is not None and _check_global_structures:
896 abort('cannot override project ' + p.name + ' in ' + p.dir + " with project of the same name in " + existing.dir) 908 abort('cannot override project ' + p.name + ' in ' + p.dir + " with project of the same name in " + existing.dir)
1550 """ 1562 """
1551 class JavaVersion: 1563 class JavaVersion:
1552 def __init__(self, versionString): 1564 def __init__(self, versionString):
1553 validChar = r'[\x21-\x25\x27-\x29\x2c\x2f-\x5e\x60-\x7f]' 1565 validChar = r'[\x21-\x25\x27-\x29\x2c\x2f-\x5e\x60-\x7f]'
1554 separator = r'[.\-_]' 1566 separator = r'[.\-_]'
1555 m = re.match(validChar + '+(' + separator + validChar + '+)*', versionString) 1567 m = re.match("^" + validChar + '+(' + separator + validChar + '+)*$', versionString)
1556 assert m is not None, 'not a recognized version string: ' + versionString 1568 assert m is not None, 'not a recognized version string: ' + versionString
1557 self.versionString = versionString 1569 self.versionString = versionString
1558 self.parts = [int(f) if f.isdigit() else f for f in re.split(separator, versionString)] 1570 self.parts = [int(f) if f.isdigit() else f for f in re.split(separator, versionString)]
1559 1571
1560 def __str__(self): 1572 def __str__(self):
4514 abort(retcode) 4526 abort(retcode)
4515 except KeyboardInterrupt: 4527 except KeyboardInterrupt:
4516 # no need to show the stack trace when the user presses CTRL-C 4528 # no need to show the stack trace when the user presses CTRL-C
4517 abort(1) 4529 abort(1)
4518 4530
4531 version = JavaVersion("1.0")
4532
4519 if __name__ == '__main__': 4533 if __name__ == '__main__':
4520 # rename this module as 'mx' so it is not imported twice by the commands.py modules 4534 # rename this module as 'mx' so it is not imported twice by the commands.py modules
4521 sys.modules['mx'] = sys.modules.pop('__main__') 4535 sys.modules['mx'] = sys.modules.pop('__main__')
4522 4536
4523 main() 4537 main()