예제 #1
0
    def moveDependentProjectsToWorkingDir(self, projectToCopyFrom, projectType, rootToCopyFrom):
        destinationDir = FileSystem.getDirectory(FileSystem.INSTALL_ROOT, self._config, self._project_name)

        destLibDir = os.path.join(destinationDir, "lib")
        if not os.path.exists(destLibDir):
                Utilities.mkdir(destLibDir)
        if platform.system() == "Windows":
            destBinDir = os.path.join(destinationDir, "bin")
            if not os.path.exists(destBinDir):
                Utilities.mkdir(destBinDir)
            # copy dll and lib
            if projectType is None or projectType.upper() == "SHARED":
                Utilities.copyTree(os.path.join(rootToCopyFrom, "bin", projectToCopyFrom + ".dll"), destBinDir)
            Utilities.copyTree(os.path.join(rootToCopyFrom, "lib", projectToCopyFrom + ".lib"), destLibDir)
        else:
            if projectType is None or projectType.upper() == "SHARED":
                # copy .so
                baseRoot = os.path.join(rootToCopyFrom, "lib")
                if not os.path.exists(baseRoot):
                    baseRoot = os.path.join(rootToCopyFrom, "lib64")
                if not os.path.exists(baseRoot):
                    Utilities.failExecution("directories [%s, %s] do not exist" %
                                            (os.path.join(rootToCopyFrom, "lib"), baseRoot))
                fileRegex = "lib" + projectToCopyFrom
                currentFilePath = None
                for entry in os.listdir(baseRoot):
                    currentFilePath = os.path.join(baseRoot, entry)
                    if fileRegex in entry and not os.path.isdir(currentFilePath):
                        Utilities.copyTree(currentFilePath, destLibDir)
            else:
                # copy .a
                Utilities.copyTree(os.path.join(rootToCopyFrom, "lib", "lib" + projectToCopyFrom + ".a"), destLibDir)
        Utilities.copyTree(os.path.join(rootToCopyFrom, "include", projectToCopyFrom),
                           os.path.join(destinationDir, "include", projectToCopyFrom))
예제 #2
0
 def makeVisualStudioProjects(self, test="OFF", logging="OFF"):
     wd = FileSystem.getDirectory(FileSystem.VISUAL_STUDIO_ROOT, self._config, self._project_name)
     Utilities.mkdir(wd)
     CMakeArgs = self.getCMakeArgs("", wd, test, logging)
     if platform.system() == "Windows":
         visualStudioVersion = Utilities.formatVisualStudioVersion(Utilities.getVisualStudioVersion())
         CMakeArgs.extend(["-G", '"Visual Studio %s"' % visualStudioVersion])
         Utilities.PForkWithVisualStudio(appToExecute="cmake", argsForApp=CMakeArgs, wd=wd)
예제 #3
0
    def cmake(self, test="OFF", logging="OFF", python="OFF"):
        # make directory that CMake will dump output to
        wd = FileSystem.getDirectory(FileSystem.WORKING, self._config, self._project_name)
        Utilities.mkdir(wd)

        CMakeArgs = self.getCMakeArgs("", wd, test, logging, python)
        if platform.system() == "Windows":
            CMakeArgs.extend(["-G", '"NMake Makefiles"'])
            Utilities.PForkWithVisualStudio(appToExecute="cmake", argsForApp=CMakeArgs, wd=wd)
        else:
            CMakeArgs.extend(["-G", "Unix Makefiles"])
            Utilities.PFork(appToExecute="cmake", argsForApp=CMakeArgs, wd=wd, failOnError=True)
