Ejemplo n.º 1
0
def TryReplaceSection(basicConfig: BasicConfig, lines: List[str],
                      sectionName: str, replacementLines: List[str],
                      path: str) -> Optional[List[str]]:
    sectionBegin = "{0}_BEGIN".format(sectionName)
    sectionEnd = "{0}_END".format(sectionName)
    startIndex = IndexOf(lines, sectionBegin)
    if startIndex < 0:
        basicConfig.LogPrint(
            "WARNING: {0} did not contain a {1} section".format(
                path, sectionBegin))
        return None
    endIndex = IndexOf(lines, sectionEnd)
    if endIndex < 0:
        basicConfig.LogPrint(
            "WARNING: {0} did not contain a {1} section".format(
                path, sectionEnd))
        return None
    if startIndex >= endIndex:
        basicConfig.LogPrint("WARNING: {0} {1} must appear before {2}".format(
            path, sectionBegin, sectionEnd))
        return None

    start = lines[0:startIndex + 1]
    end = lines[endIndex:]
    return start + replacementLines + end
Ejemplo n.º 2
0
def TryExtractBrief(basicConfig: BasicConfig, lines: List[str],
                    path: str) -> Optional[List[str]]:
    startIndex = IndexOf(lines, "AG_BRIEF_BEGIN")
    if startIndex < 0:
        basicConfig.LogPrint(
            "WARNING: {0} did not contain a AG_BRIEF_BEGIN section".format(
                path))
        return None
    endIndex = IndexOf(lines, "AG_BRIEF_END")
    if endIndex < 0:
        basicConfig.LogPrint(
            "WARNING: {0} did not contain a AG_BRIEF_END section".format(path))
        return None
    if startIndex >= endIndex:
        basicConfig.LogPrint(
            "WARNING: {0} AG_BRIEF_BEGIN must appear before AG_BRIEF_END".
            format(path))
        return None

    result = lines[startIndex + 1:endIndex]

    # remove all empty lines at the end
    index = len(result) - 1
    while index >= 0 and len(result[index]) == 0:
        result.pop(index)
        index = index - 1

    return result
def __TryValidateInstallation(basicConfig: BasicConfig,
                              validationEngine: ValidationEngine,
                              package: Package, packagesToBuild: List[Package],
                              recipePackageStateCache: RecipePackageStateCache,
                              cmakeConfig: GeneratorCMakeConfig) -> bool:
    if package.ResolvedDirectExperimentalRecipe is None:
        raise Exception("Invalid package")
    sourceRecipe = package.ResolvedDirectExperimentalRecipe
    installPath = sourceRecipe.ResolvedInstallLocation
    if installPath is not None:
        if not IOUtil.IsDirectory(installPath.ResolvedPath):
            basicConfig.LogPrintVerbose(
                2, "Installation directory not located: {0}".format(
                    installPath.ResolvedPath))
            return False
        elif basicConfig.Verbosity >= 2:
            basicConfig.LogPrint(
                "Installation directory located at '{0}'".format(
                    installPath.ResolvedPath))

    # Check if the user decided to do a build override by creating the required file.
    # This allows the user to tell the system that it has been build and it should mind its own buisness
    packageHasUserBuildOverride = False
    if not installPath is None:
        overrideFilename = IOUtil.Join(
            installPath.ResolvedPath,
            __g_BuildPackageInformationOverrideFilename)
        packageHasUserBuildOverride = IOUtil.IsFile(overrideFilename)
        if packageHasUserBuildOverride:
            basicConfig.LogPrint(
                "Package {0} contained a build override file '{1}'".format(
                    package.Name, __g_BuildPackageInformationOverrideFilename))

    if not __RunValidationEngineCheck(validationEngine, package):
        if packageHasUserBuildOverride:
            raise Exception(
                "Package {0} contained a build override file '{1}', but it failed validation. Fix the issues or delete the override file '{2}'"
                .format(package.Name,
                        __g_BuildPackageInformationOverrideFilename,
                        overrideFilename))
        basicConfig.LogPrintVerbose(2, "Install validation failed")
        return False

    # If there is a user build override we dont check the build dependency json file
    if packageHasUserBuildOverride:
        return True

    # If there is no build pipeline we consider the validation to be completed, else we need to check the saved build info
    if not PackageRecipeUtil.HasBuildPipeline(package):
        return True

    if not BuildInfoFileUtil.TryValidateBuildInformation(
            basicConfig, package, packagesToBuild, recipePackageStateCache,
            cmakeConfig, __g_BuildPackageInformationFilename):
        basicConfig.LogPrintVerbose(
            2, "Install validator failed to load build information")
        return False
    return True
    def __init__(self, basicConfig: BasicConfig,
                 recipeFilterManager: RecipeFilterManager,
                 experimental: Optional[ToolConfigExperimental],
                 generator: GeneratorPlugin) -> None:
        cmakeGenerator = CMakeTypes.TryDetermineCMakeGenerator(generator)
        cmakeGeneratorShortName = None
        if cmakeGenerator is not None:
            cmakeGeneratorShortName = CMakeTypes.TryGetCompilerShortIdFromGeneratorName(
                cmakeGenerator)

        shortCompilerName = "NotDefined" if cmakeGeneratorShortName is None else cmakeGeneratorShortName
        if cmakeGeneratorShortName is None:
            if basicConfig.Verbosity >= 2:
                basicConfig.LogPrintWarning(
                    "No CMake short generator id has been defined, defaulting to '{0}'"
                    .format(shortCompilerName))

        recipeBuilderSetup = None
        allowDownloads = False
        if experimental is not None:
            targetLocation = ResolvedPath(
                experimental.DefaultThirdPartyInstallDirectory.DynamicName,
                experimental.DefaultThirdPartyInstallDirectory.ResolvedPath)
            installReadonlySource = experimental.DefaultThirdPartyInstallReadonlyCacheDirectory
            readonlyCachePath = None if installReadonlySource is None else installReadonlySource.ResolvedPath  # type: Optional[str]
            recipeBuilderSetup = RecipeBuilderSetup(targetLocation,
                                                    readonlyCachePath)
            if IOUtil.TryGetEnvironmentVariable(
                    experimental.DisableDownloadEnv) != None:
                allowDownloads = False
                basicConfig.LogPrint(
                    "Downloads disabled since the environment variable {0} was defined"
                    .format(experimental.DisableDownloadEnv))
            elif experimental.AllowDownloads:
                allowDownloads = True
            else:
                basicConfig.LogPrint(
                    "Downloads disabled since the project has it disabled by default"
                )

        super().__init__(basicConfig, generator.PlatformName,
                         generator.PlatformName, shortCompilerName,
                         recipeBuilderSetup)

        #allowDownload=True, disableDownloadEnv=None

        self.BasicConfig = basicConfig
        self.Generator = generator
        # for now the generator is also the platform and the existing code use that name so maintain compatibility for now
        self.Platform = generator
        self.AllowDownloads = allowDownloads
        self.RecipeFilterManager = recipeFilterManager
