⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 umake_lib.py

📁 linux下的一款播放器
💻 PY
📖 第 1 页 / 共 2 页
字号:
        m = module_from_file_rel(project, path)        if m:            m = string.lower(m)            #print "Checking %s => %s (%s)" % ( repr(path), repr(m), repr(done.get(m,-1)))            if not done.has_key(m):                w = modname +":" + m                if not warnings_printed.has_key(w):                    print "Warning: Missing BIF dep %s (%s %s)" % (repr(m), type, path)                    warnings_printed[w]=1    globals()["__umake_warnings_printed_cache__"]=warnings_printed# Check each path in "paths" to make sure that they come from# modules which are included in our BIF source dependency list.def CheckModuleSourceDependencies_rel(platform, project, type, paths):    # I feel nice, so we check aginainst the recursive tree of    # dependencies rather than against just the dependencies in this    # module... /Hubbe    module_directory = project.module_directory()    modname = module_from_file(module_directory)    if not modname:        return    try:        done = project.__recursive_source_dependency_check_done__    except:        done = GetModuleDependencies(project, modname).copy()        bifdeps = done.keys()        for d in bifdeps:            for n in bldreg.get("bifmodule_source_deplist",string.lower(d),[]):                n = string.lower(n)                if not done.has_key(n):                    bifdeps.append(n)                    done[n]=1        project.__recursive_source_dependency_check_done__ = done    warnings_printed = globals().get("__umake_warnings_printed_cache__",{})            for path in paths:        m = module_from_file_rel(project, path)        if m:            m = string.lower(m)            if not done.has_key(m):                w = modname +":" + m                if not warnings_printed.has_key(w):                    print "Warning: Missing BIF source dep %s (%s %s)" % (repr(m), type, path)                    warnings_printed[w]=1    globals()["__umake_warnings_printed_cache__"]=warnings_printeddef fix_library_path(platform, project, path, target_type=None):    if not target_type:        target_type = "lib"            path = string.strip(path)    m = re.match(r'([^[]+)\[([^]]+)\]', path)        if m:        lib = m.group(2)        dir = m.group(1)        dir = fix_path(dir)        ## UGLO        force_odir=0        force_common=0        if lib[:2] == "./":            force_odir=1            lib=lib[2:]        if lib[:3] == "../":            force_common=1            lib=lib[3:]        if target_type == "lib":            lname="%s%s.%s" % (platform.library_prefix,                               lib,                               platform.library_suffix)        elif target_type == "dll":            lname = platform.versioning.create_dll_name(lib)        elif target_type == "exe":            if len(platform.exe_suffix):                lname = "%s.%s" % (output_name, platform.exe_suffix)            else:                lname = lib        path = os.path.join(dir,                            project.output_dir,                            lname)        if not force_odir:            if force_common or not os.path.exists(path):                tmppath = os.path.join(dir, lname)                if os.path.exists(tmppath) or force_common:                    path = tmppath        return path        return fix_path(path)def SetupProject(platform, project):    """Tweaks a Project object after its data has been modified by Umakefil    execution.  Paths that may be in UNIX form are converted to local form,    defines from the platform.defines list are added to the project    defines, multiple defines are filtered out, and much, much more!"""    ## include the module's own public directory if it's not already    ## included from the Umakefil/*.pcf file    if "./pub" not in project.includes:        project.AddIncludes("./pub")        includes = []    for include in project.includes:        include = string.strip(include)        include = fix_path(include)        if include in includes:            pass            # warning("removing duplicate include path=\"%s\"" % (include))        else:            includes.append(include)    project.includes = includes    ## This is a *source* dependency, not a build dependency    CheckModuleSourceDependencies_rel(platform, project, "include path", includes)    ## libraries    libraries = []    for lib in project.libraries:        libraries.append( fix_library_path(platform, project, lib ) )    project.libraries = libraries    ## libraries2    ## Bizarro, this seems to be a noop -Hubbe    list = project.libraries2    libraries2 = []    for lib in list:        include = string.strip(lib)        include = fix_path(lib)        libraries2.append(lib)    project.libraries2 = libraries2    CheckModuleDependencies_rel(platform, project, "library", libraries + libraries2)    ## project.local_libs    ## Another noop    local_libs = []    for lib in project.local_libs:        include = string.strip(lib)        include = fix_path(lib)        local_libs.append(lib)    project.local_libs = local_libs        CheckModuleDependencies_rel(platform, project, "library", local_libs)    ## defines    defines = []    for define in platform.defines + project.defines:        define = string.strip(define)        if define[:2] == "-D":            define = define[2:]        if define in defines:            pass            # warning("removing duplicate define=\"%s\"" % (define))        else:            defines.append(define)    project.defines = defines                ## sources    sources = []    for source in project.sources:        source = string.strip(source)        source = fix_path(source)        if source in sources:            warning("removing duplicate source file=\"%s\"" % (source))        else:            sources.append(source)    project.sources = sources    ## This is a *source* dependency, not a build dependency    CheckModuleSourceDependencies_rel(platform, project, "source file", sources)    ## create the objects list by checking all the source files    ## to see if they exist; if they do, then change the suffix and    ## add them to project.objects; if the source file does not exist,    ## then we need to check for object files that look like they could    ## have been generated by the source files if they actually existed    ## and add them to project.srcobjs    ## must use the list copy syntax for project.sources because we're    ## going to remove the source files which do not exist from the source    ## list from within the loop    if sysinfo.host_type != "mac":        for path in project.sources[:]:            sourcefile = SourceFile(platform, path, project.object_dir)            ## link_output is a boolean flag which tells us if the output            ## from the build rule should be put on the final link line;            ## in this case, we're not interested in the source if it            ## doesn't belong in the link line            if not sourcefile.build_rule.link_output:                continue            ## if the source file is found            if os.path.isfile(sourcefile.path):                project.objects.append(sourcefile.obj_path)                continue            ## deal with missing source files            warning('missing source file="%s"' % (sourcefile.path))            if os.path.isfile(sourcefile.obj_path):                project.RemoveSources(sourcefile.path)                project.AddSourceObjects(sourcefile.obj_path)            else:                fatal('could not find object file for missing source="%s"' % (                    sourcefile.path))    ## the section below processes the libraries added in     ## project.module_libs, which are specified with a    ## single name    ##    ## for this to work, the module_lib name needs to be    ## both the name of the subdirectory(module), and for    ## the library to be a static library with the same name    ## with the platform's library suffix extention    ##    ## we generate the full paths to the libraries, and    ## generate paths to the include directories for the    ## modules    ## setup project.module_libs    module_libs = []    for lib in project.module_libs:        ## create the library name/path and add it to the project        lib = string.strip(lib)        lib = string.replace(lib,"\\","/")        libparts = string.split(lib,"/")        lib = libparts[-1]        ## Magic, normally path/to/module becomes: $src/path/to/module/$out/module.lib        ## However, path/to/module[l] becomes $src/path/to/module/$out/l.lib        m = re.match(r'([^[]+)\[([^]]+)\]', lib)        if m:            libparts[-1]=m.group(1)            lib = m.group(2)        parts = [ project.src_root_path ] + \                  libparts + \                  [ project.output_dir,                    "%s%s__%s.%s" % (platform.library_prefix,                                     lib,                                     string.join(libparts,"_"),                                     platform.library_suffix) ]        libpath = apply(os.path.join, parts)        #print "TESTING libpath=%s" % libpath        if not (os.path.exists(libpath) or os.path.islink(libpath)):            parts = [ project.src_root_path ] + \                      libparts + \                      [ project.output_dir,                        "%s%s.%s" % (platform.library_prefix,                                     lib,                                     platform.library_suffix) ]            libpath = apply(os.path.join, parts)            if not os.path.exists(libpath):                parts = [ project.src_root_path ] + \                        libparts + \                        ["%s%s.%s" % (platform.library_prefix,                                      lib,                                      platform.library_suffix) ]                tmppath = apply(os.path.join, parts)                if os.path.exists(tmppath):                    libpath = tmppath                    module_libs.append(libpath)        ## add include paths for the library        pub_path = apply(os.path.join, [project.src_root_path]+libparts+["pub"])        debug(" srcroot = %s" % (repr(project.src_root_path)))        debug(" libparts = %s" % (repr(libparts)))        debug(" libpath = %s" % (repr(libpath)))        debug("Checking pub path: %s (%d)" % (repr(pub_path), os.path.isdir(pub_path)))        if os.path.isdir(pub_path) and pub_path not in project.includes:            project.AddIncludes(pub_path)        ## XXX: skipping "pub" is a hack to work around bad configurations -JMP        if platform.inc_subdir and platform.inc_subdir != "pub":            inc_subdir_path = os.path.join(pub_path, platform.inc_subdir)            if os.path.isdir(inc_subdir_path) and \               inc_subdir_path not in project.includes:                project.AddIncludes(inc_subdir_path)                project.module_libs = module_libs    #print "checking module deps on: %s" % repr(module_libs)    CheckModuleDependencies_rel(platform, project, "module library", module_libs)    ## for a all-static target, the _STATICALLY_LINKED define is    ## required    if project.BuildOption("nodll"):        project.AddDefines("_STATICALLY_LINKED")    ## This is an ugly ugly ugly backwards-compatible hack    ## It allows for pre-build2002 umakefiles to be located    ## in subdirectories with (more or less) the old semantics.    ## -Hubbe    if project.module_depth == 1:        project.makefile_name = os.path.basename(project.makefile_name)class Targets:    """Base class of all Umake target types.  This class implements only    the most abstract parts of the target methods.  The real implementations    are in the specific platform handling code."""    def __init__(self, platform, project):        self.platform = platform        self.project = project    def ProgramTarget(self, target):        fatal("ProgramTarget unimplemented")    def ProgramWithResourceTarget(self, target, rtarget, rfile, includes):        fatal("ProgramWithResourceTarget unimplemented")    def LibraryTarget(self, libname):        fatal("LibraryTarget unimplemented")    def DLLTarget(self, target):        fatal("DLLTarget unimplemented")    def DLLWithResourceTarget(self, target, rtarget, rfile, includes):        fatal("DLLWithResourceTarget unimplemented")    def AllTarget(self, depends):        fatal("AllTarget unimplemented")    def DependTarget(self):        fatal("DependTarget unimplemented")    def CopyTarget(self, target_list):        fatal("CopyTarget unimplemented")    def EmptyTarget(self):        fatal("EmptyTargets unimplemented")def mtime(filename):    try:        ret=os.stat(filename)[stat.ST_MTIME]    except:        ret=0    return retdef declaw_name(name):    name = os.path.normpath(name)    name = string.lower(name)    name = string.replace(name,"-","_")    name = string.replace(name,"/","_")    name = string.replace(name,"\\","_")    name = string.replace(name,".mak","")    name = string.replace(name,"_makefile","")    return namedef write_file(name, data):    if os.path.isfile(name):        if open(name,"r").read() == data:            return    #print "WRITING FILE %s" % name    open(name, "w").write(data)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -