📄 umake_win_vc7_makefile.py
字号:
if opt == "Zi": self.toolopts["DebugInformationFormat"]="3" return if opt == "ZI": self.toolopts["DebugInformationFormat"]="4" return if opt == "Zp": self.toolopts["StructMemberAlignment"]=arg return if opt in [ "Zm" ]: self.xopts.append("/%s%s " % (opt, arg)) return return self.SimpleCompilerOption(opt, arg) def ResourceOption(self, opt, arg): if opt == "l": self.toolopts["Culture"]=string.atoi(arg,0) return return self.SimpleCompilerOption(opt, arg) def MidlOption(self, opt, arg): if opt == "O": if arg in ["icf","if"]: self.toolopts["GenerateStublessProxies"]="TRUE" return return self.ResourceOption(opt, arg) def LinkerOption(self, opt, arg): if opt == "": if arg == "$(LINKER_OPTIONS)": return self.xdeps.append(arg) return if opt == "out": self.toolopts["OutputFile"]=arg return if opt == "base": self.toolopts["BaseAddress"]=arg return if opt == "implib": self.toolopts["ImportLibrary"]=arg return if opt == "subsystem": if string.lower(arg) == "console": self.toolopts["SubSystem"]=1 return if string.lower(arg) == "windows": self.toolopts["SubSystem"]=2 return if opt == "machine": if string.lower(arg) in ["x86","i386"]: self.toolopts["TargetMachine"]=1 return if opt == "nodefaultlib": self.nodefaultlibs.extend(string.split(arg,",")) return if opt in [ "dll", "lib" ]: return if opt == "pdb": if arg == "none": return self.toolopts["ProgramDatabaseFile"]=arg return if opt == "def": self.toolopts["ModuleDefinitionFile"]=arg return if opt == "debug": self.toolopts["GenerateDebugInformation"]="TRUE" return if opt == "incremental": self.toolopts["LinkIncremental"]=1 return if opt == "incremental:no": self.toolopts["LinkIncremental"]=0 return if opt == "libpath": if self.toolopts.has_key("ReferencePath"): arg=self.toolopts["ReferencePath"]+";"+arg self.toolopts["ReferencePath"]=arg return if opt == "map": self.toolopts["GenerateMapFile"]=1 if arg: self.toolopts["MapFileName"]=arg return if opt == "align": self.xopts.append("/%s:%s " % (opt, arg)) return return self.Option(opt,arg) def parse_options(self, name, flags, func, argstring, defopts=None, case_insensetive = None): self.toolopts = defopts or {} self.toolopts["Name"]=name self.xopts=[] self.includes=[] self.forced_includes=[] self.defines=[] self.nodefaultlibs=[] self.xdeps=[] ProcessOptions( makefile.expand_variables("$(%s)"%flags, self.variables), func, argstring, case_insensetive) self.toolopts["ForcedIncludeFiles"]=string.join(self.forced_includes,",") self.toolopts["AdditionalOptions"]=string.join(self.xopts) self.toolopts["AdditionalIncludeDirectories"]=string.join(self.includes,",") self.toolopts["PreprocessorDefinitions"]=string.join(self.defines,",") self.toolopts["IgnoreDefaultLibraryNames"]=string.join(self.nodefaultlibs,";") self.toolopts["AdditionalDependencies"]=string.join(self.xdeps," ") return self.toolopts def generate_xml(self, project): self.cc_toolopts=self.parse_options("VCCLCompilerTool", "ALL_CC_FLAGS", self.CompilerOption, "D=I=Zm=Zp=FI=W=O=M=G=Y=F=wd=Fd=", defopts={"Optimization":"0" }) self.rc_toolopts=self.parse_options("VCResourceCompilerTool", "RCFLAGS", self.ResourceOption,"D=d=I=i=l=") self.midl_toolopts=self.parse_options("VCMIDLTool", "MTLFLAGS", self.MidlOption,"D=d=I=i=l=O=") l="out:base:implib:subsystem:nodefaultlib:pdb:machine:def:libpath:map;align:" self.linker_toolopts=self.parse_options("VCLinkerTool", "LINKER_OPTIONS", self.LinkerOption, l,None, 1) if self.target_type == "exe": conftype = 1 elif self.target_type == "dll": conftype = 2 elif self.target_type == "lib": conftype = 4 else: conftype = 0 if conftype != 0: tools = [ xml("Tool", self.cc_toolopts), xml("Tool", { "Name":"VCCustomBuildTool", }), xml("Tool", self.linker_toolopts), xml("Tool", self.midl_toolopts ), xml("Tool", { "Name":"VCPostBuildEventTool", "Description":"Copying...", "CommandLine":string.join(self.post_build_cmds,"\n")}), xml("Tool", { "Name":"VCPreBuildEventTool", }), xml("Tool", { "Name":"VCPreLinkEventTool", }), xml("Tool", self.rc_toolopts), xml("Tool", { "Name":"VCWebServiceProxyGeneratorTool", }), xml("Tool", { "Name":"VCXMLDataGeneratorTool", }), xml("Tool", { "Name":"VCWebDeploymentTool", }), xml("Tool", { "Name":"VCManagedWrapeprGeneratorTool", }), xml("Tool", { "Name":"VCAuxiliaryManagedWrapperGeneratorTool", }), # xml("Tool", # { "Name":""SupercalifragilisticexpalidociusTool", }), ] else: tools= [ xml("Tool", { "Name":"VCNMakeTool", "BuildCommandLine": "nmake.exe /NOLOGO /f %s all copy" % project.makefile_name, "ReBuildCommandLine": "nmake.exe /NOLOGO /f %s /a all copy" % project.makefile_name, "CleanCommandLine": "nmake.exe /NOLOGO /f %s clean" % project.makefile_name, "Output":self.variables["OUTFILE"] }), ] return xml("Configuration", { "Name": self.type, "OutputDirectory":self.variables["OUTDIR"], "IntermediateDirectory":self.variables["OBJDIR"], "ConfigurationType":conftype }, tools) class Project(Project): """Class representing and generating one MSDEV project""" def generate_xml(self): guid = make_guid(self.name) config_xml=[] for c in self.configurations: config_xml.append(c.generate_xml(self)) file_xml=[] resource_xml=[] for sourcefile in self.sourcefiles: if sourcefile.build_rule.source_suffix in [ ".rc",".mc" ] \ or c.target_type not in ["exe","dll","lib"]: resource_xml.append(xml("File",{"RelativePath":sourcefile.path})) else: file_xml.append(xml("File", {"RelativePath":sourcefile.path}, [xml("FileConfiguration", {"Name":"Build|Win32"}, [xml("Tool", {"Name":"VCCLCompilerTool", "ObjectFile":sourcefile.obj_path})])])) header_xml=[] for source in self.headerfiles: header_xml.append(xml("File",{"RelativePath":source})) return xml("VisualStudioProject", { "ProjectType":"Visual C++", "Version":"7.10", "Name":self.name, "ProjectGUID":guid, "Keyword":"MakeFileProj", }, [ xml("Platforms", None, [ xml("Platform",{ "Name":"Win32" } ) ] ), xml("Configurations", {}, config_xml), xml("Files", {}, [ xml("Filter", { "Name":"Source Files", "Filter":"cpp;c;cxx;def;odl;idl;hpj;bat;asm" }, file_xml), xml("Filter", { "Name":"Header Files", "Filter":"h;hpp;hxx;hm;inl;inc", }, header_xml), xml("Filter", { "Name":"Resource Files", "Filter":"rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe", }, resource_xml) ]), xml("Globals",{},[]), ]) def generate(self): text = [ ] text.append('<?xml version="1.0" encoding = "Windows-1252"?>\n') text.extend(self.generate_xml().generate()) text=string.join(text,"") text=string.replace(text,"$(MODULE)",self.name) return text;class Workspace(Workspace): """Class representing and generating one MSDEV solution""" def generate(self): text = [] text.append('Microsoft Visual Studio Solution File, Format Version 8.00') self.text=text self.done={} self.project_byname={} for (name, path) in self.projects: self.project_byname[name]=path for (name, path) in self.projects: self.generate_project(name) text.append('Global') text.append('\tGlobalSection(SolutionConfiguration) = preSolution') text.append('\t\tBuild = Build') text.append('\tEndGlobalSection') text.append('\tGlobalSection(ProjectConfiguration) = postSolution') for (name, path) in self.projects: guid = make_guid(name) text.append('\t\t%s.Build.ActiveCfg = Build|Win32' % (guid)) text.append('\t\t%s.Build.Build.0 = Build|Win32' % (guid)) text.append('\tEndGlobalSection') text.append('\tGlobalSection(ExtensibilityGlobals) = postSolution') text.append('\tEndGlobalSection') text.append('\tGlobalSection(ExtensibilityAddIns) = postSolution') text.append('\tEndGlobalSection') text.append('EndGlobal') return string.join(self.text,"\n") def generate_project(self, name): if self.done.has_key(name): return self.done[name]=1 if not self.project_byname.has_key(name): return path = self.project_byname[name] for d in self.dependencies.get(name,[]): self.generate_project(d) text=self.text guid = make_guid(name) text.append('Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "%s", "%s", "%s"' % (name, path, guid)) text.append('\tProjectSection(ProjectDependencies) = postProject') for d in self.dependencies.get(name,[]): depguid = make_guid(d) text.append('\t\t%s = %s\n' % (depguid, depguid)) text.append('\tEndProjectSection') text.append('EndProject')class project_generator(project_generator): """Class which generates a VCPROJ file from the data in in the platform and project classes""" def add_configurations(self): self.do_config("Build|Win32")
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -