def make(self, projectConfig):
        makeConf = {
            'target_type': projectConfig.getItem('make.configuration.target.type', self.defaultConf['target_type']),
            'cc': projectConfig.getItem('make.configuration.compiler.c.cc', self.defaultConf['cc']),
            'cxxc': projectConfig.getItem('make.configuration.compiler.cpp.cc', self.defaultConf['cxxc']),
            'cflags': projectConfig.getItem('make.configuration.compiler.c.flags', self.defaultConf['cflags']),
            'cxxflags': projectConfig.getItem('make.configuration.compiler.cpp.flags', self.defaultConf['cxxflags']),
            'fpic': projectConfig.getItem('make.configuration.compiler.fpic', self.defaultConf['fpic']),
            'autolink': projectConfig.getItem('make.configuration.linker.autolink', self.defaultConf['autolink']),
            'ar': projectConfig.getItem('make.configuration.archiver.ar', self.defaultConf['ar']),
            'ld': projectConfig.getItem('make.configuration.linker.ld', self.defaultConf['ld']),
            'ldflags': projectConfig.getItem('make.configuration.linker.flags', self.defaultConf['ldflags']),
            'ld_library_paths': projectConfig.getItem('make.configuration.linker.library_paths', self.defaultConf['ld_library_paths']),
            'libraries': projectConfig.getItem('make.configuration.linker.libraries', []),
            'c_src_exts': projectConfig.getItem('make.configuration.compiler.c.src_exts', self.defaultConf['c_src_exts']),
            'cxx_src_exts': projectConfig.getItem('make.configuration.compiler.cpp.src_exts', self.defaultConf['cxx_src_exts']),
            'c_include_paths': projectConfig.getItem('make.configuration.compiler.c.include_paths', self.defaultConf['c_include_paths']),
            'cxx_include_paths': projectConfig.getItem('make.configuration.compiler.cpp.include_paths', self.defaultConf['cxx_include_paths']),
            'cxx_using_c_include_paths': projectConfig.getItem('make.configuration.compiler.cpp.inherit_c_include_path', self.defaultConf['cxx_using_c_include_paths'])
        }

        makefile = GMakeDocument(TARGET_MAKEFILE_PATH)

        self.mainSourceFiles.clear()
        self.objectFiles.clear()
        cSourceFiles = []
        cppSourceFiles = []
        FileUtil.searchAllFiles(cSourceFiles, SRC_MAIN_PATH, makeConf['c_src_exts'])
        FileUtil.searchAllFiles(cppSourceFiles, SRC_MAIN_PATH, makeConf['cxx_src_exts'])
        self.mainSourceFiles.extend(cSourceFiles)
        self.mainSourceFiles.extend(cppSourceFiles)

        for fileName in self.mainSourceFiles:
            filePath = Path(fileName, True)
            relPath = filePath.getRelevantPath(SRC_MAIN_PATH)
            dirName = relPath.getDirName()
            baseName = relPath.getBaseName()

            subMakeDirPath = TARGET_SUBMAKE_MAIN_PATH.join(dirName)
            FileUtil.createDirectory(subMakeDirPath)

            subMakefilePath = subMakeDirPath.join(PathUtil.getPrefix(baseName))
            subMakefilePath.appendExt('mk')
            subMakefile = GMakeDocument(subMakefilePath)

            compileRule = GCCCompileRule(filePath, [INCLUDE_MAIN_PATH], SRC_MAIN_PATH, TARGET_OBJECT_MAIN_PATH, makeConf)
            subMakefile.addRule(compileRule)
            makefile.addSubDocument(subMakefile)

            objectFilePath = Path(compileRule.getTarget())
            self.objectFiles.append(objectFilePath)

        if makeConf['autolink']:
            if makeConf['target_type'] == 'executable':
                subMakefile = GMakeDocument(FINAL_TARGET_SUBMAKE_PATH)
                
                finalFileName = '%(name)s-%(version)s' % { 
                        'name': projectConfig.getItem('project.name', 'noname'),
                        'version': projectConfig.getItem('project.version', '1.0.0')}
                finalFilePath = TARGET_PATH.join(finalFileName)

                linkRule = GCCLinkRule(finalFilePath, self.objectFiles, makeConf)
                subMakefile.addRule(linkRule)

                makefile.addSubDocument(subMakefile)

                allRule = GMakeSimpleRule('all', [finalFilePath])
                makefile.addRule(allRule)
            elif makeConf['target_type'] == 'dynamic_library':
                subMakefile = GMakeDocument(FINAL_TARGET_SUBMAKE_PATH)
                
                finalFileName = 'lib%(name)s.so.%(version)s' % { 
                        'name': projectConfig.getItem('project.name', 'noname'),
                        'version': projectConfig.getItem('project.version', '1.0.0')}
                finalFilePath = TARGET_PATH.join(finalFileName)

                linkRule = GCCLinkRule(finalFilePath, self.objectFiles, makeConf)
                subMakefile.addRule(linkRule)

                makefile.addSubDocument(subMakefile)

                allRule = GMakeSimpleRule('all', [finalFilePath])
                makefile.addRule(allRule)
            elif makeConf['target_type'] == 'static_library':
                subMakefile = GMakeDocument(FINAL_TARGET_SUBMAKE_PATH)
                
                finalFileName = 'lib%(name)s.a.%(version)s' % { 
                        'name': projectConfig.getItem('project.name', 'noname'),
                        'version': projectConfig.getItem('project.version', '1.0.0')}
                finalFilePath = TARGET_PATH.join(finalFileName)

                arRule = ArRule(finalFilePath, self.objectFiles, makeConf)
                subMakefile.addRule(arRule)

                makefile.addSubDocument(subMakefile)

                allRule = GMakeSimpleRule('all', [finalFilePath])
                makefile.addRule(allRule)
            else:
                self.logger.warn('target_type is not recognized!')
                sys.exit(1)
        else:
            allRule = GMakeSimpleRule('all', self.objectFiles)
            makefile.addRule(allRule)

        makefile.writeToFile()

        return True
    def init(self):
        FileUtil.createDirectory(SRC_PATH)
        FileUtil.createDirectory(INCLUDE_PATH)
        FileUtil.createDirectory(TARGET_PATH)
        FileUtil.createDirectory(SRC_MAIN_PATH)
        FileUtil.createDirectory(SRC_TEST_PATH)
        FileUtil.createDirectory(INCLUDE_MAIN_PATH)
        FileUtil.createDirectory(INCLUDE_TEST_PATH)

        return True
