📄 buildapp.py
字号:
self.setup_depends() ## print out some information about this build self.build_info() ## cvs checkout source code and get binary distributions for this build outmsg.send('getting files') self.get_files() ## update the platform-specific header file in the include/ directory self.update_platform() ## return now if we only want to checkout the files if self.settings.get('checkout_only_flag'): return ## compile the target if not self.settings.get('no_compile_flag'): outmsg.send('compiling') self.collate_modules() ## md5 sign the binaries outmsg.send('signing output binaries') self.sign() ## archive build if self.settings.get('archive_build_flag'): self.archive_build() if not self.settings['build_options'].count('buildfarm_build'): if self.settings['build_options'].count('distribute'): import distributions distributions.DistCheckin().process_checkins( self.settings['copy_path']) bldreg.sync_on() print print "Build complete, %d of %d modules failed." % (self.errors, self.built) def setup_build(self): pass #if os.path.isfile('md5_sign.txt'): # os.unlink('md5_sign.txt') def setup_depends(self): target_tmp=self.target_id_list[:] ## the -m <bif-branch> can either be a BIF id or a filename, ## we do the tests here... branch_list = None checkout_mode = 0 if self.settings.get("no_cvs_checkout_flag"): checkout_mode=3 if os.path.isfile(self.build_branch): self.build_xml_file = self.build_branch elif (bldreg.get("build","last_cvs_tag",None) == self.everything_from_cvs_tag and bldreg.get("build","last_cvs_date",None) == self.everything_from_cvs_date and bldreg.get("build","last_branch",None) == self.build_branch): import branchlist branch_list = branchlist.BranchList( self.everything_from_cvs_tag, self.everything_from_cvs_date, checkout_mode or 2) self.build_xml_file=bldreg.get("build","last_xml_file",None) else: import branchlist branch_list = branchlist.BranchList( self.everything_from_cvs_tag, self.everything_from_cvs_date, checkout_mode) self.build_xml_file = branch_list.file(self.build_branch) if not self.build_xml_file: e = err.Error() e.Set("Cannot find bif file for the branch=\"%s\"." % ( self.build_branch)) raise err.error, e bldreg.set_value("build","last_cvs_tag",self.everything_from_cvs_tag) bldreg.set_value("build","last_cvs_date",self.everything_from_cvs_date) bldreg.set_value("build","last_branch",self.build_branch) bldreg.set_value("build","last_xml_file",self.build_xml_file) ## parse the BIF/XML file and get information for this build outmsg.send("reading bif=\"%s\" file" % (self.build_xml_file)) import bif bif_data = bif.load_bif(self.build_xml_file, branch_list) self.build_branch = bif_data.build_id self.module_hash = bif_data.module_hash ## Check the profile profile=os.environ.get("PROFILE_ID", bldreg.get("build","profile","default")) if bif_data.module_hash.has_key(profile): profile_module = bif_data.module_hash[profile] bldreg.set_value("build","bif_profile",profile) if profile_module.type != profile_module.MODULE_PROFILE: print "WARNING: Using Profile '%s' from BIF," % profile print "even though it does not have type='profile'." target_tmp.append(profile) else: if not os.path.isfile(profile+".pf"): import branchlist profile_list = branchlist.ProfileList( self.everything_from_cvs_tag, self.everything_from_cvs_date, checkout_mode) profile = profile_list.file(profile) os.environ["PROFILE_ID"] = profile bldreg.set_value("build","profile",profile) ## if there wasn't a command-line specified cvs branch, ## then use the default branch specified in the XML file if self.default_cvs_tag == "": self.default_cvs_tag = bif_data.default_cvs_tag if self.default_cvs_tag_type == "": self.default_cvs_tag_type = bif_data.default_cvs_tag_type ## CVS timestamp if self.default_cvs_date == "": self.default_cvs_date = bif_data.default_cvs_date ## CVS ROOT if self.default_cvs_root == "": self.default_cvs_root = bif_data.default_cvs_root ## check that targets are valid for target_id in self.target_id_list: if not self.module_hash.has_key(target_id): e = err.Error() e.Set("Cannot find the target=\"%s\" you requested in "\ "the bif file." % (target_id)) raise err.error, e ## create a dependency list for all targets outmsg.send('computing dependency tree') import dependlist self.depends = dependlist.DependList(bif_data, target_tmp) if os.environ.get('BUILD_ON_PLATFORM','') == 'MacOSX': # This section calculates the top-level dependencies for each module # That is, it gets the list of dependencies listed in the bif file for the module, # replacing any name-only ("fake") modules with those actual dependencies # for the name-only module that apply to this platform. # # When it's done, we will have module_id_build_dict filled with # a mapping of module id to dependency module ids, like # module_id_build_dict['rmacore'] = ['pnmisc' ,'pncont', ...] # # The entries of the dictionary are used later to determine the list of # subtargets for eact target project in the uber outmsg.send("determining uber subtargets for each module to be built") build_list = self.depends.build_list() for module in build_list: self.module_id_build_dict[module.id] = [] dependancy_id_list = module.dependancy_id_list while 1: # for each id, get the module; if it's a real module we're building, # then we want its id; if it is a name only (fake) module, we want to # put its dependencies in the dependancy_id_list for the next iteration real_modules_ids_list = [] for x in build_list: if x.id in dependancy_id_list: real_modules_ids_list.append(x.id) fake_modules_ids_list = [] for x in dependancy_id_list: if x not in real_modules_ids_list: fake_modules_ids_list.append(x) # add all the real modules to our dependency list in the dict unless they are already in it new_unique_module_ids_list = [] for x in real_modules_ids_list: if not x in self.module_id_build_dict[module.id]: new_unique_module_ids_list.append(x) self.module_id_build_dict[module.id] = self.module_id_build_dict[module.id] + new_unique_module_ids_list #outmsg.send('module: %s' % (module.id)) #outmsg.send(' real dependancies: %s' % (string.join(real_modules_ids_list, ','))) #outmsg.send(' fake dependancies: %s' % (string.join(fake_modules_ids_list, ','))) if len(fake_modules_ids_list) < 1: break # break out of while loop since no fake modules need to be handled else: # get the dependancies for each fake module and make them our new dependancy list for the # next go round # # first, get the modules for the ids in our fake list fake_modules_list = [] for x in self.depends.module_list: if (x.id in fake_modules_ids_list) and (self.depends.chk_platform(x)): fake_modules_list.append(x) # next, put the items in their dependency lists into the fake list dependancy_id_list = [] for fakemodule in fake_modules_list: dependancy_id_list = dependancy_id_list + fakemodule.dependancy_id_list # if there are no dependencies left to resolve, we're done if len(dependancy_id_list) < 1: break # these simple lines would replace the above and give us the list of all modules # which are dependencies of this module #module_buildlist = dependlist.DependList(bif_data, [module.id]).build_list() #self.module_build_list[module.id] = module_buildlist #outmsg.send('module: %s build list: %s' % (module.id, string.join(self.module_id_build_dict[module.id]))) ## ## GETTING SOURCE/BINARIES FOR BUILD ## def get_files(self): ## download and unpack distribution/archive files dist_module_name_list = self.get_dist_files() ## SAFETY CHECK: if the distribution unpacking didn't avoid ## stepping on CVS module, then we have a problem for module_name in self.depends.checkout_list("name"): if module_name in dist_module_name_list: e = err.Error() e.Set("The directory created by the distribution "\ "module=\"%s\" is the same as the directory specified "\ "by a CVS module in the bif file." % (module_name)) raise err.error, e if not self.settings.get("no_cvs_checkout_flag"): self.checkout_files() def remove_modules(self): outmsg.send('examining modules') remove_module_dir_list = self.depends.list('path') # build a list of directories to remove # making sure that they are only the ones # we need to remove conflict_directory_list = [] for directory in os.listdir(os.curdir): if remove_module_dir_list.count(directory): conflict_directory_list.append(directory) continue if directory == self.settings.get('copy_path'): conflict_directory_list.append(directory) continue # return now if there are no conflicts if len(conflict_directory_list) == 0: return # remove the directories without prompting # if yes_mode_flag is set if self.settings.get('yes_mode_flag'): reply = "y" else: outmsg.send('existing modules:') for directory in conflict_directory_list: outmsg.send(" %s" % directory) while 1: reply = string.lower(raw_input('remove modules [y/n]: ')) if len(reply) > 0 and string.lower(reply[0]) == 'y' \ or string.lower(reply[0]) == 'n': reply = reply[0] break if reply == 'y': for directory in conflict_directory_list: outmsg.send('removing %s' % (directory)) try: shell.rm(directory) except: print "Failed to remove module %s, build cannot continue." % (directory) sys.exit(1) def get_dist_files(self): if self.settings.get('clobber_mode_flag'): self.remove_modules() module_list = [] ## if we're not in update mode or clobber mode, only ## get the distribution modules we don't already have if self.settings.get('update_mode_flag') or \ self.settings.get('clobber_mode_flag'): module_list = self.depends.distribution_list() else: for module in self.depends.distribution_list(): if not os.path.exists(module.name): module_list.append(module) if len(module_list) == 0: return [] outmsg.send('downloading distribution binaries') new_directory_list = self.get_distribution_list( module_list, self.default_cvs_tag, self.default_cvs_date) return new_directory_list def get_archive(self, module): ## we don't know what modules might be lurking ## in a single archive so we take a snapshot
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -