comparison mxtool/mx.py @ 17182:d6c7c530ca84

mx: change name of suite specification file from projects.py to suite.py
author Doug Simon <doug.simon@oracle.com>
date Tue, 23 Sep 2014 12:52:22 +0200
parents a8c0553cb2e4
children 4046e014f29f
comparison
equal deleted inserted replaced
17181:dddb5e4e51a4 17182:d6c7c530ca84
916 p.println('}') 916 p.println('}')
917 else: 917 else:
918 p.println('},') 918 p.println('},')
919 p.println('') 919 p.println('')
920 920
921 existing, projectsPyFile = _load_suite_dict(dirname(projectsFile)) 921 existing, suitePyFile = _load_suite_dict(dirname(projectsFile))
922 if existing: 922 if existing:
923 assert existing['name'] == suite.pop('name') 923 assert existing['name'] == suite.pop('name')
924 assert existing['mxversion'] == suite.pop('mxversion') 924 assert existing['mxversion'] == suite.pop('mxversion')
925 for s in ['projects', 'libraries', 'jrelibraries', 'distributions']: 925 for s in ['projects', 'libraries', 'jrelibraries', 'distributions']:
926 section = suite[s] 926 section = suite[s]
951 print_section(p, 'distribution_extensions', suite, is_last=True) 951 print_section(p, 'distribution_extensions', suite, is_last=True)
952 952
953 p.dec() 953 p.dec()
954 p.println('}') 954 p.println('}')
955 955
956 with open(projectsPyFile, 'w') as fp: 956 with open(suitePyFile, 'w') as fp:
957 fp.write(out.getvalue()) 957 fp.write(out.getvalue())
958 if verbose: 958 if verbose:
959 print 'created: ' + projectsPyFile 959 print 'created: ' + suitePyFile
960 960
961 def _load_suite_dict(mxDir): 961 def _load_suite_dict(mxDir):
962 962
963 suffix = 1 963 suffix = 1
964 suite = None 964 suite = None
978 if '$' in value or '%' in value: 978 if '$' in value or '%' in value:
979 abort('value of ' + '.'.join(context) + ' contains an undefined environment variable: ' + value) 979 abort('value of ' + '.'.join(context) + ' contains an undefined environment variable: ' + value)
980 980
981 return value 981 return value
982 982
983 moduleName = 'projects' 983 moduleName = 'suite'
984 modulePath = join(mxDir, moduleName + '.py') 984 modulePath = join(mxDir, moduleName + '.py')
985 while exists(modulePath): 985 while exists(modulePath):
986 986
987 savedModule = sys.modules.get(moduleName) 987 savedModule = sys.modules.get(moduleName)
988 if savedModule: 988 if savedModule:
1044 if not isinstance(v, types.ListType): 1044 if not isinstance(v, types.ListType):
1045 abort('distribution_extensions.' + n + '.dependencies must be a list') 1045 abort('distribution_extensions.' + n + '.dependencies must be a list')
1046 original['dependencies'] += v 1046 original['dependencies'] += v
1047 1047
1048 dictName = 'extra' 1048 dictName = 'extra'
1049 moduleName = 'projects' + str(suffix) 1049 moduleName = 'suite' + str(suffix)
1050 modulePath = join(mxDir, moduleName + '.py') 1050 modulePath = join(mxDir, moduleName + '.py')
1051
1052 deprecatedModulePath = join(mxDir, 'projects' + str(suffix) + '.py')
1053 if exists(deprecatedModulePath):
1054 abort('Please rename ' + deprecatedModulePath + ' to ' + modulePath)
1055
1051 suffix = suffix + 1 1056 suffix = suffix + 1
1052 1057
1053 return suite, modulePath 1058 return suite, modulePath
1054 1059
1055 class Suite: 1060 class Suite:
1078 # TODO: remove once mx/projects has been deprecated 1083 # TODO: remove once mx/projects has been deprecated
1079 projectsFile = join(self.mxDir, 'projects') 1084 projectsFile = join(self.mxDir, 'projects')
1080 if exists(projectsFile): 1085 if exists(projectsFile):
1081 convertprojects([projectsFile], verbose=False) 1086 convertprojects([projectsFile], verbose=False)
1082 1087
1083 projectsPyFile = join(self.mxDir, 'projects.py') 1088 suitePyFile = join(self.mxDir, 'suite.py')
1084 if not exists(projectsPyFile): 1089 if not exists(suitePyFile):
1085 return 1090 return
1086 1091
1087 suiteDict, _ = _load_suite_dict(self.mxDir) 1092 suiteDict, _ = _load_suite_dict(self.mxDir)
1088 1093
1089 if suiteDict.get('name') is not None and suiteDict.get('name') != self.name: 1094 if suiteDict.get('name') is not None and suiteDict.get('name') != self.name:
1217 arc.zf.writestr(arcname, lp.read(arcname)) 1222 arc.zf.writestr(arcname, lp.read(arcname))
1218 d.add_update_listener(_refineAnnotationProcessorServiceConfig) 1223 d.add_update_listener(_refineAnnotationProcessorServiceConfig)
1219 self.dists.append(d) 1224 self.dists.append(d)
1220 1225
1221 if self.name is None: 1226 if self.name is None:
1222 abort('Missing "suite=<name>" in ' + projectsPyFile) 1227 abort('Missing "suite=<name>" in ' + suitePyFile)
1223 1228
1224 def _commands_name(self): 1229 def _commands_name(self):
1225 return 'mx_' + self.name.replace('-', '_') 1230 return 'mx_' + self.name.replace('-', '_')
1226 1231
1227 def _find_commands(self, name): 1232 def _find_commands(self, name):
3584 3589
3585 generate_eclipse_workingsets() 3590 generate_eclipse_workingsets()
3586 3591
3587 def _check_ide_timestamp(suite, configZip, ide): 3592 def _check_ide_timestamp(suite, configZip, ide):
3588 """return True if and only if the projects file, eclipse-settings files, and mx itself are all older than configZip""" 3593 """return True if and only if the projects file, eclipse-settings files, and mx itself are all older than configZip"""
3589 projectsPyFiles = [join(suite.mxDir, e) for e in os.listdir(suite.mxDir) if e.startswith('projects') and e.endswith('.py')] 3594 suitePyFiles = [join(suite.mxDir, e) for e in os.listdir(suite.mxDir) if e.startswith('suite') and e.endswith('.py')]
3590 if configZip.isOlderThan(projectsPyFiles): 3595 if configZip.isOlderThan(suitePyFiles):
3591 return False 3596 return False
3592 # Assume that any mx change might imply changes to the generated IDE files 3597 # Assume that any mx change might imply changes to the generated IDE files
3593 if configZip.isOlderThan(__file__): 3598 if configZip.isOlderThan(__file__):
3594 return False 3599 return False
3595 3600
5217 """ 5222 """
5218 if os.path.isdir(d): 5223 if os.path.isdir(d):
5219 for f in os.listdir(d): 5224 for f in os.listdir(d):
5220 if (mxDirName == None and (f == 'mx' or fnmatch.fnmatch(f, 'mx.*'))) or f == mxDirName: 5225 if (mxDirName == None and (f == 'mx' or fnmatch.fnmatch(f, 'mx.*'))) or f == mxDirName:
5221 mxDir = join(d, f) 5226 mxDir = join(d, f)
5222 if exists(mxDir) and isdir(mxDir) and (exists(join(mxDir, 'projects.py')) or exists(join(mxDir, 'projects'))): 5227 if exists(mxDir) and isdir(mxDir) and (exists(join(mxDir, 'suite.py')) or exists(join(mxDir, 'projects'))):
5223 return mxDir 5228 return mxDir
5224 5229
5225 def _check_primary_suite(): 5230 def _check_primary_suite():
5226 if _primary_suite is None: 5231 if _primary_suite is None:
5227 abort('no primary suite found') 5232 abort('no primary suite found')