def GetDependencies(self, configuration): '''返回依赖的项目的名称列表(构建顺序)''' result = [] # 依赖的项目名称列表 # dependencies are located directly under the root level rootNode = XmlUtils.GetRoot(self.doc) if not rootNode: return result for i in rootNode.childNodes: if i.nodeName == 'Dependencies' \ and i.getAttribute('Name') == configuration: # have found it for j in i.childNodes: if j.nodeName == 'Project': result.append(XmlUtils.ReadString(j, 'Name')) return result # if we are here, it means no match for the given configuration # return the default dependencies node = XmlUtils.FindFirstByTagName(rootNode, 'Dependencies') if node: for i in node.childNodes: if i.nodeName == 'Project': result.append(XmlUtils.ReadString(i, 'Name')) return result
def __init__(self, node=None): self.configs = {} # 构建设置,即 xml 中的 Configuration 元素 self.globalSettings = None # 全局构建设置,一个 BuildConfigCommon self.projectType = '' # 项目类型,可运行、静态库、动态库三种 if node: # load configurations self.projectType = XmlUtils.ReadString(node, 'Type') for i in node.childNodes: if i.nodeName == 'Configuration': configName = XmlUtils.ReadString(i, 'Name') self.configs[configName] = BuildConfig.BuildConfig(i) # 若此设置的项目类型为空, 赋值为项目总的类型, 以免为空 if not self.configs[configName].projectType: self.configs[configName].projectType = self.projectType elif i.nodeName == 'GlobalSettings': self.globalSettings = BuildConfig.BuildConfigCommon( i, 'GlobalSettings') else: # create new settings with default values # 默认为可运行类型项目 #self.projectType = str(Project.Project.STATIC_LIBRARY) self.projectType = str(Project.Project.EXECUTABLE) self.configs['Debug'] = BuildConfig.BuildConfig() # Create global settings if it's not been loaded or by default if not self.globalSettings: self.globalSettings = BuildConfig.BuildConfigCommon( None, 'GlobalSettings')
def __init__(self, node = None, name = '', selected = False): #FIXME: selected 参数应该强制为 False,需要设置只能由 BuildMatrix 设置 self.name = name self.mappingList = [] #保存 ConfigMappingEntry 的列表 self.isSelected = selected if node: self.name = XmlUtils.ReadString(node, 'Name') self.isSelected = XmlUtils.ReadBool(node, 'Selected') for i in node.childNodes: if i.nodeName == 'Project': projName = XmlUtils.ReadString(i, 'Name') confName = XmlUtils.ReadString(i, 'ConfigName') self.mappingList.append(ConfigMappingEntry(projName, confName))
def __init__(self, node = None): self.name = '' self.toolPath = '' self.toolOptions = '' self.toolJobs = '' self.isActive = False # added on 2011-12-10: 替代 toolPath, toolOptions, toolJobs,为了泛用 self.command = '' if node: self.name = XmlUtils.ReadString(node, 'Name') self.toolPath = XmlUtils.ReadString(node, 'ToolPath') self.toolOptions = XmlUtils.ReadString(node, 'Options') self.toolJobs = XmlUtils.ReadString(node, 'Jobs', '1') self.isActive = XmlUtils.ReadBool(node, 'Active', self.isActive) self.command = node.getAttribute('Command') if not self.command: self.command = "%s %s" % (self.toolPath, self.toolOptions)
def __init__(self, node=None): self.configs = {} # 构建设置,即 xml 中的 Configuration 元素 self.globalSettings = None # 全局构建设置,一个 BuildConfigCommon self.projectType = '' # 项目类型,可运行、静态库、动态库三种 ### 文件自动导入的设置 ### # 实际目录路径(相对) -> 项目虚拟目录路径 self.direList = [] # 通配模式, ; 相隔, ;; 表示单个分号 self.inclGlob = '*.c;*.cpp;*.cxx;*.c++;*.cc;*.h;*.hpp;*.hxx;Makefile' # 同上 self.exclGlob = '*.mod.c' # 示例 self.direList.append({ 'Enable': 1, 'Recursive': 0, 'RealPath': '.', 'VirtPath': '.' }) if node: # load configurations self.projectType = XmlUtils.ReadString(node, 'Type') for i in node.childNodes: if i.nodeName == 'Configuration': configName = XmlUtils.ReadString(i, 'Name') self.configs[configName] = BuildConfig.BuildConfig(i) # 若此设置的项目类型为空, 赋值为项目总的类型, 以免为空 if not self.configs[configName].projectType: self.configs[configName].projectType = self.projectType elif i.nodeName == 'GlobalSettings': self.globalSettings = BuildConfig.BuildConfigCommon( i, 'GlobalSettings') elif i.nodeName == 'FileImportGlob': self.inclGlob = XmlUtils.ReadString(i, 'IncludeGlob') self.exclGlob = XmlUtils.ReadString(i, 'ExcludeGlob') del self.direList[:] for j in i.childNodes: if j.nodeName == 'Directory': d = {} d['Enable'] = int(XmlUtils.ReadBool(j, 'Enable')) d['Recursive'] = int( XmlUtils.ReadBool(j, 'Recursive')) d['RealPath'] = XmlUtils.ReadString(j, 'RealPath') d['VirtPath'] = XmlUtils.ReadString(j, 'VirtPath') self.direList.append(d) else: # create new settings with default values # 默认为可运行类型项目 #self.projectType = str(Project.Project.STATIC_LIBRARY) self.projectType = str(Project.Project.EXECUTABLE) self.configs['Debug'] = BuildConfig.BuildConfig() # Create global settings if it's not been loaded or by default if not self.globalSettings: self.globalSettings = BuildConfig.BuildConfigCommon( None, 'GlobalSettings')
def __init__(self, xmlNode = None, confType = 'Configuration'): '''字符串类型的变量都是以分号分割的字符串''' self.includePath = '' # 分号分割的字符串 self.compileOptions = '' # 这是 C++ 的编译选项 self.linkOptions = '' self.libs = '' # 分号分割的字符串 self.libPath = '' # 分号分割的字符 self.preprocessor = '' # 分号分割的字符 self.resCompileOptions = '' self.resCompileIncludePath = '' self.cCompileOptions = '' self.confType = confType # xml node name # added on 2012-10-06 self.cCxxCmplOpts = '' # 同时用于 C 和 C++ 的编译选项 if xmlNode: # 读取编译器设置 compilerNode = XmlUtils.FindFirstByTagName(xmlNode, 'Compiler') if compilerNode: self.compileOptions = compilerNode.getAttribute('Options')\ .encode('utf-8') self.cCompileOptions = compilerNode.getAttribute('C_Options')\ .encode('utf-8') if compilerNode.hasAttribute('C_Cpp_Options'): # 同时用于 C/C++ self.cCxxCmplOpts = compilerNode.getAttribute('C_Cpp_Options')\ .encode('utf-8') #if not self.cCompileOptions: # the attribute "C_Options" does not exist, # copy the values from the "Options" attribute # 只有这个属性不存在时才复制值, python 的实现不需要如此处理 #self.cCompileOptions = self.compileOptions li1 = [] li2 = [] for i in compilerNode.childNodes: if i.nodeName == 'IncludePath': li1.append(XmlUtils.ReadString(i, 'Value')) elif i.nodeName == 'Preprocessor': li2.append(XmlUtils.ReadString(i, 'Value')) self.includePath = Globals.JoinToSmclStr(li1) self.preprocessor = Globals.JoinToSmclStr(li2) # 读取链接器设置 linkerNode = XmlUtils.FindFirstByTagName(xmlNode, 'Linker') if linkerNode: self.linkOptions = XmlUtils.ReadString(linkerNode, 'Options') li1 = [] li2 = [] for i in linkerNode.childNodes: if i.nodeName == 'Library': li1.append(XmlUtils.ReadString(i, 'Value')) elif i.nodeName == 'LibraryPath': li2.append(XmlUtils.ReadString(i, 'Value')) self.libs = Globals.JoinToSmclStr(li1) self.libPath = Globals.JoinToSmclStr(li2) # 读取资源编译器设置 resCmpNode = XmlUtils.FindFirstByTagName(xmlNode, 'ResourceCompiler') if resCmpNode: self.resCompileOptions = XmlUtils.ReadString(resCmpNode, 'Options') li1 = [] for i in resCmpNode.childNodes: if i.nodeName == 'IncludePath': li1.append(XmlUtils.ReadString(i, 'Value')) self.resCompileIncludePath = Globals.JoinToSmclStr(li1) else: if self.includePath: self.includePath += ';.' else: self.includePath += '.' if self.libPath: self.libPath += ';.' else: self.libPath += '.'
def __init__(self, xmlNode = None): '''麻烦,直接访问变量修改''' self.commonConfig = BuildConfigCommon(xmlNode) self.name = '' self.preBuildCommands = [] self.postBuildCommands = [] self.compilerRequired = True self.linkerRequired = True self.enableCustomBuild = False self.outputFile = '' self.intermediateDirectory = '' self.command = '' self.commandArguments = '' self.workingDirectory = '' self.compilerType = '' # 虽然写着是 project type,但是每个构建设置都有自己独立的类型 self.projectType = '' self.customBuildCmd = '' self.customCleanCmd = '' self.customRebuildCmd = '' self.isResCmpNeeded = False self.debuggerType = '' self.customPostBuildRule = '' self.customPreBuildRule = '' self.customBuildWorkingDir = '' self.pauseWhenExecEnds = True self.toolName = '' self.makeGenerationCommand = '' self.singleFileBuildCommand = '' self.preprocessFileCommand = '' self.debuggerStartupCmds = '' self.debuggerPostRemoteConnectCmds = '' self.isDbgRemoteTarget = False self.dbgHostName = '' self.dbgHostPort = '' self.customTargets = {} self.debuggerPath = '' self.buildCmpWithGlobalSettings = '' self.buildLnkWithGlobalSettings = '' self.buildResWithGlobalSettings = '' self.precompiledHeader = '' self.envVarSet = '' self.dbgEnvSet = '' self.useSeparateDebugArgs = False self.debugArgs = '' # added on 2011-12-08 self.ignoredFiles = set() # 忽略的文件集合,元素为文件的工作区路径字符串 # 保存的是工作区路径的相对路径 if xmlNode: self.name = XmlUtils.ReadString(xmlNode, 'Name') self.compilerType = XmlUtils.ReadString(xmlNode, 'CompilerType') self.debuggerType = XmlUtils.ReadString(xmlNode, 'DebuggerType') self.projectType = XmlUtils.ReadString(xmlNode, 'Type') self.buildCmpWithGlobalSettings = XmlUtils.ReadString( xmlNode, 'BuildCmpWithGlobalSettings', BuildConfig.APPEND_TO_GLOBAL_SETTINGS) self.buildLnkWithGlobalSettings = XmlUtils.ReadString( xmlNode, 'BuildLnkWithGlobalSettings', BuildConfig.APPEND_TO_GLOBAL_SETTINGS) self.buildResWithGlobalSettings = XmlUtils.ReadString( xmlNode, 'BuildResWithGlobalSettings', BuildConfig.APPEND_TO_GLOBAL_SETTINGS) compileNode = XmlUtils.FindFirstByTagName(xmlNode, 'Compiler') if compileNode: self.compilerRequired = XmlUtils.ReadBool( compileNode, 'Required', True) self.precompiledHeader = XmlUtils.ReadString( compileNode, 'PreCompiledHeader') linkerNode = XmlUtils.FindFirstByTagName(xmlNode, 'Linker') if linkerNode: self.linkerRequired = XmlUtils.ReadBool(linkerNode, 'Required', True) resCmpNode = XmlUtils.FindFirstByTagName(xmlNode, 'ResourceCompiler') if resCmpNode: self.isResCmpNeeded = XmlUtils.ReadBool(resCmpNode, 'Required', True) debuggerNode = XmlUtils.FindFirstByTagName(xmlNode, 'Debugger') self.isDbgRemoteTarget = False if debuggerNode: self.isDbgRemoteTarget = XmlUtils.ReadBool(debuggerNode, 'IsRemote') self.dbgHostName = XmlUtils.ReadString(debuggerNode, 'RemoteHostName') self.dbgHostPort = XmlUtils.ReadString(debuggerNode, 'RemoteHostPort') self.debuggerPath = XmlUtils.ReadString(debuggerNode, 'DebuggerPath') for i in debuggerNode.childNodes: if i.nodeName == 'StartupCommands': self.debuggerStartupCmds = XmlUtils.GetNodeContent(i) elif i.nodeName == 'PostConnectCommands': self.debuggerPostRemoteConnectCmds = \ XmlUtils.GetNodeContent(i) # read the prebuild commands preBuildNode = XmlUtils.FindFirstByTagName(xmlNode, 'PreBuild') if preBuildNode: for i in preBuildNode.childNodes: if i.nodeName == 'Command': enabled = XmlUtils.ReadBool(i, 'Enabled') cmd = BuildCommand(XmlUtils.GetNodeContent(i), enabled) self.preBuildCommands.append(cmd) # read the postbuild commands postBuildNode = XmlUtils.FindFirstByTagName(xmlNode, 'PostBuild') if postBuildNode: for i in postBuildNode.childNodes: if i.nodeName == 'Command': enabled = XmlUtils.ReadBool(i, 'Enabled') cmd = BuildCommand(XmlUtils.GetNodeContent(i), enabled) self.postBuildCommands.append(cmd) self.envVarSet = Macros.USE_WORKSPACE_ENV_VAR_SET self.dbgEnvSet = Macros.USE_GLOBAL_SETTINGS # read the environment page envNode = XmlUtils.FindFirstByTagName(xmlNode, 'Environment') if envNode: self.envVarSet = XmlUtils.ReadString(envNode, 'EnvVarSetName') self.dbgEnvSet = XmlUtils.ReadString(envNode, 'DbgSetName') customBuildNode = XmlUtils.FindFirstByTagName(xmlNode, 'CustomBuild') if customBuildNode: self.enableCustomBuild = XmlUtils.ReadBool(customBuildNode, 'Enabled', False) for i in customBuildNode.childNodes: if i.nodeName == 'BuildCommand': self.customBuildCmd = XmlUtils.GetNodeContent(i) elif i.nodeName == 'CleanCommand': self.customCleanCmd = XmlUtils.GetNodeContent(i) elif i.nodeName == 'RebuildCommand': self.customRebuildCmd = XmlUtils.GetNodeContent(i) elif i.nodeName == 'SingleFileCommand': self.singleFileBuildCommand = XmlUtils.GetNodeContent(i) elif i.nodeName == 'PreprocessFileCommand': self.preprocessFileCommand = XmlUtils.GetNodeContent(i) elif i.nodeName == 'WorkingDirectory': self.customBuildWorkingDir = XmlUtils.GetNodeContent(i) elif i.nodeName == 'ThirdPartyToolName': self.toolName = XmlUtils.GetNodeContent(i) elif i.nodeName == 'MakefileGenerationCommand': self.makeGenerationCommand = XmlUtils.GetNodeContent(i) elif i.nodeName == 'Target': tgtName = i.getAttribute('Name').encode('utf-8') tgtCmd = XmlUtils.GetNodeContent(i) if tgtName: self.customTargets[tgtName] = tgtCmd else: self.enableCustomBuild = False # read pre and post build rules customPreBuildNode = XmlUtils.FindFirstByTagName(xmlNode, 'AdditionalRules') if customPreBuildNode: for i in customPreBuildNode.childNodes: if i.nodeName == 'CustomPreBuild': self.customPreBuildRule = XmlUtils.GetNodeContent(i) self.customPreBuildRule = self.customPreBuildRule.strip() elif i.nodeName == 'CustomPostBuild': self.customPostBuildRule = XmlUtils.GetNodeContent(i) self.customPostBuildRule = self.customPostBuildRule.strip() generalNode = XmlUtils.FindFirstByTagName(xmlNode, 'General') if generalNode: self.outputFile = XmlUtils.ReadString(generalNode, 'OutputFile') self.intermediateDirectory = XmlUtils.ReadString( generalNode, 'IntermediateDirectory', '.') self.command = XmlUtils.ReadString(generalNode, 'Command') self.commandArguments = XmlUtils.ReadString( generalNode, 'CommandArguments') self.workingDirectory = XmlUtils.ReadString( generalNode, 'WorkingDirectory') self.pauseWhenExecEnds = XmlUtils.ReadBool( generalNode, 'PauseExecWhenProcTerminates', True) self.useSeparateDebugArgs = XmlUtils.ReadBool( generalNode, 'UseSeparateDebugArgs', False) self.debugArgs = XmlUtils.ReadString( generalNode, 'DebugArguments') # <IgnoredFiles><IgnoredFile Name = "xxx/yyy.c"/></IgnoredFiles> ignoredFilesNode = XmlUtils.FindFirstByTagName( xmlNode, 'IgnoredFiles') if ignoredFilesNode: for i in ignoredFilesNode.childNodes: if i.nodeName == 'IgnoredFile': self.ignoredFiles.add(i.getAttribute('Name').encode('utf-8')) else: # create default project settings self.commonConfig.SetCCompileOptions('-g;-Wall') self.commonConfig.SetCompileOptions('-g;-Wall') self.commonConfig.SetLinkOptions('-O0') self.commonConfig.SetLibPath('.;Debug') self.name = 'Debug' self.compilerRequired = True self.linkerRequired = True self.intermediateDirectory = './Debug' self.workingDirectory = './Debug' self.projectType = Project.Project.EXECUTABLE self.enableCustomBuild = False self.customBuildCmd = '' self.customCleanCmd = '' self.isResCmpNeeded = False self.customPreBuildRule = '' self.customPostBuildRule = '' self.makeGenerationCommand = '' self.toolName = '' self.singleFileBuildCommand = '' self.preprocessFileCommand = '' self.debuggerStartupCmds = '' self.debuggerPostRemoteConnectCmds = '' self.isDbgRemoteTarget = False self.debugArgs = '' self.envVarSet = '<Use Workspace Settings>' self.dbgEnvSet = '<Use Global Settings>' # 获取第一个编译器设置作为默认,故若想修改默认编译器,修改默认配置文件 #compiler = BuildSettings.BuildSettingsST.Get()\ #.GetFirstCompiler() #if compiler: #self.compilerType = compiler.name self.compilerType = 'unknown' # TODO: DebuggerMgr 暂不支持 self.debuggerType = 'GNU gdb debugger' self.buildCmpWithGlobalSettings = BuildConfig.APPEND_TO_GLOBAL_SETTINGS self.buildLnkWithGlobalSettings = BuildConfig.APPEND_TO_GLOBAL_SETTINGS self.buildResWithGlobalSettings = BuildConfig.APPEND_TO_GLOBAL_SETTINGS