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

📄 umake_ascript.py

📁 linux下的一款播放器
💻 PY
📖 第 1 页 / 共 3 页
字号:
            ppc_linker["Termination Name"] = '""'        if not ppc_linker.has_key("Main Name"):            ppc_linker["Main Name"] = '"__start"'    ## if the target type is a DLL, check for a export file in the    ## listed sources    ##    ## XXX: umake should generate a .exp file from the    ##      project.exported_functions list, like it does for    ##      Windows and Unix -JMP  It now does! - CXZ    if mprj.target_type == "dll":        use_export_file = 0        for source in mprj.source_list:            if string.lower(source[-4:]) == ".exp":                use_export_file = 1                break        if use_export_file:            ppc_pef["Export Symbols"] = "expfile"    return mprjclass MacCWProjectData:    """Specialized class for holding the abstract, post-tweaked project    data for being fed to the CodeWarrior AppleScript generator."""    def __init__(self):        self.target_name = ""        self.target_type = ""                self.source_list = []        self.library_list = []        self.define_list = []        self.weak_link_list = []        self.prefix_file_include_list = []        self.preferences = {}        self.ide_path = os.environ["BUILD_SW"]        ## Access Paths: list of tuples (path, recursive, origin)        self.user_paths = []        self.system_paths = []        self.ruser_paths = []        self.rsystem_paths = []                ## flag to indicate to full search user_paths, defaults off        self.always_full_search = 0                ## project file filename/path        self.project_file = ""        self.project_file_path = ""        ## project data foldername/folder path        self.project_data = ""        self.project_data_path = ""        ## prefix file filename/path        self.prefix_file = ""        self.prefix_file_path = ""        ## resource targets        self.rtarget = ""        self.rfile = ""        ## resource project filename/path        self.rproject_file = ""        self.rproject_file_path = ""        ## resource project data foldername/folder path        self.rproject_data = ""        self.rproject_data_path = ""        ## resource prefix file filename/path        self.rprefix_file = ""        self.rprefix_file_path = ""        ## output foldername/folder path        self.output_dir = ""        self.output_dir_path = ""        ## target dir foldername/folder path        self.target_dir = ""        self.target_dir_path = ""                ## CodeWarrior target names - may be different from target names in multi-target modules        self.cwtarget_name = ""        ## arbitrary applescript run after the build        self.post_build_script = ""                self.project_dir = ""def WriteResourcePrefixFile(mprj):    """Write the prefix header file for resource projects."""    line_list = [        "/* Resource Prefix File Generated by Umake */",        "#include <types.r>",        "#define _MACINTOSH",        ]    data=string.join(line_list,"\n") + "\n"    umake_lib.write_file(mprj.rprefix_file_path, data)    fsspec = macfs.FSSpec(mprj.rprefix_file_path)    fsspec.SetCreatorType('CWIE', 'TEXT')def WritePrefixFile(mprj):    """Write the prefix header file for projects.  Prefix files on the    Macintosh are, by default, always included in every source file before    any other header file.  Therefore, it is a useful place to set up    #defines, since the Mac doesn't support doing them any other way."""    line_list = [        "/* Prefix File Generated by Umake */",        ]    ## get all the defines into one list    line_list.append("/* begin defines */")    for define in mprj.define_list:        index = string.find(define, '=')        ## define without value, just set to true        if index == -1:            line_list.append("#define %s 1" % (define))            continue        ## define with value        key = string.strip(define[:index])        value = string.strip(define[index+1:])        line_list.append('#define %s %s' % (key, value))    line_list.append("/* end defines */")    ## PPC vs. 68k, very legacy...    line_list = line_list + [        "#ifdef __POWERPC__",        "        #define _MACPPC 1",        "#else",        "        #define _MAC68K 1",        "#endif /* __POWERPC__ */",        ]    ## included in everything    for include in mprj.prefix_file_include_list:        line_list.append("#include <%s>" % (include))    ## write the file and set creator/type    data=string.join(line_list,"\n") + "\n"    umake_lib.write_file(mprj.prefix_file_path, data)    fsspec = macfs.FSSpec(mprj.prefix_file_path)    fsspec.SetCreatorType('CWIE', 'TEXT')class CWAccessPath:    """Stores all the information for setting the Access Paths panel in    CodeWarrior.  CodeWarrior projects don't differentiate between include    paths and library search paths, so we put them all in here.  Also,    each path has to be specified if it is to be searched recursivly,    and where the path origin should be: project relative, or shell (compiler)    relative, or a system framework path"""    def __init__(self):        self.system_paths = []        self.user_paths = []        self.settings = {}    def in_paths_list(self, paths_list, path, recursive, origin):        p1 = (path, recursive, origin)        for p2 in paths_list:            if p1 == p2:                return 1        return 0    def add_path(self, list, path, recursive, origin):        recursive = string.lower(recursive)        if recursive not in ["true", "false"]:            umake_lib.fatal(                'CWAccessPath: recursive must be "true" or "false"')        origin = string.lower(origin)        if origin not in ["project relative", "shell relative"]:            umake_lib.fatal(                'CWAccessPath: origin must be "project relative" or '\                '"shell relative"')        list.append( (path, recursive, origin) )    def AddSetting(self, key, value):        self.settings[key] = value    def AddSystemPath(self, path, recursive, origin):        if not self.in_paths_list(self.system_paths, path, recursive, origin):            self.add_path(self.system_paths, path, recursive, origin)    def AddUserPath(self, path, recursive, origin):        if not self.in_paths_list(self.user_paths, path, recursive, origin):            self.add_path(self.user_paths, path, recursive, origin)    def String(self):        def cw_path(p, r, o):            return '{name:"%s",recursive:%s,origin:%s}' % (p,r,o)        lst = []                sys_list = []        for (path, recursive, origin) in self.system_paths:            sys_list.append(cw_path(path, recursive, origin))        lst.append("System Paths:{%s}" % (string.join(sys_list, ",")))        user_list = []        for (path, recursive, origin) in self.user_paths:            user_list.append(cw_path(path, recursive, origin))        lst.append("User Paths:{%s}" % (string.join(user_list, ",")))        for (key, value) in self.settings.items():            lst.append("%s:%s" % (key, value))        return "{%s}" % (string.join(lst, ","))        def WriteExportFile(mprj):    ## write the file and set creator/type    if len(mprj.export_file):        fil = open(mprj.export_file, 'w')        for exported_func in mprj.export_list:            fil.write("%s\n" % (exported_func))        fil.close()        fsspec = macfs.FSSpec(mprj.export_file)        fsspec.SetCreatorType('CWIE', 'TEXT')class ASMakefile:    def __init__(self, mprj):        self.mprj = mprj        ## start the script and define subroutines        script = ascript.CreateAppleScript()        self.script = script        all =  []        self.all = all        for sumake in mprj.project.submakes:            m_path = macpath.normpath(macpath.join(os.getcwd(), sumake.makefile()))            all.extend( [                'set scriptobj to (load script file "%s")' % (m_path),                'tell scriptobj',                '  set myerrors to myerrors & return & all()',                'end tell' ] )        script.Extend(mprj.project.pre_target_buff)        self.Clean()        if mprj.project.target_type != "":            WritePrefixFile(mprj)            WriteResourcePrefixFile(mprj)                WriteExportFile(mprj)            self.VerifyPath()            self.ExtractCWErrors()                if len(mprj.weak_link_list):                self.SetWeakLink()            if len(mprj.post_build_script):                self.PostBuildScript()            if mprj.rtarget:                self.DefineResourceProject()            ## FIXME, only do this for if asked to 'clean' build            all.extend( [                '  --clean out old project and data by default',                '  Clean()' ])            ## write the "all" function, like "make all" in a Makefile            all.extend( [                '  --make the output directory, and target directory',                '  verifypath("%s")' % (mprj.output_dir_path),                '  verifypath("%s")' % (mprj.target_dir_path) ] )            if mprj.rtarget:                all.extend( [                    '--build the windows resource dll',                    'myerrors = myerrors & return & ResourceProject()' ] )            self.RunProject()            ## for DLL target types, we make a alias to the dll with a .lib            ## extention so developers can do implicit linking to DLL's the            ## same way they do on Windows            ##            ## Note: when Windows compiles a DLL, it creates a companion .LIB            ##       library with the same name; you link to the DLL by linking            ##       in the stub .LIB            absolute_output_dir = os.path.join(os.getcwd(), mprj.output_dir)            absolute_output_path = os.path.join(absolute_output_dir, mprj.output_name)            if mprj.target_type == "dll":                if mprj.project.opt_target_name:                    alias_name= mprj.project.opt_target_name                else:                    alias_name= mprj.target_name                alias_name = "%s.LIB" % (string.upper(alias_name))                absolute_alias_path = os.path.join(absolute_output_dir, alias_name)                all.extend( [                    'tell application "Finder"',                    '  try',                    '    if (file "%s") exists then' % (absolute_alias_path),                    '    else',                    '      make new alias file to (file "%s") at (folder "%s") '\                    '       with properties {name:"%s"}' % (                            absolute_output_path, absolute_output_dir, alias_name),                    '    end if',                    '   on error',                    '  end try',                    'end tell' ])            if len(mprj.post_build_script):                all.extend( [                    '--execute the custom subroutine',                    'DoPostBuild()' ])            ## copy the built target and finish off the script            all.extend( [                '-- Copy results to common output folder',                'tell application "Finder"',                '  if (file "%s") exists then' % (absolute_output_path),                '      Duplicate file "%s" to folder "%s" with replacing' % (                    absolute_output_path, mprj.target_dir_path),                '  end if',                'end tell' ])        if len(all):            script.Append('on all()',                          'set myerrors to ""')

⌨️ 快捷键说明

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