예제 #1
0
    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 += '.'
예제 #2
0
 def SetResCmpIncludePath(self, paths):
     if type(paths) == type([]):
         self.resCompileIncludePath = Globals.JoinToSmclStr(paths)
     else:
         self.resCompileIncludePath = paths
예제 #3
0
 def SetLibPath(self, paths):
     if type(paths) == type([]):
         self.libPath == Globals.JoinToSmclStr(paths)
     else:
         self.libPath = paths
예제 #4
0
 def SetLibraries(self, libs):
     if type(libs) == type([]):
         self.libs = Globals.JoinToSmclStr(libs)
     else:
         self.libs = libs
예제 #5
0
 def SetIncludePath(self, paths):
     if type(paths) == type([]):
         self.includePath = Globals.JoinToSmclStr(paths)
     else:
         self.includePath = paths
예제 #6
0
 def SetPreprocessor(self, prepr):
     if type(prepr) == type([]):
         self.preprocessor = Globals.JoinToSmclStr(prepr)
     else:
         self.preprocessor = prepr