예제 #1
0
    def Create(self, name, description, path, projectType):
        self.name = name
        self.fileName = os.path.join(path,
                                     name + os.extsep + PROJECT_FILE_SUFFIX)
        self.fileName = os.path.abspath(self.fileName)
        self.dirName, self.baseName = os.path.split(self.fileName)

        self.doc = minidom.Document()
        rootNode = self.doc.createElement('CodeLite_Project')
        self.doc.appendChild(rootNode)
        rootNode.setAttribute('Name', name.decode('utf-8'))

        descNode = self.doc.createElement('Description')
        XmlUtils.SetNodeContent(descNode, description)
        rootNode.appendChild(descNode)

        # Create the default virtual directories
        srcNode = self.doc.createElement('VirtualDirectory')
        srcNode.setAttribute('Name', 'src')
        rootNode.appendChild(srcNode)
        headNode = self.doc.createElement('VirtualDirectory')
        headNode.setAttribute('Name', 'include')
        rootNode.appendChild(headNode)

        # creae dependencies node
        depNode = self.doc.createElement('Dependencies')
        rootNode.appendChild(depNode)

        self.DoSaveXmlFile()

        # create a minimalist build settings
        settings = ProjectSettings()
        settings.SetProjectType(projectType)
        self.SetSettings(settings)
        self.SetModified(True)
