Example #1
0
    def __init__(
            self, package: Package,
            packageGeneratorReport: Optional[PackageGeneratorReport]) -> None:
        super().__init__()
        self.Type = PackageType.ToString(package.Type)
        #self.IsVirtual = package.IsVirtual

        #self.PackageLanguage = PackageLanguage.ToString(package.PackageLanguage)
        if package.CreationYear != PackageCreationYearString.NotDefined and package.CreationYear is not None:
            self.CreationYear = package.CreationYear  # type: str
        #self.CompanyName = package.CompanyName

        # resolved
        #self.PlatformName = package.ResolvedPlatformName

        self.AllRequirements = [
            JsonRequirement(requirement)
            for requirement in package.ResolvedAllRequirements
        ]
        if package.ResolvedPlatformNotSupported:
            self.Supported = not package.ResolvedPlatformNotSupported  # type: bool

        if packageGeneratorReport is not None:
            self.GeneratorReport = JsonPackageGeneratorReport(
                package, packageGeneratorReport)
Example #2
0
    def AddCustomArguments(self, parser: argparse.ArgumentParser,
                           toolConfig: ToolConfig,
                           userTag: Optional[object]) -> None:
        packageTypes = PackageType.AllStrings()
        packageTypes.sort()

        #parser.add_argument('--graph', action='store_true', help='Generate a dependency graph using dot (requires the graphviz dot executable in path)')
        parser.add_argument(
            '--IgnoreNotSupported',
            action='store_true',
            help='try to build things that are marked as not supported')

        parser.add_argument('--ListBuildVariants',
                            action='store_true',
                            help='List all build-variants')
        parser.add_argument('--ListExtensions',
                            action='store_true',
                            help='List all extensions')
        parser.add_argument('--ListFeatures',
                            action='store_true',
                            help='List all features supported by build')
        parser.add_argument('--ListVariants',
                            action='store_true',
                            help='List all used variants')
        parser.add_argument('--ListRecipes',
                            action='store_true',
                            help='List all known recipes')
        parser.add_argument('--ListRequirements',
                            action='store_true',
                            help='List all requirements')

        parser.add_argument('--stats', action='store_true', help='Show stats')

        parser.add_argument('-t',
                            '--type',
                            default=DefaultValue.PackageConfigurationType,
                            choices=[PluginSharedValues.TYPE_DEFAULT, 'sdk'],
                            help='Select generator type')

        parser.add_argument(
            '--SaveJson',
            default=DefaultValue.SaveJson,
            help='Save package information to the given json output file')
        parser.add_argument(
            '--IncludeGeneratorReport',
            action='store_true',
            help=
            'If set we include the generator report if available when saving to json'
        )

        # filtering
        parser.add_argument(
            '--PackageType',
            default=DefaultValue.PackageTypeList,
            help=
            "The list of package types that will be saved [{0}]. For example [Executable] to save all packages of the 'Executable' type."
            .format(', '.join(packageTypes)))
Example #3
0
def ParsePackageTypeList(strPackageTypeList: str) -> List[str]:
    parsedList = ParseList(strPackageTypeList, "packageType", True)
    if not '*' in parsedList:
        validPackageTypes = PackageType.AllStrings()
        for entry in parsedList:
            if entry not in validPackageTypes:
                raise Exception(
                    "The package type list must be valid, the package type '{0}' is not, valid types {1}"
                    .format(entry, validPackageTypes))
    return parsedList
Example #4
0
def SavePackageMetaDataToJson(generatorContext: GeneratorContext,
                              generatorConfig: GeneratorConfig,
                              dstFilePath: str, log: Log,
                              topLevelPackage: Package,
                              packageTypeFilters: List[str],
                              includeGeneratorReport: bool) -> None:
    resolvedBuildOrder = topLevelPackage.ResolvedBuildOrder

    # Raw package type filtering
    if not '*' in packageTypeFilters:
        log.LogPrint(
            "Filtering by PackageType: {0}".format(packageTypeFilters))
        resolvedBuildOrder = [
            package for package in resolvedBuildOrder
            if PackageType.ToString(package.Type) in packageTypeFilters
        ]

    if resolvedBuildOrder is None:
        log.LogPrint(
            "WARNING: No packages left to write to json file '{0}'".format(
                dstFilePath))
        resolvedBuildOrder = []

    generatorReportDict = None if not includeGeneratorReport else generatorContext.Generator.GenerateReport(
        log, generatorConfig, resolvedBuildOrder)

    jsonRootDict = {}  # type: Dict[str, Any]
    jsonRootDict["PlatformName"] = topLevelPackage.ResolvedPlatformName
    jsonRootDict["ResolvedPackageList"] = {
        package.Name: ToJsonPackage(package, generatorReportDict)
        for package in resolvedBuildOrder
    }

    jsonText = str(
        json.dumps(jsonRootDict,
                   ensure_ascii=False,
                   sort_keys=True,
                   indent=2,
                   cls=ComplexEncoder))
    IOUtil.WriteFileIfChanged(dstFilePath, jsonText)
def __ParsePackage(log: Log, packageName: str,
                   jsonPackageDict: Dict[str, object]) -> PackageInfo:
    jsonAllRequirements = jsonPackageDict[JsonPackageKey.AllRequirements]

    if not isinstance(jsonAllRequirements, list):
        raise Exception("Invalid file format")
    allRequirements = __ParseRequirementsInfo(log, jsonAllRequirements)

    strPackageType = __ReadDictStrAttrib(jsonPackageDict, JsonPackageKey.Type)
    packageType = PackageType.FromString(strPackageType)
    supported = __ReadDictBoolAttrib(jsonPackageDict, JsonPackageKey.Supported,
                                     True)

    jsonPackageGeneratorReport = None if JsonPackageKey.GeneratorReport not in jsonPackageDict else jsonPackageDict[
        JsonPackageKey.GeneratorReport]
    generatorReport = None  # type: Optional[PackageGeneratorReportInfo]
    if jsonPackageGeneratorReport is not None:
        if not isinstance(jsonPackageGeneratorReport, dict):
            raise Exception("Invalid file format")
        generatorReport = __ParsePackageGeneratorReport(
            log, packageName, jsonPackageGeneratorReport)

    return PackageInfo(packageName, allRequirements, packageType, supported,
                       generatorReport)