Beispiel #1
0
    def __init__(self,
                 useAsRelative: bool,
                 commandFormatString: str,
                 arguments: List[str],
                 nativeArguments: List[str],
                 currentWorkingDirectoryFormatString: Optional[str] = None,
                 runInEnvScript: Optional[str] = None,
                 nativeArgumentSeparator: Optional[str] = None) -> None:
        """
            The information stored in a format string can contain both variables and environment variables and
            it need to be formatted/converted using the ReportVariableFormatter before being used.

            Some notes:
            Each variant name string as used by the generator.
            - Each normal variant is represented as a ${VARIANT_NAME} variable.
            - Each virtual variant is represented as a $(VARIANT_NAME) variable.
            Please note there can be other variables and environment variables as required by the generator
        """
        super().__init__()
        if commandFormatString is None:
            raise Exception("commandFormatString can not be None")
        if commandFormatString.startswith('/') or ':' in commandFormatString:
            raise Exception("commandFormatString can not be absolute")
        #if currentWorkingDirectoryFormatString is not None and (currentWorkingDirectoryFormatString.startswith('/') or ':' in currentWorkingDirectoryFormatString):
        #    raise Exception("currentWorkingDirectoryFormatString can not be absolute: '{0}'".format(currentWorkingDirectoryFormatString))
        if currentWorkingDirectoryFormatString is not None and IOUtil.IsDriveRootPath(
                currentWorkingDirectoryFormatString):
            raise Exception(
                "currentWorkingDirectoryFormatString can not point to a drive root: '{0}'"
                .format(currentWorkingDirectoryFormatString))
        if runInEnvScript is not None and (runInEnvScript.startswith('/')
                                           or ':' in runInEnvScript):
            raise Exception("runInEnvScript can not be absolute")
        if len(nativeArguments) != 0 and nativeArgumentSeparator is None:
            raise Exception(
                "When native args are supplied there should be a native argument separator"
            )

        # if this is true the exe should be run via as 'relative' command.
        # if this is false it will be run as a absolute path command relative to the package absolute path
        self.UseAsRelative = useAsRelative

        # The command that should be run with the cwdFormatString as CWD
        # This normally represents a absolute path, but for build-in commands it can be relative.
        # Relative paths are considered relative to the cwdFormatString
        self.CommandFormatString = commandFormatString
        self.Arguments = arguments

        # The argument that indicates that the rest of the arguments are native arguments
        self.NativeArgumentSeparator = nativeArgumentSeparator
        # Arguments that should be send to the native command
        self.NativeArguments = nativeArguments

        # if this is None, the package absolute path should be used instead
        self.CurrentWorkingDirectoryFormatString = currentWorkingDirectoryFormatString

        # A optional script that can be used to run things with the 'dynamic' environment used for virtual variants
        self.RunInEnvScript = runInEnvScript
Beispiel #2
0
    def Process(self, currentDirPath: str, toolConfig: ToolConfig, localToolConfig: LocalToolConfig) -> None:
        config = Config(self.Log, toolConfig, localToolConfig.PackageConfigurationType,
                        localToolConfig.BuildVariantsDict, localToolConfig.AllowDevelopmentPlugins)

        # Disable downloads and writes
        if config.ToolConfig.Experimental is not None:
            config.ToolConfig.Experimental.AllowDownloads = False
        config.ForceDisableAllWrite()
        if localToolConfig.IgnoreNotSupported:
            config.IgnoreNotSupported = True

        self.Log.PrintTitle()

        if not localToolConfig.ForceYes and not self.__AskYesNo("Delete all build directories"):
            return

        packageFilters = localToolConfig.BuildPackageFilters

        buildVariantConfig = BuildVariantConfigUtil.GetBuildVariantConfig(localToolConfig.BuildVariantsDict)
        generator = self.ToolAppContext.PluginConfigContext.GetGeneratorPluginById(localToolConfig.PlatformName, localToolConfig.Generator,
                                                                                   buildVariantConfig, config.ToolConfig.DefaultPackageLanguage,
                                                                                   config.ToolConfig.CMakeConfiguration,
                                                                                   localToolConfig.GetUserCMakeConfig(), False)

        theFiles = MainFlow.DoGetFiles(config, toolConfig.GetMinimalConfig(generator.CMakeConfig), currentDirPath, localToolConfig.Recursive)
        generatorContext = GeneratorContext(config, self.ErrorHelpManager, packageFilters.RecipeFilterManager, config.ToolConfig.Experimental, generator)
        packages = MainFlow.DoGetPackages(generatorContext, config, theFiles, packageFilters, autoAddRecipeExternals=False)

        topLevelPackage = PackageListUtil.GetTopLevelPackage(packages)
        #requestedFiles = None if config.IsSDKBuild else theFiles

        self.Log.LogPrint("Deleting package build directories")
        for package in topLevelPackage.ResolvedBuildOrder:
            if package.AbsoluteBuildPath is not None:
                # While the path is most likely normalized we force it here
                removePath = IOUtil.NormalizePath(package.AbsoluteBuildPath)
                if IOUtil.IsDirectory(removePath):
                    self.Log.LogPrint("- Deleting '{0}'".format(removePath))
                    if IOUtil.IsDriveRootPath(removePath):
                        raise Exception("Invalid path format '{0}'".format(removePath))
                    IOUtil.SafeRemoveDirectoryTree(removePath)