📄 umake.py
字号:
self.command_list = [self.rm, self.rmdir, self.make_dep, self.make_lib, self.make_toc, self.copy, self.make] def form_var(self, var_name): return '%s%s%s' % (self.var_begin, var_name, self.var_end)class Project: """This is where project specific information is stored. This information should only apply to the current project being build. For example: the list of source files (sources) is always specific to a given project. Build choices is a list of strings that enables the user of umake to parameterize a given umake file. For example: if you sometimes want to build with purify, you could call umake with -t "purify" and then put in a ton of if statements to setup compilers and such when build_choices.count('purify') > 0.""" def __init__(self): self.pre_target_buff = [] self.post_target_buff = [] self.current_buffer = 'pre_target_buff' self.__target_name = "" self.__output_name = "" self.__drm_sign = 0 self.target_name = "" self.dll_type = "plugin" self.target_type = "" ## Last modified cf file self.cf_last_modified = 0 ## UPP file mtime (zero if upp file was regenerated) self.upp_last_modified = 0 ## When creating a dll, this is the name of the lib file that goes with it self.opt_target_name=None ## output_dir is the base subdirectory for built targets ## within a module self.output_dir = "" ## object_dir is the directory to put object files in within ## a module self.object_dir = "" ## src_root_path is the path of the directories where all ## the modules are checked out to self.src_root_path = "ERROR ERROR" self.module_depth = 1 ## target_dir is the path targets are copied to in "make copy" self.target_dir = "" ## project_dir is the path to the directory the project was ## launched, as far as I can tell --JMP self.project_dir = "" self.module_dir = "" ## copy_target_list is a list of files to be placed in the "make copy" ## section of the Makefile to be copied to the target_dir self.copy_target_list = [] ## ## Extra copy commands self.debug_copies = [] self.makefile_path = "" self.postbuildmake = "" self.sources = [] self.objects = [] self.objsrcs = [] self.includes = [] self.defines = [] self.system_paths = [] self.exported_func = [] self.exported_function_protos = {} ## static libraries self.libraries = [] self.libraries2 = [] self.module_libs = [] self.local_libs = [] ## dynamic libraries self.dynamic_libraries = [] self.sys_libraries = [] self.sys_frameworks = [] ## dll versioning on/off self.versioning_off = 0 self.build_choices = ["default"] self.makefile_name = "Makefile" self.umakefile_name = "Umakefil" ## with resource self.with_resource_flag = 0 self.resource_target = '' self.resourcefile = '' self.resourceincludes = '' ## Extra targets self.xtargets = [] self.alldepends = '' self.submakes = [] ## the preferences hash is a really wacky/bad way of ## setting panel preferences in CW self.preferences = {} ## weak_link_list are a set of system libraries which ## need weak symbol resolution self.weak_link_list = [] ## prefix_file_include_list should only be used from the .cf ## files to add a list of includes to the prefix file self.prefix_file_include_list = [] ## FIXME: description self.distribute_location=None ## These are features which are off ## by default. You can turn them on by calling ## project.SetBuildVersion ## (or project.SetBuild2002Version) self.features = { "submodules" : 0, "versioning_off" : 0, "static_implies_nodll" : 0, "makefile_quotes" : 0, } ## Extra makefile dependencies self.file_dependencies = {} def EnableFeature(self, feature): if not self.features.has_key(feature): umake_lib.fatal("Feature '%s' not supported." % feature) if feature == "versioning_off": self.versioning_off = 2 ## magic self.features[feature]=1 def DisableFeature(self, feature): if not self.features.has_key(feature): umake_lib.fatal("Feature '%s' not supported." % feature) if feature == "versioning_off": if self.versioning_off == 2: ## magic? self.versioning_off = 0 self.features[feature]=0 def FeatureIsEnabled(self, feature): return self.features.get(feature,0) def SetBuildVersion(self,t): if t < 20020822: return self.features["submodules"]=1 def SetBuild2002Version(self,t): if t < 20020620: return self.features["submodules"]=1 def writeln(self, buff): if not stringp(buff): umake_lib.fatal("project.writeln(): invalid argument type") self.__dict__[self.current_buffer].append(buff+"\n") def write(self, str): if not stringp(buff): umake_lib.fatal("project.write(): invalid argument type") self.__dict__[self.current_buffer].append(buff) ## For backwards compatibility ONLY!! def append_script(self, script): for l in script.script_list: self.writeln(l) ## Fixme, this should generate the makefile and return it def get_buffer(self): return string.join(self.__dict__[self.current_buffer],'') def clear_buffer(self): self.post_target_buff = "" self.pre_target_buff = "" def SetModuleDepth(self, depth): print "UMAKE: Warning, project.SetModuleDepth is not required anymore and will soon dissappear!!!" def AddCommonDefines(self, cdefines): for define in string.split(cdefines): self.AddDefines(define) def AddCommonLibraries(self, clibraries): for library in string.split(clibraries): self.AddModuleLibraries(library) def AddCommonIncludes(self, cincludes): for include in string.split(cincludes): self.AddIncludes(include) def AddCommonSources(self, csources): for source in string.split(csources): self.AddSources(source) def TargetName(self): return self.__target_name def SetTargetName(self, target_name): self.current_buffer = 'post_target_buff' self.__target_name = target_name self.target_name = target_name def SetFakeTargetName(self, target_name): self.current_buffer = 'post_target_buff' self.target_name = target_name def SetTargetType(self, target_type): self.current_buffer = 'post_target_buff' if target_type not in ["dll", "exe", "lib"]: umake_lib.fatal("invalid target type=\"%s\"" % (target_type)) self.target_type = target_type def OutputName(self): return self.__output_name def SetOutputName(self, output_name): self.__output_name = output_name def SetTargetDirectory(self, target_dir): self.target_dir = target_dir def DRMSign(self): self.__drm_sign = 1 def CheckDRMSign(self): return self.__drm_sign def SetDLLTypePlugin(self): self.dll_type = 'plugin' def SetDLLTypeCodec(self): self.dll_type = 'codec' def SetDLLTypeCommon(self): self.dll_type = 'common' def AddBuildChoice(self, choice): self.AddBuildOption(choice) def RemoveBuildChoice(self, choice): self.RemoveBuildOption(choice) def AddBuildOption(self, choice): if not project.build_choices.count(choice): project.build_choices.append(choice) def RemoveBuildOption(self, choice): while project.build_choices.count(choice): project.build_choices.remove(choice) def BuildOption(self, option): if option in self.build_choices: return 1 if option == "nodll": if self.FeatureIsEnabled("static_implies_nodll"): if ( "static" in self.build_choices or "static_only" in self.build_choices ): return 1 return 0 def AddSources(self, *args): self.sources.extend(umake_lib.listify(args)) def AddModuleSources(self, *args): for source in umake_lib.listify(args): self.sources.append( apply(os.path.join, [ self.src_root_path ] + string.split(source,"/"))) def RemoveSources(self, *args): self.sources = rmlist(self.sources, umake_lib.listify(args)) def AddSourceObjects(self, *args): self.objsrcs = self.objsrcs + umake_lib.listify(args) def RemoveSourceObjects(self, *args): self.objsrcs = rmlist(self.objsrcs, umake_lib.listify(args)) def AddIncludes(self, *args): self.includes = self.includes + umake_lib.listify(args) def RemoveIncludes(self, *args): self.includes = rmlist(self.includes, umake_lib.listify(args)) def AddModuleIncludes(self, *args): for dir in umake_lib.listify(args): dir = apply(os.path.join, [ self.src_root_path ] + string.split(dir,"/")) self.AddIncludes(dir) def RemoveModuleIncludes(self, *args): for dir in umake_lib.listify(args): dir = apply(os.path.join, [ self.src_root_path ] + string.split(dir,"/")) self.RemoveIncludes(dir) def AddDefines(self, *args): for define in umake_lib.listify(args): define = string.strip(define) if define in self.defines: pass # umake_lib.warning("throwing out duplicate define=\"%s\"" % (define)) else: self.defines.append(define) def RemoveDefines(self, *args): tmp={} for d in umake_lib.listify(args): tmp[d]=1 defs=[] for d in self.defines: if not (tmp.get(d) or tmp.get(string.split(d,'=')[0])): defs.append(d) self.defines = defs def IsDefined(self, ppdef): if '=' not in ppdef: for d in self.defines: if string.split(d,"=")[0] == ppdef: return 1 else: if ppdef in self.defines: return 1 return 0 def AddLibraries(self, *args): self.libraries = self.libraries + umake_lib.listify(args) def RemoveLibraries(self, *args): self.libraries = rmlist(self.libraries, umake_lib.listify(args)) def AddLibraries2(self, *args): self.libraries2 = self.libraries2 + umake_lib.listify(args) def RemoveLibraries2(self, *args): self.libraries2 = rmlist(self.libraries2, umake_lib.listify(args)) def AddSystemLibraries(self, *args): self.sys_libraries = self.sys_libraries + umake_lib.listify(args) def RemoveSystemLibraries(self, *args): self.sys_libraries = rmlist(self.sys_libraries, umake_lib.listify(args)) def AddSystemFrameworks(self, *args): self.sys_frameworks = self.sys_frameworks + umake_lib.listify(args) def RemoveSystemFrameworks(self, *args): self.sys_frameworks = rmlist(self.sys_frameworks, umake_lib.listify(args)) def AddDynamicLibraries(self, *args): self.dynamic_libraries = self.dynamic_libraries + umake_lib.listify(args) def RemoveDynamicLibraries(self, *args): self.dynamic_libraries = rmlist( self.dynamic_libraries, umake_lib.listify(args)) def AddStaticSystemLibraries(self, *args): try: for l in umake_lib.listify(args): self.dynamic_libraries.append(platform.link.make_lib_static(l)) except KeyError: print "UMAKE Warning: This platform does not support project.AddStaticSystemLibraries()" return def RemoveStaticSystemLibraries(self, *args):
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -