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))
def parseDependencyFile(self): dependencyFilePath = os.path.join(FileSystem.getDirectory(FileSystem.DEPENDENCIES), "dependencies.txt") if not os.path.exists(dependencyFilePath): Utilities.failExecution("dependency file [%s] does not exist" % dependencyFilePath) requiredProjects = [] with open(dependencyFilePath, 'r') as file: flag = False lineNum = 0 splitLine = None for line in file: splitLine = line.strip().split(None) if len(splitLine) == 0 or splitLine[0] == '#': continue if splitLine[0] == '-' + self._project_name: flag = True elif flag and '-' not in splitLine[0]: requiredProjects.append(splitLine) elif flag and '-' in splitLine[0] and ('-' + self._project_name) != splitLine[0]: flag = False elif not flag: continue else: Utilities.failExecution("Parse error in dependency file [%s] at line [%s]" % (dependencyFilePath, lineNum)) lineNum += 1 print("Required projects for project [%s] are %s" % (self._project_name, requiredProjects)) return requiredProjects
def run(self, parsedCommandLine): (buildSteps, self._custom_args) = (parsedCommandLine[0], parsedCommandLine[1]) # this build MUST have a project name to run if self._project_name == "": Utilities.failExecution("Project name not set") # if the user has not specified any build steps, run the default if len(buildSteps) == 0: buildSteps = self._build_steps # run the build for the user specified configuration else run for # all configurations (the user can restrict this to build for # debug or release versions) if "configuration" in self._custom_args: self._config = self._custom_args["configuration"] if self._config != "release" and self._config != "debug": Utilities.failExecution("Unknown configuration [%s]" % self._config) print("\nbuilding configuration [%s]\n" % self._config) self.executeBuildSteps(buildSteps) else: for configuration in self._configurations: print("\nbuilding configuration [%s]\n" % configuration) self._config = configuration self.executeBuildSteps(buildSteps) print("********************") print("* COMPLETE *") print("********************")
def executeStep(self, buildStep): if hasattr(self, buildStep): print("-Executing build step [%s]" % buildStep) method = getattr(self, buildStep) success = Utilities.call(method, self._custom_args) if not success: Utilities.failExecution("Build step [%s] failed" % buildStep) else: Utilities.failExecution("Project %s does not have build step [%s]" % (self._project_name, buildStep))
def getDirectory(directoryEnum, configuration='', projectName=''): if directoryEnum == ROOT: return os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) elif directoryEnum == WORKING: return os.path.join(getDirectory(ROOT), 'build', configuration, projectName) elif directoryEnum == SCRIPT_ROOT: return os.path.join(getDirectory(ROOT), 'scripts') elif directoryEnum == PROJECT_ROOT: return os.path.join(getDirectory(ROOT), 'projects') elif directoryEnum == MANUAL_DIR: return os.path.join(getDirectory(ROOT), 'manual') elif directoryEnum == CPP_SOURCE_DIR: return os.path.join(getDirectory(ROOT), 'cpp') elif directoryEnum == TEST_REPORT_DIR: return os.path.join(getDirectory(WORKING, configuration, projectName), 'testReports') elif directoryEnum == CMAKE_BASE_DIR: return os.path.join(getDirectory(ROOT), 'cmake') elif directoryEnum == CMAKE_TOOLCHAIN_DIR: return os.path.join(getDirectory(CMAKE_BASE_DIR), 'toolchains') elif directoryEnum == CMAKE_MODULE_DIR: return os.path.join(getDirectory(CMAKE_BASE_DIR), 'modules') elif directoryEnum == OUT_ROOT: return os.path.join(getDirectory(WORKING, configuration, projectName), 'out') elif directoryEnum == INSTALL_ROOT: return os.path.join(getDirectory(OUT_ROOT, configuration, projectName), 'installRoot') elif directoryEnum == INSTALL_DIR: return os.path.join(getDirectory(OUT_ROOT, configuration, projectName), 'install') elif directoryEnum == LOG_DIR: return os.path.join(getDirectory(WORKING, configuration, projectName), 'logs') elif directoryEnum == DEPENDENCIES: return os.path.join(getDirectory(ROOT), "dependencies") elif directoryEnum == IDE_ROOT: return os.path.join(getDirectory(OUT_ROOT, configuration, projectName), "IDE") elif directoryEnum == CLIENT_ROOT: return os.path.join(getDirectory(ROOT), "client") elif directoryEnum == CLIENT_CONFIG: return os.path.join(getDirectory(CLIENT_ROOT), "config") else: Utilities.failExecution("Unknown directoryEnum: [%s]" % directoryEnum)
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