示例#3
0
    def init(self):
        FileUtil.createDirectory(TARGET_PATH)

        return True
示例#4
0
    def make(self, projectConfig):
        makeConf = {
            'target_type':
            projectConfig.getItem('make.configuration.target.type',
                                  self.defaultConf['target_type']),
            'cc':
            projectConfig.getItem('make.configuration.compiler.c.cc',
                                  self.defaultConf['cc']),
            'cxxc':
            projectConfig.getItem('make.configuration.compiler.cpp.cc',
                                  self.defaultConf['cxxc']),
            'cflags':
            projectConfig.getItem('make.configuration.compiler.c.flags',
                                  self.defaultConf['cflags']),
            'cxxflags':
            projectConfig.getItem('make.configuration.compiler.cpp.flags',
                                  self.defaultConf['cxxflags']),
            'fpic':
            projectConfig.getItem('make.configuration.compiler.fpic',
                                  self.defaultConf['fpic']),
            'autolink':
            projectConfig.getItem('make.configuration.linker.autolink',
                                  self.defaultConf['autolink']),
            'ar':
            projectConfig.getItem('make.configuration.archiver.ar',
                                  self.defaultConf['ar']),
            'ld':
            projectConfig.getItem('make.configuration.linker.ld',
                                  self.defaultConf['ld']),
            'ldflags':
            projectConfig.getItem('make.configuration.linker.flags',
                                  self.defaultConf['ldflags']),
            'ld_library_paths':
            projectConfig.getItem('make.configuration.linker.library_paths',
                                  self.defaultConf['ld_library_paths']),
            'libraries':
            projectConfig.getItem('make.configuration.linker.libraries', []),
            'c_src_exts':
            projectConfig.getItem('make.configuration.compiler.c.src_exts',
                                  self.defaultConf['c_src_exts']),
            'cxx_src_exts':
            projectConfig.getItem('make.configuration.compiler.cpp.src_exts',
                                  self.defaultConf['cxx_src_exts']),
            'c_include_paths':
            projectConfig.getItem(
                'make.configuration.compiler.c.include_paths',
                self.defaultConf['c_include_paths']),
            'cxx_include_paths':
            projectConfig.getItem(
                'make.configuration.compiler.cpp.include_paths',
                self.defaultConf['cxx_include_paths']),
            'cxx_using_c_include_paths':
            projectConfig.getItem(
                'make.configuration.compiler.cpp.inherit_c_include_path',
                self.defaultConf['cxx_using_c_include_paths'])
        }

        makefile = GMakeDocument(TARGET_MAKEFILE_PATH)

        self.mainSourceFiles.clear()
        self.objectFiles.clear()
        cSourceFiles = []
        cppSourceFiles = []
        FileUtil.searchAllFiles(cSourceFiles, SRC_MAIN_PATH,
                                makeConf['c_src_exts'])
        FileUtil.searchAllFiles(cppSourceFiles, SRC_MAIN_PATH,
                                makeConf['cxx_src_exts'])
        self.mainSourceFiles.extend(cSourceFiles)
        self.mainSourceFiles.extend(cppSourceFiles)

        for fileName in self.mainSourceFiles:
            filePath = Path(fileName, True)
            relPath = filePath.getRelevantPath(SRC_MAIN_PATH)
            dirName = relPath.getDirName()
            baseName = relPath.getBaseName()

            subMakeDirPath = TARGET_SUBMAKE_MAIN_PATH.join(dirName)
            FileUtil.createDirectory(subMakeDirPath)

            subMakefilePath = subMakeDirPath.join(PathUtil.getPrefix(baseName))
            subMakefilePath.appendExt('mk')
            subMakefile = GMakeDocument(subMakefilePath)

            compileRule = GCCCompileRule(filePath, [INCLUDE_MAIN_PATH],
                                         SRC_MAIN_PATH,
                                         TARGET_OBJECT_MAIN_PATH, makeConf)
            subMakefile.addRule(compileRule)
            makefile.addSubDocument(subMakefile)

            objectFilePath = Path(compileRule.getTarget())
            self.objectFiles.append(objectFilePath)

        if makeConf['autolink']:
            if makeConf['target_type'] == 'executable':
                subMakefile = GMakeDocument(FINAL_TARGET_SUBMAKE_PATH)

                finalFileName = '%(name)s-%(version)s' % {
                    'name': projectConfig.getItem('project.name', 'noname'),
                    'version': projectConfig.getItem('project.version',
                                                     '1.0.0')
                }
                finalFilePath = TARGET_PATH.join(finalFileName)

                linkRule = GCCLinkRule(finalFilePath, self.objectFiles,
                                       makeConf)
                subMakefile.addRule(linkRule)

                makefile.addSubDocument(subMakefile)

                allRule = GMakeSimpleRule('all', [finalFilePath])
                makefile.addRule(allRule)
            elif makeConf['target_type'] == 'dynamic_library':
                subMakefile = GMakeDocument(FINAL_TARGET_SUBMAKE_PATH)

                finalFileName = 'lib%(name)s.so.%(version)s' % {
                    'name': projectConfig.getItem('project.name', 'noname'),
                    'version': projectConfig.getItem('project.version',
                                                     '1.0.0')
                }
                finalFilePath = TARGET_PATH.join(finalFileName)

                linkRule = GCCLinkRule(finalFilePath, self.objectFiles,
                                       makeConf)
                subMakefile.addRule(linkRule)

                makefile.addSubDocument(subMakefile)

                allRule = GMakeSimpleRule('all', [finalFilePath])
                makefile.addRule(allRule)
            elif makeConf['target_type'] == 'static_library':
                subMakefile = GMakeDocument(FINAL_TARGET_SUBMAKE_PATH)

                finalFileName = 'lib%(name)s.a.%(version)s' % {
                    'name': projectConfig.getItem('project.name', 'noname'),
                    'version': projectConfig.getItem('project.version',
                                                     '1.0.0')
                }
                finalFilePath = TARGET_PATH.join(finalFileName)

                arRule = ArRule(finalFilePath, self.objectFiles, makeConf)
                subMakefile.addRule(arRule)

                makefile.addSubDocument(subMakefile)

                allRule = GMakeSimpleRule('all', [finalFilePath])
                makefile.addRule(allRule)
            else:
                self.logger.warn('target_type is not recognized!')
                sys.exit(1)
        else:
            allRule = GMakeSimpleRule('all', self.objectFiles)
            makefile.addRule(allRule)

        makefile.writeToFile()

        return True
示例#5
0
    def init(self):
        FileUtil.createDirectory(SRC_PATH)
        FileUtil.createDirectory(INCLUDE_PATH)
        FileUtil.createDirectory(TARGET_PATH)
        FileUtil.createDirectory(SRC_MAIN_PATH)
        FileUtil.createDirectory(SRC_TEST_PATH)
        FileUtil.createDirectory(INCLUDE_MAIN_PATH)
        FileUtil.createDirectory(INCLUDE_TEST_PATH)

        return True
    def init(self):
        FileUtil.createDirectory(TARGET_PATH)

        return True