Ejemplo n.º 5
0
    def __init__(self, basicConfig: BasicConfig,
                 errorHelpManager: ErrorHelpManager,
                 recipeFilterManager: RecipeFilterManager,
                 experimental: Optional[ToolConfigExperimental],
                 generator: GeneratorPlugin) -> None:
        if generator.CMakeConfig is None:
            raise Exception("Invalid generator")

        recipeBuilderSetup = None
        allowDownloads = False
        if experimental is not None:
            targetLocation = ResolvedPath(
                experimental.DefaultThirdPartyInstallDirectory.DynamicName,
                experimental.DefaultThirdPartyInstallDirectory.ResolvedPath)
            installReadonlySource = experimental.DefaultThirdPartyInstallReadonlyCacheDirectory
            readonlyCachePath = None if installReadonlySource is None else installReadonlySource.ResolvedPath  # type: Optional[str]
            recipeBuilderSetup = RecipeBuilderSetup(targetLocation,
                                                    readonlyCachePath)
            if IOUtil.TryGetEnvironmentVariable(
                    experimental.DisableDownloadEnv) != None:
                allowDownloads = False
                basicConfig.LogPrint(
                    "Downloads disabled since the environment variable {0} was defined"
                    .format(experimental.DisableDownloadEnv))
            elif experimental.AllowDownloads:
                allowDownloads = True
            else:
                basicConfig.LogPrint(
                    "Downloads disabled since the project has it disabled by default"
                )

        generatorInfo = GeneratorInfo(generator.IsCMake,
                                      generator.CMakeConfig.AllowFindPackage)
        super().__init__(basicConfig, errorHelpManager, generator.PlatformName,
                         generator.PlatformName, generatorInfo,
                         generator.CMakeConfig, recipeBuilderSetup)

        #allowDownload=True, disableDownloadEnv=None

        self.BasicConfig = basicConfig
        self.Generator = generator
        # for now the generator is also the platform and the existing code use that name so maintain compatibility for now
        self.Platform = generator
        self.AllowDownloads = allowDownloads
        self.RecipeFilterManager = recipeFilterManager
Ejemplo n.º 6
0
def __CreatePipelines(basicConfig: BasicConfig,
                      builder: PipelineCommandBuilder,
                      resolvedBuildOrder: List[Package]) -> List[RecipeRecord]:
    pipelines = []  # type: List[RecipeRecord]
    for package in resolvedBuildOrder:
        basicConfig.LogPrint("Creating package {0} build pipelines".format(
            package.Name))
        try:
            basicConfig.PushIndent()
            record = RecipeRecord(basicConfig, builder, package)
            pipelines.append(record)
        finally:
            basicConfig.PopIndent()
    return pipelines
Ejemplo n.º 7
0
 def __ProcessCompilerConfiguration(
     self, basicConfig: BasicConfig,
     xmlCompilerConfiguration: List[XmlConfigCompilerConfiguration]
 ) -> Dict[str, ToolConfigCompilerConfiguration]:
     result = {}  # type: Dict[str, ToolConfigCompilerConfiguration]
     for config in xmlCompilerConfiguration:
         if config.Id in result:
             raise XmlDuplicatedCompilerConfigurationException(
                 result[config.Id].BasedOn.XMLElement,
                 result[config.Id].Name, config.XMLElement, config.Name)
         elif config.Name == CompilerNames.VisualStudio:
             result[config.Id] = ToolConfigCompilerConfiguration(
                 basicConfig, config)
         else:
             msg = "CompilerConfiguration name: '{0}' is not currently supported, so entry is ignored".format(
                 config.Name)
             basicConfig.LogPrint(msg)
     return result
Ejemplo n.º 8
0
def __FindMissingInstallations(
        basicConfig: BasicConfig, validationEngine: ValidationEngine,
        resolvedBuildOrder: List[Package],
        recipePackageStateCache: RecipePackageStateCache) -> List[Package]:
    """ Check packages in the resolvedBuildOrder and return all that fails install validation, keeping the initial order """
    missingPackages = []  # type: List[Package]
    for package in resolvedBuildOrder:
        basicConfig.LogPrint("Checking if package {0} is installed".format(
            package.Name))
        try:
            basicConfig.PushIndent()
            if not __TryValidateInstallation(basicConfig, validationEngine,
                                             package, missingPackages,
                                             recipePackageStateCache):
                missingPackages.append(package)
        finally:
            basicConfig.PopIndent()
    return missingPackages