def Execute(self, toolFinder: PackageToolFinder, path: str, target: CMakeTargetType, cmakeProjectName: str, configuration: BuildVariantConfig, buildEnv: Dict[str, str], parentPath: str) -> None: projectFile = "rules.ninja" if self.__UseRecipe: toolPackage = toolFinder.GetToolPackageByToolName('ninja') commandName = IOUtil.Join(toolPackage.AbsoluteToolPath, self.__CommandName) else: commandName = self.__CommandName self.Log.LogPrint( "* Running ninja at '{0}' for project '{1}' and configuration '{2}'" .format(path, projectFile, BuildVariantConfig.ToString(configuration))) buildCommand = [commandName] if target == CMakeTargetType.Install: buildCommand.append('install') buildCommand += self.BuilderThreadArguments try: result = subprocess.call(buildCommand, cwd=path, env=buildEnv) if result != 0: raise Exception("ninja failed with {0} command {1}".format( result, buildCommand)) except Exception: self.Log.LogPrint("* ninja failed '{0}'".format(buildCommand)) raise
def FromBuildVariantConfig(buildVariantConfig: int) -> str: if BuildVariantConfig.Release: return CMakeBuildType.Release elif BuildVariantConfig.Debug: return CMakeBuildType.Debug raise Exception("Unsupported BuildVariantConfig '{0}'".format( BuildVariantConfig.ToString(buildVariantConfig)))
def __ParseConfiguration(self, configuration: str) -> List[int]: configurations = configuration.split(';') configurationList = [] for entry in configurations: config = BuildVariantConfig.FromString(entry) configurationList.append(config) return configurationList
def Execute(self, toolFinder: PackageToolFinder, path: str, target: CMakeTargetType, cmakeProjectName: str, configuration: BuildVariantConfig, buildEnv: Dict[str, str], parentPath: str) -> None: projectFile = "Makefile" self.Log.LogPrint( "* Running make at '{0}' for project '{1}' and configuration '{2}'" .format(path, projectFile, BuildVariantConfig.ToString(configuration))) buildCommand = ['make', '-f', projectFile] buildCommand += self.BuilderThreadArguments if target == CMakeTargetType.Install: buildCommand.append('install') try: result = subprocess.call(buildCommand, cwd=path, env=buildEnv) if result != 0: raise Exception("make failed {0}".format(buildCommand)) except Exception: self.Log.LogPrint("* make failed '{0}'".format(buildCommand)) raise
def Execute(self, toolFinder: PackageToolFinder, path: str, target: CMakeTargetType, cmakeProjectName: str, configuration: BuildVariantConfig, buildEnv: Dict[str, str], parentPath: str) -> None: self.Log.LogPrint( "* Running make at '{0}' for project '{1}' and configuration '{2}'" .format(path, cmakeProjectName, BuildVariantConfig.ToString(configuration))) cmakeConfig = CMakeBuildType.FromBuildVariantConfig(configuration) buildCommand = ['cmake', '--build', path, '--config', cmakeConfig] if self.NumBuildThreads > 0: buildCommand += ['--parallel', str(self.NumBuildThreads)] try: result = subprocess.call(buildCommand, cwd=parentPath, env=buildEnv) if result != 0: raise Exception("cmake failed {0}".format(buildCommand)) except Exception: self.Log.LogPrint("* cmake failed '{0}'".format(buildCommand)) raise if target == CMakeTargetType.Install: buildCommand = [ 'cmake', '--install', path, '--config', cmakeConfig ] try: result = subprocess.call(buildCommand, cwd=parentPath, env=buildEnv) if result != 0: raise Exception("cmake failed {0}".format(buildCommand)) except Exception: self.Log.LogPrint("* cmake failed '{0}'".format(buildCommand)) raise
def ParseBuildConfigString(config: str) -> BuildVariantConfig: return BuildVariantConfig.FromString(config.lower())
def __init__(self, toolVersion: Version, platformName: str, buildVariantConfig: BuildVariantConfig, buildDir: str, buildDirSetByUser: bool, checkDir: str, generatorName: str, installPrefix: Optional[str], cmakeVersion: CMakeVersion, additionalGlobalConfigArguments: List[str], additionalAppConfigArguments: List[str], allowFindPackage: bool) -> None: super().__init__() PathUtil.ValidateIsNormalizedPath(buildDir, "BuildDir") if installPrefix is not None: PathUtil.ValidateIsNormalizedPath(installPrefix, "DefaultInstallPrefix") finalGeneratorName = CMakeHelper.DetermineFinalCMakeGenerator( generatorName) # its important that we use the generatorName for the GetCompilerShortIdFromGeneratorName to get the proper android name generatorShortName = CMakeHelper.GetCompilerShortIdFromGeneratorName( generatorName) # Check if we should use a 'build variant temp dir' if not buildDirSetByUser: buildDir = IOUtil.Join(buildDir, generatorShortName) if CMakeHelper.GetGeneratorMultiConfigCapabilities( finalGeneratorName ) == CMakeGeneratorMultiConfigCapability.No: buildDir = IOUtil.Join( buildDir, BuildVariantConfig.ToString(buildVariantConfig)) self.ToolVersion = toolVersion self.PlatformName = platformName self.BuildDir = buildDir self.CacheDir = IOUtil.Join(buildDir, '_fsl') # If this is true the user specified the directory self.BuildDirSetByUser = buildDirSetByUser self.CheckDir = checkDir # the active build variant self.BuildVariantConfig = buildVariantConfig self.GeneratorName = generatorName self.InstallPrefix = installPrefix self.CMakeVersion = cmakeVersion self.CMakeCommand = CMakeHelper.DetermineCMakeCommand(platformName) # The tool arguments self.CMakeInternalArguments = CMakeHelper.DetermineGeneratorArguments( finalGeneratorName, platformName) # This contains only the user arguments for both recipe and apps self.CMakeConfigUserGlobalArguments = additionalGlobalConfigArguments self.CMakeConfigUserAppArguments = additionalAppConfigArguments # The combined arguments that should be supplied to cmake self.CMakeConfigRecipeArguments = self.CMakeInternalArguments + additionalGlobalConfigArguments # The combined arguments that should be supplied to cmake self.CMakeConfigAppArguments = self.CMakeInternalArguments + additionalGlobalConfigArguments + additionalAppConfigArguments self.CMakeFinalGeneratorName = finalGeneratorName self.GeneratorShortName = generatorShortName self.GeneratorRecipeShortName = "{0}_{1}".format( generatorShortName, toolVersion.ToMajorMinorString().replace('.', '_')) self.AllowFindPackage = allowFindPackage