📄 buildmenu.py
字号:
try: i = int(input) except ValueError: print print "** Invalid Input **" continue if i < 0 or i >= len(self.menu) + len(self.history): print print "** Invalid Input **" continue if i >= len(self.menu): self.flags = self.history [ i - len(self.menu) ] i = 3 ## call apply(self.menu[i][1], self.menu[i][2:]) def build(self, flags): ## add the branch to the arg_list arg_list = ['-m', self.build_branch] ## Add the cvs tag if self.cvs_tag: arg_list.extend(["-r", self.cvs_tag]) if self.cvs_date: arg_list.extend(["-D", self.cvs_date]) arg_list.extend(flags + self.targets) if self.GetBIF().module_hash.has_key(self.profile): os.environ["PROFILE_ID"] = self.profile else: os.environ["PROFILE_ID"] = self.get_profile_list().file(self.profile) ## run invoke_buildsystem(arg_list) os.chdir(self.working_path) def TagMenuOption(self): tag = "" if self.cvs_tag: tag=self.cvs_tag if self.cvs_date: tag=self.cvs_date if self.cvs_tag and self.cvs_date: tag=self.cvs_tag +"@"+self.cvs_date if tag: tag=" (currently: %s)" % tag return "Set Tag/Branch/Timestamp%s" % (tag) def SetTag(self): print "Current CVS Tag : \"%s\"" % self.cvs_tag print "Current CVS Date: \"%s\"" % self.cvs_date print "" print "You may enter a new tag, branch or date, to enter" print "both a branch and a date, put a @ in between." print "Example: yourbranch@2002/01/20 05:20:22" print "Note that if you are using BIFs and/or profiles" print "directly from CVS, then those files will be updated" print "using the information you enter here." print "" tag=raw_input("Enter branch, tag, date or branch@date: ") parts = string.split(tag,"@") self.cvs_tag="" self.cvs_date="" if len(parts) > 1: self.cvs_tag=parts[0] self.cvs_date=parts[1] elif (" " in tag) or ("/" in tag): self.cvs_date=tag else: self.cvs_tag=tag bldreg.set_value('build','cvs_date',self.cvs_date) bldreg.set_value('build','cvs_tag',self.cvs_tag) ## Update branchlist and profile_list import branchlist self.branch_list = branchlist.BranchList(self.cvs_tag, self.cvs_date) self.profile_list = None def ProfileMenuOption(self): return "Set Profile (%s)" % self.profile def SetProfile(self): print files_scanned=0 profiles = [] for p in self.GetModules(): if p.type == p.MODULE_PROFILE: profiles.append(p.id) max_bif=len(profiles) tmp = self.get_profile_list().get_list() tmp.sort() profiles.extend(tmp) profile=BasicMenu("profile",profiles).get() if not profile: print "Profile not changed" else: bldreg.set_value('build','profile',profile) self.profile=profile def BuildMenuOption(self): return "run: build %s" % self.mkarglist(self.flags) def Build(self): if self.flags in self.history: i=self.history.index(self.flags) del self.history[i] self.history = [ self.flags ] + self.history if len(self.history) > 5: self.history = self.history[:5] bldreg.set_value('build','history',self.history) # print "%r" % self.history self.build(self.flags) def Toggle(self, *flags): for flag in flags: if flag in self.flags: i = self.flags.index(flag) del self.flags[i] else: self.flags.append(flag) bldreg.set_value('build','arguments',self.flags) def CustomToggle(self): print "Descriptions of custom build options are under the Help" print "menu option." print reply = raw_input("[Custom Build Arguments]: ") for arg in string.split(reply): self.Toggle(string.strip(arg)) def TargetMenuOption(self): return "Set Target(s) (%s)" % self.mkarglist(self.targets) def GetBIF(self): if self.bif_data_cache: if self.bif_data_cache[0] == self.build_branch and \ self.bif_data_cache[1] == self.cvs_tag and \ self.bif_data_cache[2] == self.cvs_date: return self.bif_data_cache[3] filename = self.branch_list.file(self.build_branch) if not filename: return None print 'reading %s file' % (filename) import bif self.bif_data_cache = ( self.build_branch, self.cvs_tag, self.cvs_date, bif.load_bif_data(filename, self.branch_list) ) return self.bif_data_cache[3] def GetModules(self): bif_data = self.GetBIF() modules = bif_data.module_hash.values() modules.sort(lambda x, y: cmp(x.id, y.id)) return modules def SetTarget(self): modules = self.GetModules() toplevel=[] groups={} all=[] for m in modules: if m.get_attribute("from_shadow_only"): continue g=m.group or "other" if not groups.get(g): groups[g]=[m.id] else: groups[g].append(m.id) all.append(m.id) if m.get_attribute("primary_target"): toplevel.append(m.id) ## No point in creating menues with one choice if not toplevel and (len(all) < 20 or len(groups) <= 1): toplevel=all else: for g in groups.keys() + ["all"]: toplevel.append("List %s targets..." % g) groups["all"]=all groups[""]=toplevel group = "" while 1: selection = MultipleChoiceMenu("target", groups[group], all).get() if not selection: if group: group = "" continue print "Target not changed" return if len(selection) == 1: w=string.split(selection[0]) if len(w) > 2 and w[0] == "List" and w[-1]=="targets...": group=string.join(w[1:-1]) continue self.targets = selection bldreg.set_value('build','targets',self.targets) break def CheckoutSource(self): self.build(self.flags + ["-h"]) def BIFMenuOption(self): return "Set BIF branch (%s)" % (self.build_branch) def SetBIFBranch(self): branch_list = self.branch_list.get_bif_list() branch_list.sort() bif=BasicMenu("BIF",branch_list).get() if not bif: print "BIF Branch not changed" return bldreg.set_value('build', 'branch', bif) self.build_branch = bif bif_data = self.GetBIF() if bif_data.default_profile: bldreg.set_value('build','profile',bif_data.default_profile) self.profile=self.get_profile_list().file(bif_data.default_profile) if bif_data.default_target: self.targets = string.split(bif_data.default_target) bldreg.set_value('build','targets',self.targets) if bif_data.default_options: flags = string.split(bif_data.default_options) for flag in flags: flag = "-t"+flag if flag not in self.flags: self.flags.append(flag) bldreg.set_value('build','arguments',self.flags) print def Help(self): man_page() def Quit(self): self.done = 1def find_rcfile(name): """Execute $UMAKERC, $HOME/.umakerc, %HOMEDRIVE%HOMEPATH/umakerc.py or %preferencesfolder%:umakerc""" f=os.environ.get(string.upper(name),"") if f and os.path.isfile(f): return f home=os.environ.get("HOME","") if home: f=os.path.join(home,"." + name) if os.path.isfile(f): return f homedrive=os.environ.get("HOMEDRIVE","") homepath=os.environ.get("HOMEPATH","") if homedrive and homepath: f=os.path.join(homedrive + homepath, "."+name) if os.path.isfile(f): return f if sys.platform == "mac": import macfs import MACFS vrefnum, curdir = macfs.FindFolder( MACFS.kOnAppropriateDisk, MACFS.kPreferencesFolderType, 0) fss = macfs.FSSpec((vrefnum, curdir, name)) f= fss.as_pathname() if os.path.isfile(f): return f return Nonedef find_rcfile_location(name): """Execute $UMAKERC, $HOME/.umakerc, %HOMEDRIVE%HOMEPATH/umakerc.py or %preferencesfolder%:umakerc""" f=os.environ.get(string.upper(name),"") if f and os.path.isdir(os.path.dirname(f)): return f home=os.environ.get("HOME","") if home and os.path.isdir(home): return os.path.join(home,"." + name) homedrive=os.environ.get("HOMEDRIVE","") homepath=os.environ.get("HOMEPATH","") if homedrive and homepath: f=os.path.join(homedrive + homepath, "."+name) if os.path.isdir(os.path.dirname(f)): return f if sys.platform == "mac": import macfs import MACFS vrefnum, curdir = macfs.FindFolder( MACFS.kOnAppropriateDisk, MACFS.kPreferencesFolderType, 0) fss = macfs.FSSpec((vrefnum, curdir, name)) return fss.as_pathname() return Nonedefault_buildrc="""AddCVS("helix",":pserver:anoncvs@localhost:/cvs")AddBIFPath("common","[helix]common/build/BIF")"""#AddBIFPath("client","[helix]client/build/BIF")#AddBIFPath("producer","[helix]producer/build/BIF")def install_rcfile(): """Give the user the option of installing a buildrc file""" location = find_rcfile_location("buildrc") print "It seems you have not configured your buildrc file yet." if location: print "If you like, I can install a default buildrc file for you:" print "-------------------------------------------------------" print default_buildrc print "-------------------------------------------------------" ans=raw_input("Would you like to install the above in '%s'? " % location) if ans and string.lower(ans)[0] == 'y': open(location,"w").write(default_buildrc) print "Done" print print "The default bulidrc will enable to you to work against the" print "anonymous Helix CVS repository only. If you require named" print "cvs access, or access to more repositories and/or BIF file" print "directories, please exit the build system now and customize" print "your buildrc file. You will also need to set up an ssh" print "tunnel to be able to access the helixcommunity cvs repository." print "Read https://www.helixcommunity.org/nonav/docs/ddSSHGuide.html" print "for more information." print else: print "buildrc file not installed" print else: print print "I am unable to find a suitable location for your buildrc." print "You may need to set the BUILDRC environment variable to" print "specify the location of your buildrc file. Please refer" print "to the following file for more documentation:" print os.path.join(os.environ["BUILD_ROOT"], "doc", "buildrc.html") print if not find_rcfile("buildrc"): print "Running build without a buildrc fill will probably fail." ans = raw_input("Would you like to continue? ('no' will exit the program) :") if ans and string.lower(ans)[0] == 'n': sys.exit(1) def call_buildrc(install = 1): file = find_rcfile("buildrc") if not file and install: install_rcfile() if file: import cvs import branchlist import sdk import bif execfile(file, { "AddCVS" : cvs.Add, "AddMultiCVS" : cvs.AddMulti, "AddBIFPath": branchlist.AddBIFPath, "AddBIFShadow": bif.AddShadow, "AddProfilePath": branchlist.AddProfilePath, "RemoveProfilePath": branchlist.RemoveProfilePath, "SetSDKPath" : sdk.SetPath, "GetSDKPath" : sdk.GetPath, })## called externally to rundef run(force_menu_mode = 0): system_checks() system_fixes() ## if there are command-line arguments, then run non-interactive if len(sys.argv) > 1 and not force_menu_mode: call_buildrc(0) command_line_args() else: call_buildrc(1) ShellToolApp().main()
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -