Beispiel #1
0
 def __init__(self, log: Log,
              sourceCommand: XmlRecipePipelineCommandCMakeBuild,
              pipelineInfo: PipelineInfo, allowSkip: bool) -> None:
     super().__init__(log, sourceCommand, pipelineInfo)
     self.Source = sourceCommand.Source
     if pipelineInfo.Tasks.TaskCMakeAndBuild is None:
         raise Exception(
             "The '{0}' operation has not been enabled for this platform".
             format(sourceCommand.CommandName))
     self.Task = pipelineInfo.Tasks.TaskCMakeAndBuild
     self.__SourceCommand = sourceCommand
     self.AllowSkip = allowSkip
     self.VariableDict = self.__BuildVariableDict(log)
     self._IsAndroid = pipelineInfo.SourcePackage.ResolvedPlatform.Name == PlatformNameString.ANDROID if pipelineInfo.SourcePackage.ResolvedPlatform is not None else False
     if self._IsAndroid:
         minVersion = CMakeUtil.GetMinimumVersion()
         try:
             version = CMakeUtil.GetVersion()
             self.Log.LogPrint("CMake version {0}.{1}.{2}".format(
                 version.Major, version.Minor, version.Build))
             if version < minVersion:
                 raise Exception(
                     "CMake version {0}.{1}.{2} or greater is required".
                     format(minVersion.Major, minVersion.Minor,
                            minVersion.Build))
         except Exception as e:
             self.Log.DoPrintWarning(
                 "Failed to determine CMake version, please ensure you have {0}.{1}.{2} or better available."
                 .format(minVersion.Major, minVersion.Minor,
                         minVersion.Build))
             self.Log.LogPrintWarning(str(e))
    def __GetCMakeConfiguration(
            self,
            configList: List[XmlCMakeConfiguration]) -> CMakeConfiguration:
        if len(configList) != 1:
            if len(configList) <= 0:
                return CMakeConfiguration("${TopProjectRoot}/build", None,
                                          CMakeUtil.GetMinimumVersion(), [])
            raise Exception("There can only be one CMakeConfiguration")
        configEntry = configList[0]

        defaultBuildDir = configEntry.DefaultBuildDir
        defaultInstallPrefix = configEntry.DefaultInstallPrefix
        minVersion = self.__ParseCMakeVersionString(configEntry.MinVersion)

        platformList = []  # type: List[CMakeConfigurationPlatform]
        for platformEntry in configEntry.Platforms:
            # Default to the platform one if its defined, else default to the general one (which can be None)
            platformEntryDefaultInstallPrefix = platformEntry.DefaultInstallPrefix if platformEntry.DefaultInstallPrefix is not None else defaultInstallPrefix
            # Generate the platform config object
            platformList.append(
                CMakeConfigurationPlatform(platformEntry.Name,
                                           platformEntry.DefaultGeneratorName,
                                           platformEntryDefaultInstallPrefix))

        if defaultBuildDir is None:
            raise Exception(
                "CMakleConfiguration.DefaultBuildDir must be defined")
        return CMakeConfiguration(defaultBuildDir, defaultInstallPrefix,
                                  minVersion, platformList)
 def __ParseCMakeVersionString(self,
                               versionStr: Optional[str]) -> CMakeVersion:
     toolMin = CMakeUtil.GetMinimumVersion()
     if versionStr is None:
         return toolMin
     parsedMinVersion = Util.ParseVersionString(versionStr, maxValues=3)
     while len(parsedMinVersion) < 3:
         parsedMinVersion.append(0)
     projectMin = CMakeVersion(parsedMinVersion[0], parsedMinVersion[1],
                               parsedMinVersion[2])
     return projectMin if projectMin >= toolMin else toolMin
