def GetDescription(self): rootNode = XmlUtils.GetRoot(self.doc) if rootNode: node = XmlUtils.FindFirstByTagName(rootNode, 'Description') if node: return XmlUtils.GetNodeContent(node) return ''
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