예제 #4
0
    def generateConfig(self, asyncConfigPath=None, asyncConfigFileName=None):
        outIncludeDir = os.path.join(FileSystem.getDirectory(FileSystem.OUT_ROOT),
                                     "include")
        projectLogDir = FileSystem.getDirectory(FileSystem.LOG_DIR, self._config, self._project_name)
        asyncConfig = None
        if asyncConfigPath is None:
            asyncConfig = os.path.join(FileSystem.getDirectory(FileSystem.CLIENT_CONFIG),
                                       (asyncConfigFileName if asyncConfigFileName is not None else "AsyncConfig.xml"))
        else:
            asyncConfig = asyncConfigPath
        Utilities.mkdir(outIncludeDir)

        configArgs = []

        configArgs.append(['std::string', 'LOGGING_ROOT', 'dir', projectLogDir.replace("\\", "/")])
        if "Robos" in self._project_name:
            configArgs.append(['std::string', 'ASYNC_CONFIG_PATH', 'file', asyncConfig.replace("\\", "/")])

        (formattedConfigArgsHeader, formattedConfigArgsSrc) = self.checkConfigArgsAndFormat("\t", configArgs)

        if os.path.exists(projectLogDir):
            Utilities.rmTree(projectLogDir)
        Utilities.mkdir(projectLogDir)
        projNameUpper = self._project_name.upper()
        with open(os.path.join(outIncludeDir, self._project_name + "Config.hpp"), 'w') as file:
            file.write("#pragma once\n"
                       "#ifndef " + projNameUpper + "_CONFIG_" + projNameUpper + "CONFIG_HPP\n"
                       "#define " + projNameUpper + "_CONFIG_" + projNameUpper + "CONFIG_HPP\n\n"
                       "// SYSTEM INCLUDES\n"
                       "#include <string>\n\n"
                       "// C++ PROJECT INCLUDES\n\n"
                       "namespace " + self._project_name + "\n"
                       "{\n"
                       "namespace Config\n"
                       "{\n\n" +
                       formattedConfigArgsHeader +
                       "} // end of namespace Config\n"
                       "} // end of namespace " + self._project_name + "\n"
                       "#endif // end of " + projNameUpper + "_CONFIG_" + projNameUpper + "CONFIG_HPP\n")
        with open(os.path.join(outIncludeDir, self._project_name + "Config.cpp"), 'w') as file:
            file.write("// SYSTEM INCLUDES\n\n"
                       "// C++ PROJECT INCLUDES\n"
                       "#include \"" + self._project_name + "Config.hpp\"\n\n"
                       "namespace " + self._project_name + "\n"
                       "{\n"
                       "namespace Config\n"
                       "{\n\n" +
                       formattedConfigArgsSrc +
                       "} // end of namespace Config\n"
                       "} // end of namespace " + self._project_name + "\n")
예제 #5
0
 def generateProjectVersion(self):
     outIncludeDir = os.path.join(
         FileSystem.getDirectory(FileSystem.OUT_ROOT),
         'include'
     )
     print("making directory %s" % outIncludeDir)
     Utilities.mkdir(outIncludeDir)
     with open(os.path.join(outIncludeDir, 'Version.hpp'), 'w') as file:
         file.write("#pragma once\n"
                    "#ifndef VERSION_H\n"
                    "#define VERSION_H\n\n"
                    "#define VERSION       " + self._project_build_number + "\n"
                    "#define VERSION_STR  \"" + self._project_build_number + "\"\n\n"
                    "#endif  // VERSION_H\n\n")
예제 #6
0
    def buildAndLoadDependencies(self):
        dependentProjects = self.parseDependencyFile()
        print("dependentProjects %s" % dependentProjects)
        projectBuild = None

        Utilities.mkdir(FileSystem.getDirectory(FileSystem.INSTALL_ROOT, self._config, self._project_name))
        allBuiltOutDir = FileSystem.getDirectory(FileSystem.OUT_ROOT, self._config)
        for project in dependentProjects:
            dependentProjectPath = FileSystem.getDirectory(FileSystem.INSTALL_ROOT, self._config,  project[0])

            # build the project if necessary
            if not os.path.exists(dependentProjectPath):
                projectBuild = LocalBuildRules.LocalBuild(project[0])
                projectBuild.run(([], self._custom_args))

            # copy over necessary objects to link
            self.moveDependentProjectsToWorkingDir(project[0],
                                                   project[1] if len(project) >= 2 else None,
                                                   allBuiltOutDir)
예제 #7
0
    def checkConfigArgsAndFormat(self, offset, configArgs):
        formattedHeader = ""
        formattedSrc = ""
        for arg in configArgs:
            if arg[2] == "dir":
                if os.path.exists(arg[3]):
                    if os.path.isdir(arg[3]):
                        Utilities.rmTree(arg[3])
                    else:
                        Utilities.failExecution("Path [%s] was assumed to be a directory" % arg[3])
                Utilities.mkdir(arg[3])
            elif arg[2] == "file":
                if not os.path.exists(arg[3]) or not os.path.isfile(arg[3]):
                    Utilities.failExecution("Path [%s] does not exist or is not a file" % arg[3])
            elif arg[2] is not None:
                Utilities.failExecution("unknown config variable value specifier [%s]" % arg[2])

            formattedHeader += offset + "extern const " + arg[0] + " " + arg[1] + ";\n\n"
            formattedSrc += offset + "const " + arg[0] + " " + \
                arg[1] + " = " + ("\"" + str(arg[3]) + "\"" if "string" in arg[0] else str(arg[3])) + \
                ";\n\n"

        return formattedHeader, formattedSrc
예제 #8
0
파일: rbuild.py 프로젝트: aew61/Utilities
 def customSetupWorkspace(self, node):
     print("Setting up workspaces for package [%s]" % node._name)
     self.cleanBuildWorkspace(node)
     Utilities.mkdir(FileSystem.getDirectory(FileSystem.WORKING, self._config, node._name))
     self.loadDependencies(node)
예제 #9
0
 def setupWorkspace(self):
     print("Setting up workspaces for project [%s]" % self._project_name)
     self.cleanBuildWorkspace()
     Utilities.mkdir(FileSystem.getDirectory(FileSystem.WORKING, self._config, self._project_name))
     self.buildAndLoadDependencies()