Beispiel #4
0
def BuildGeneratorCMakeConfig(log: Log, toolVersion: Version, platformName: str, buildVariantConfig: BuildVariantConfig,
                              userCMakeConfig: Optional[UserCMakeConfig], cmakeConfiguration: CMakeConfiguration,
                              defaultCompilerVersion: int, isCheckMode: bool) -> GeneratorCMakeConfig:
    """
    Build the CMake config based on the supplied parameters and the default settings from the toolconfig
    """

    # Setup default configuration
    buildDir = IOUtil.Join(cmakeConfiguration.DefaultBuildDir, platformName)
    generatorName = ""
    installPrefix = cmakeConfiguration.DefaultInstallPrefix

    # Give the platform a chance to override the config
    platformConfig = cmakeConfiguration.TryGetPlatformConfig(platformName)
    allowFindPackage = True
    if platformConfig is not None:
        if platformConfig.DefaultGeneratorName is not None:
            generatorName = platformConfig.DefaultGeneratorName
        if platformConfig.DefaultInstallPrefix is not None:
            installPrefix = platformConfig.DefaultInstallPrefix
        if platformConfig.AllowFindPackage is not None:
            allowFindPackage = platformConfig.AllowFindPackage
            log.LogPrintVerbose(2, "project defined AllowFindPackage to {0}".format(allowFindPackage))

    # Apply the commandline overrides (so the user gets the final say)
    buildDirSetByUser = False
    if userCMakeConfig is not None:
        if userCMakeConfig.BuildDir is not None:
            buildDir = userCMakeConfig.BuildDir
            buildDirSetByUser = True
        if userCMakeConfig.GeneratorName is not None:
            generatorName = userCMakeConfig.GeneratorName
        if userCMakeConfig.InstallPrefix is not None:
            installPrefix = userCMakeConfig.InstallPrefix
        if userCMakeConfig.AllowFindPackage is not None:
            allowFindPackage = userCMakeConfig.AllowFindPackage
            log.LogPrintVerbose(2, "Command line set AllowFindPackage to {0}".format(allowFindPackage))

    # If we still dont have a generator name then try to select a good default
    if len(generatorName) <= 0:
        # Try to determine the default generator name for the platform
        generatorName = CMakeHelper.GetPlatformDefaultCMakeGenerator(platformName, defaultCompilerVersion)

    cmakeVersion = CMakeUtil.GetVersion()

    cmakeConfigGlobalArgs = [] if userCMakeConfig is None else shlex.split(userCMakeConfig.ConfigGlobalArgs)
    cmakeConfigAppArgs = [] if userCMakeConfig is None else shlex.split(userCMakeConfig.ConfigAppArgs)

    checkDir = IOUtil.Join(buildDir, 'fsl')
    if isCheckMode:
        buildDir = checkDir

    return GeneratorCMakeConfig(toolVersion, platformName, buildVariantConfig, buildDir, buildDirSetByUser, checkDir, generatorName, installPrefix,
                                cmakeVersion, cmakeConfigGlobalArgs, cmakeConfigAppArgs, allowFindPackage)
Beispiel #5
0
def BuildGeneratorCMakeConfig(
        platformName: str, userCMakeConfig: Optional[UserCMakeConfig],
        cmakeConfiguration: CMakeConfiguration,
        defaultCompilerVersion: int) -> GeneratorCMakeConfig:
    """
    Build the CMake config based on the supplied parameters and the default settings from the toolconfig
    """

    # Setup default configuration
    buildDir = cmakeConfiguration.DefaultBuildDir
    generatorName = ""
    installPrefix = cmakeConfiguration.DefaultInstallPrefix

    # Give the platform a chance to override the config
    platformConfig = cmakeConfiguration.TryGetPlatformConfig(platformName)
    if platformConfig is not None:
        if platformConfig.DefaultGeneratorName is not None:
            generatorName = platformConfig.DefaultGeneratorName
        if platformConfig.DefaultInstallPrefix is not None:
            installPrefix = platformConfig.DefaultInstallPrefix

    # Apply the commandline overrides (so the user gets the final say)
    if userCMakeConfig is not None:
        if userCMakeConfig.BuildDir is not None:
            buildDir = userCMakeConfig.BuildDir
        if userCMakeConfig.GeneratorName is not None:
            generatorName = userCMakeConfig.GeneratorName
        if userCMakeConfig.InstallPrefix is not None:
            installPrefix = userCMakeConfig.InstallPrefix

    # If we still dont have a generator name then try to select a good default
    if len(generatorName) <= 0:
        # Try to determine the default generator name for the platform
        generatorName = CMakeTypes.GetPlatformDefaultCMakeGenerator(
            platformName, defaultCompilerVersion)

    cmakeVersion = CMakeUtil.GetVersion()

    return GeneratorCMakeConfig(buildDir, generatorName, installPrefix,
                                cmakeVersion)