예제 #2
0
    def ToXmlNode(self):
        # Create the common nodes
        node = self.commonConfig.ToXmlNode()
        
        node.setAttribute('Name', self.name)
        node.setAttribute('CompilerType', self.compilerType)
        node.setAttribute('DebuggerType', self.debuggerType)
        node.setAttribute('Type', self.projectType)
        node.setAttribute('BuildCmpWithGlobalSettings', self.buildCmpWithGlobalSettings)
        node.setAttribute('BuildLnkWithGlobalSettings', self.buildLnkWithGlobalSettings)
        node.setAttribute('BuildResWithGlobalSettings', self.buildResWithGlobalSettings)
        
        compilerNode = XmlUtils.FindFirstByTagName(node, 'Compiler')
        if compilerNode:
            compilerNode.setAttribute('Required', Macros.BoolToString(self.compilerRequired))
            compilerNode.setAttribute('PreCompiledHeader', self.precompiledHeader)
        
        linkerNode = XmlUtils.FindFirstByTagName(node, 'Linker')
        if linkerNode:
            linkerNode.setAttribute('Required', Macros.BoolToString(self.linkerRequired))
        
        resCmpNode = XmlUtils.FindFirstByTagName(node, 'ResourceCompiler')
        if resCmpNode:
            resCmpNode.setAttribute('Required', Macros.BoolToString(self.isResCmpNeeded))
            
        generalNode = minidom.Document().createElement('General')
        generalNode.setAttribute('OutputFile', self.outputFile)
        generalNode.setAttribute('IntermediateDirectory', self.intermediateDirectory)
        generalNode.setAttribute('Command', self.command)
        generalNode.setAttribute('CommandArguments', self.commandArguments)
        generalNode.setAttribute('UseSeparateDebugArgs', Macros.BoolToString(self.useSeparateDebugArgs))
        generalNode.setAttribute('DebugArguments', self.debugArgs)
        generalNode.setAttribute('WorkingDirectory', self.workingDirectory)
        generalNode.setAttribute('PauseExecWhenProcTerminates', Macros.BoolToString(self.pauseWhenExecEnds))
        node.appendChild(generalNode)
        
        debuggerNode = minidom.Document().createElement('Debugger')
        debuggerNode.setAttribute('IsRemote', Macros.BoolToString(self.isDbgRemoteTarget))
        debuggerNode.setAttribute('RemoteHostName', self.dbgHostName)
        debuggerNode.setAttribute('RemoteHostPort', self.dbgHostPort)
        debuggerNode.setAttribute('DebuggerPath', self.debuggerPath)
        # node.appendChild(debuggerNode) #?
        
        envNode = minidom.Document().createElement('Environment')
        envNode.setAttribute('EnvVarSetName', self.envVarSet)
        envNode.setAttribute('DbgSetName', self.dbgEnvSet)
        node.appendChild(envNode)
        
        dbgStartupCommands = minidom.Document().createElement('StartupCommands')
        XmlUtils.SetNodeContent(dbgStartupCommands, self.debuggerStartupCmds)
        dbgPostCommands = minidom.Document().createElement('PostConnectCommands')
        XmlUtils.SetNodeContent(dbgPostCommands, self.debuggerPostRemoteConnectCmds)
        
        debuggerNode.appendChild(dbgStartupCommands)
        debuggerNode.appendChild(dbgPostCommands)
        node.appendChild(debuggerNode)
        
        dom = minidom.Document()
        # Add prebuild commands
        preBuildNode = dom.createElement('PreBuild')
        node.appendChild(preBuildNode)
        for i in self.preBuildCommands:
            commandNode = dom.createElement('Command')
            commandNode.setAttribute('Enabled', Macros.BoolToString(i.enabled))
            XmlUtils.SetNodeContent(commandNode, i.command)
            preBuildNode.appendChild(commandNode)
        
        # Add postbuild commands
        postBuildNode = dom.createElement('PostBuild')
        node.appendChild(postBuildNode)
        for i in self.postBuildCommands:
            commandNode = dom.createElement('Command')
            commandNode.setAttribute('Enabled', Macros.BoolToString(i.enabled))
            XmlUtils.SetNodeContent(commandNode, i.command)
            postBuildNode.appendChild(commandNode)
        
        # Add custom build commands
        customBuildNode = dom.createElement('CustomBuild')
        node.appendChild(customBuildNode)
        customBuildNode.setAttribute('Enabled', Macros.BoolToString(self.enableCustomBuild))
        
        # Add the working directory of the cutstom build
        customBuildWDNode = dom.createElement('WorkingDirectory')
        XmlUtils.SetNodeContent(customBuildWDNode, self.customBuildWorkingDir)
        customBuildNode.appendChild(customBuildWDNode)
        
        toolName = dom.createElement('ThirdPartyToolName')
        XmlUtils.SetNodeContent(toolName, self.toolName)
        customBuildNode.appendChild(toolName)
        
        # add the makefile generation command
        makeGenCmd = dom.createElement('MakefileGenerationCommand')
        XmlUtils.SetNodeContent(makeGenCmd, self.makeGenerationCommand)
        customBuildNode.appendChild(makeGenCmd)
        
        singleFileCmd = dom.createElement('SingleFileCommand')
        XmlUtils.SetNodeContent(singleFileCmd, self.singleFileBuildCommand)
        customBuildNode.appendChild(singleFileCmd)
        
        preprocFileCmd = dom.createElement('PreprocessFileCommand')
        XmlUtils.SetNodeContent(preprocFileCmd, self.preprocessFileCommand)
        customBuildNode.appendChild(preprocFileCmd)
        
        # add build and clean commands
        bldCmd = dom.createElement('BuildCommand')
        XmlUtils.SetNodeContent(bldCmd, self.customBuildCmd)
        customBuildNode.appendChild(bldCmd)
        
        clnCmd = dom.createElement('CleanCommand')
        XmlUtils.SetNodeContent(clnCmd, self.customCleanCmd)
        customBuildNode.appendChild(clnCmd)
        
        rebldCmd = dom.createElement('RebuildCommand')
        XmlUtils.SetNodeContent(rebldCmd, self.customRebuildCmd)
        customBuildNode.appendChild(rebldCmd)
        
        # add all 'Targets'
        for k, v in self.customTargets.items():
            customTgtNode = dom.createElement('Target')
            customTgtNode.setAttribute('Name', k)
            XmlUtils.SetNodeContent(customTgtNode, v)
            customBuildNode.appendChild(customTgtNode)
        
        # add the additional rules
        addtionalCmdsNode = dom.createElement('AdditionalRules')
        node.appendChild(addtionalCmdsNode)
        
        preCmd = dom.createElement('CustomPreBuild')
        XmlUtils.SetNodeContent(preCmd, self.customPreBuildRule)
        addtionalCmdsNode.appendChild(preCmd)
        
        postCmd = dom.createElement('CustomPostBuild')
        XmlUtils.SetNodeContent(postCmd, self.customPostBuildRule)
        addtionalCmdsNode.appendChild(postCmd)

        # add "IgnoredFiles" node
        ignoredFilesNode = dom.createElement('IgnoredFiles')
        for i in self.ignoredFiles:
            ignoredFileNode = dom.createElement('IgnoredFile')
            ignoredFileNode.setAttribute('Name', i)
            ignoredFilesNode.appendChild(ignoredFileNode)
        node.appendChild(ignoredFilesNode)
        
        return node