📄 umake.py
字号:
try: tmp = [] for l in umake_lib.listify(args): tmp.append(platform.link.make_lib_static(l)) except KeyError: print "UMAKE Warning: This platform does not support project.RemoveStaticSystemLibraries()" raise self.dynamic_libraries = rmlist( self.dynamic_libraries, tmp) def AddModuleLibraries(self, *args): tmp=umake_lib.listify(args) self.module_libs.extend(tmp) for lib in tmp: lib = string.strip(lib) lib = string.replace(lib,"\\","/") libparts = string.split(lib,"/") lib=libparts[-1] m = re.match(r'([^[]+)\[([^]]+)\]', lib) if m: libparts[-1]=m.group(1) lib = m.group(2) hook_file = apply(os.path.join, [self.src_root_path]+ libparts+ [lib + "_linkhook.cf"]) hook_file=umake_lib.ci_find_file(hook_file) if hook_file: print("exec_linkhook_file=\"%s\"" % (hook_file)) my_exec_file(hook_file) def RemoveModuleLibraries(self, *args): self.module_libs = rmlist(self.module_libs, umake_lib.listify(args)) def AddLocalLibraries(self, *args): self.local_libs = self.local_libs + umake_lib.listify(args) def RemoveLocalLibraries(self, *args): self.local_libs = rmlist(self.local_libs, umake_lib.listify(args)) def AddSystemPaths(self, *args): self.system_paths = self.system_paths + umake_lib.listify(args) def RemoveSystemPaths(self, *args): self.system_paths = rmlist(self.system_paths, umake_lib.listify(args)) def AddExportedFunctions(self, *args): self.exported_func = self.exported_func + umake_lib.listify(args) def ExportFunction(self, name, proto, include_path = None, include = None): self.exported_func.append(name) self.exported_function_protos[name]=[ proto, include, include_path ] def RemoveExportedFunctions(self, *args): self.exported_func = rmlist(self.exported_func, umake_lib.listify(args)) ## project.AddDebugOutput: ## This function takes an environment variable and a relative ## path as arguments. If the environment variable exists, a ## link to/alias to/copy of the output will be placed in that ## directory. Example: ## ## project.AddDebugOutput("RP_DEBUG_BASEDIR","plugins/rv/") ## ## This will copy the output into $RP_DEBUG_BASEDIR/plugins/rv/ ## Since the paths are often platform specific, this functions ## should normally only be used in pcf files. ## ## NOTA BENE: ## The last argument of this function must end with a slash ## def AddDebugOutput(self, env, rel): op=os.environ.get(env,None) if op: self.debug_copies.append( os.path.join(op, rel) ) def AddCopyTargets(self, *args): self.copy_target_list.extend(umake_lib.listify(args)) def RemoveCopyTargets(self, *args): self.copy_target_list = rmlist( self.copy_target_list, umake_lib.listify(args)) def SetPreference(self, panel, setting, value): try: temp = self.preferences[panel] except KeyError: temp = self.preferences[panel] = {} temp[setting] = value def Set(self, name, value): """Compiler-dependant settings goes here""" self.preferences[name] = value def AddWeakLinkLibrary(self, *args): self.weak_link_list = self.weak_link_list + umake_lib.listify(args) def RemoveWeakLinkLibrary(self, *args): self.weak_link_list = rmlist(self.weak_link_list, umake_lib.listify(args)) def AddPrefixFileInclude(self, *args): self.prefix_file_include_list = self.prefix_file_include_list + \ umake_lib.listify(args) def RemovePrefixFileInclude(self, *args): self.prefix_file_include_list = rmlist( self.prefix_file_include_list, umake_lib.listify(args)) def AddFileDependency(self, file, *args): if not self.file_dependencies.has_key(file): self.file_dependencies[file]=[] self.file_dependencies[file].extend(list(args)) class SubModule: def umakefile(self): return self.umf def abs_umakefile(self): return self.abs_umf def makefile(self): return self.mf def abs_makefile(self): return self.abs_mf def dependencies(self): return self.deps def AddSubModule(self, umf, mf = None, dependencies = None, ignore_errors = None): abs_umf = os.path.join(self.module_directory(), umf) if mf: abs_mf = os.path.join(self.module_directory(), mf) else: lum = self.mangle(abs_umf) abs_mf = bldreg.get("makefile",lum,None) # print "depth=%d moddir=%s abs_umf=%s LUM=%s abs_mf=%s" % ( self.module_depth, repr(self.module_directory()), repr(abs_umf), repr(lum), repr(abs_mf)) if not abs_mf: umake_lib.fatal("Failed to find %s in registry." % repr(os.path.join(os.getcwd(), umf))) if os.path.dirname(abs_mf) == self.module_directory(): mf = os.path.basename(abs_mf) else: mf = os.path.join(self.src_root_path, abs_mf) # print "depth=%d moddir=%s abs_umf=%s LUM=%s abs_mf=%s mf=%s, rp=%s" % ( self.module_depth, repr(self.module_directory()), repr(abs_umf), repr(lum), repr(abs_mf),repr(mf),self.src_root_path) ## Create the module object mod = self.SubModule() mod.umf = umf mod.mf = mf mod.abs_umf = abs_umf mod.abs_mf = abs_mf mod.deps = dependencies mod.ignore_errors = ignore_errors self.submakes.append(mod) def output_path(self): """Returns the output path and file name for this project""" output_name = self.target_name if self.target_type == "lib": output_name = "%s%s.%s" % (platform.library_prefix, output_name, platform.library_suffix) elif self.target_type == "dll": output_name = platform.versioning.create_dll_name(output_name) elif self.target_type == "exe": if len(self.platform.exe_suffix): output_name = "%s.%s" % (output_name, platform.exe_suffix) output_path = os.path.join(self.output_dir, output_name) return output_path, output_name def _module_path_parts(self): tmp = os.getcwd() r = [] if sysinfo.host_type == "mac": if tmp[-1] == ":": tmp = tmp[:-1] for a in range(0,self.module_depth): tmp, base = os.path.split(tmp) r = [ base ] + r return r def module_handle(self): r=self._module_path_parts() return string.join(r,"/") def module_directory(self): r=self._module_path_parts() if sysinfo.host_type == "mac": r = [ ":" ] + r if len(r): tmp=apply(os.path.join, r) else: tmp = "" return tmp def set_created_by(self, target, abs_make): ltarget=self.mangle(target) labs_make=string.lower(abs_make) by = bldreg.get("created_by",ltarget, labs_make) if by != labs_make: print "UMAKE Warning: %s is created by both %s and %s" % (target, by, abs_make) bldreg.set_value("created_by", ltarget, labs_make) def write_registry_info(self): """Writes some basic information about the target into the build system registry. This requires the import of bldreg.py from the build system.""" ## get the working directory module_directory = self.module_directory() abs_umake = os.path.join(module_directory, self.umakefile_name) abs_make = os.path.join(module_directory, self.makefile_name) bldreg.set_value("umakefile", self.mangle(abs_make), abs_umake ) bldreg.set_value("makefile", self.mangle(abs_umake), abs_make) ## Write dependency info if self.target_type != "lib": libs = bldreg.get("extra_dependencies",abs_make, []) for m in self.module_libs + self.sys_frameworks: ## FIXME, absolute paths may point to modules! if os.path.isabs(m): continue if m[:len(self.src_root_path)] != self.src_root_path: continue m = string.lower(m) m=m[len(self.src_root_path):] if len(m) and m[0] in [':', '/', '\\']: m=m[1:] libs.append(m) if self.target_type == "": libs.append("FROMBIF") bldreg.set_value("dependencies", self.mangle(abs_make), libs) if self.target_type != "" or \ len(self.pre_target_buff) or \ len(self.post_target_buff): # print "NOT AN ALIAS %s %d %d %s" % ( self.target_type,len(self.pre_target_buff),len(self.post_target_buff), self.makefile_name) pass else: # print "IS AN ALIAS %s %d %d %s" % ( self.target_type,len(self.pre_target_buff),len(self.post_target_buff), self.makefile_name) makefiles = [] for sumake in self.submakes: makefiles.append(sumake.abs_makefile()) bldreg.set_value("alias", self.mangle(abs_make), makefiles) previous="FROMBIF" for sumake in self.submakes: amf=sumake.abs_makefile() deps=bldreg.get("extra_dependencies",amf, []) deps.append(previous) bldreg.set_value("extra_dependencies",amf, deps) previous=amf ## Don't write anything more if this is a custom makefile without ## known targets if not (self.target_type and self.target_name): return target=self.target_name path=self.output_path()[0] ## the section "target_directory" keeps a mapping of target ID ## to the subdirectory it was built under; this allows us to ## easily check if there is a target ID collision where targets ## in two different subdirectories (modules) have the same name try: check_modue_dir = bldreg.get_value("target_directory", target) except KeyError: check_modue_dir = "" if len(check_modue_dir): if check_modue_dir != module_directory: temp = "target name=\"%s\" conflicts with directory=\"%s\"" umake_lib.warning(temp % (target, check_modue_dir)) bldreg.set_value("target_directory", target, module_directory) ## create the full target and object path target_path = os.path.join(module_directory, path) object_path = os.path.join(module_directory, self.object_dir) ## write the target/path key to the registry umake_lib.debug("[targets] %s = %s" % (target, target_path)) bldreg.set_value("targets", target, target_path) handle=self.module_handle() bldreg.set_value("handle_to_file", "%s[%s]" % (handle, target), target_path) if string.split(handle,"/")[-1] == target: bldreg.set_value("handle_to_file", target, target_path) bldreg.set_value("file_to_handle", target_path, "%s[%s]" % (handle, target)) self.set_created_by(target_path, abs_make) ## KLUGE if self.target_type == "dll": t2 = self.target_name if self.opt_target_name: t2 = self.opt_target_name t2 = "%s%s.%s" % (platform.library_prefix, t2, platform.library_suffix) t2 = os.path.join(module_directory, t2) self.set_created_by(t2, abs_make) ## write the path to the object files umake_lib.debug("[objects] %s = %s" % (target, object_path)) bldreg.set_value("objects", target, object_path) ## write exported functions if len(self.exported_func): exported_functions = string.join(self.exported_func, ",") umake_lib.debug("[export] %s = %s" % (target, exported_functions)) bldreg.set_value("export", target, exported_functions) for func in self.exported_func: if self.exported_function_protos.has_key(func): bldreg.set_value("export_protos",target+"::"+func, self.exported_function_protos[func]) else: bldreg.clear_value("export", target) ## set target type umake_lib.debug("[types] %s = %s" % (target, self.target_type)) bldreg.set_value("types", target, self.target_type) if ("distribute" in self.build_choices or \ "make_distributions" in self.build_choices ) and \ self.distribute_location: ## FIXME add path checks path = apply(os.path.join, [ project.src_root_path ] + string.split(self.distribute_location,"/")) ## FIXME: Allow specifying dbg/rel/. path=umake_lib.fix_library_path(platform, project, path, self.target_type)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -