コード例 #1
0
    def __init__(self, filename: str, strPackageName: Optional[str],
                 packageLocation: ToolConfigPackageLocation) -> None:
        super(PackageFile, self).__init__()

        if not IOUtil.IsAbsolutePath(filename):
            raise UsageErrorException()

        if not isinstance(packageLocation, ToolConfigPackageLocation):
            raise UsageErrorException()

        filename = IOUtil.NormalizePath(filename)
        if not filename.startswith(packageLocation.ResolvedPathEx):
            raise UsageErrorException(
                "The filename '{0}' does not belong to the supplied location '{1}'"
                .format(filename, packageLocation.ResolvedPathEx))

        self.Filename = IOUtil.GetFileName(filename)
        self.RelativeFilePath = filename[
            len(packageLocation.ResolvedPathEx
                ):]  # The full relative path to the file
        self.RelativeDirPath = IOUtil.GetDirectoryName(
            self.RelativeFilePath)  # The relative containing directory
        self.AbsoluteFilePath = filename  # type: str
        self.AbsoluteDirPath = IOUtil.GetDirectoryName(filename)  # type: str
        self.PackageRootLocation = packageLocation  # type: ToolConfigPackageLocation
        self.PackageName = self.__DeterminePackageNameFromRelativeName(
            self.RelativeDirPath
        ) if strPackageName is None else strPackageName  # type: str
コード例 #2
0
 def __GetGenerator(self, pluginId: str, generatorType: GeneratorType,
                    allowAll: bool) -> GeneratorPlugin:
     pluginId = pluginId.lower()
     generatorPluginDict = self.__GeneratorPluginDict
     if not pluginId in generatorPluginDict:
         raise UsageErrorException(
             "Unknown platform: '{0}'".format(pluginId))
     if pluginId == PluginSharedValues.PLATFORM_ID_ALL and not allowAll:
         raise UsageErrorException(
             "Platform '{0}' is not allowed".format(pluginId))
     if generatorType == GeneratorType.CMake:
         platformName = generatorPluginDict[pluginId].PlatformName
         return GeneratorPluginCMakeBase(platformName)
     elif generatorType == GeneratorType.Legacy:
         platformName = generatorPluginDict[pluginId].PlatformName
         if platformName == PlatformNameString.UBUNTU:
             legacyUbuntuGenerator = GeneratorPluginUbuntuLegacy()
             return legacyUbuntuGenerator
         elif platformName == PlatformNameString.YOCTO:
             legacyYoctoGenerator = GeneratorPluginYoctoLegacy()
             return legacyYoctoGenerator
         elif platformName == PlatformNameString.QNX:
             legacyQnxGenerator = GeneratorPluginQNXLegacy()
             return legacyQnxGenerator
     return generatorPluginDict[pluginId]
コード例 #3
0
    def __ResolvePaths(self, config: Config, filename: str,
                       allowNoInclude: bool) -> None:
        if not os.path.isabs(filename):
            raise UsageErrorException()

        self.AbsolutePath = IOUtil.GetDirectoryName(filename)
        if not self.IsVirtual:
            sourcePath = self.BaseSourcePath
            if self.PackageLanguage == PackageLanguage.CPP:
                self.__ResolvePathIncludeDir(config, allowNoInclude)
            elif self.PackageLanguage == PackageLanguage.CSharp:
                #sourcePath = self.Name
                pass
            else:
                raise UnsupportedException(
                    "Unsupported package language: {0}".format(
                        self.PackageLanguage))
            self.AbsoluteSourcePath = IOUtil.Join(self.AbsolutePath,
                                                  sourcePath)
            self.AbsoluteContentPath = IOUtil.Join(self.AbsolutePath,
                                                   "Content")
            self.AbsoluteContentSourcePath = IOUtil.Join(
                self.AbsolutePath, "Content.bld")
            if not os.path.isdir(self.AbsoluteSourcePath
                                 ) and not config.DisableSourceDirCheck:
                raise PackageMissingRequiredSourceDirectoryException(
                    self.AbsoluteSourcePath)
        elif self.Type == PackageType.HeaderLibrary:
            if self.PackageLanguage == PackageLanguage.CPP:
                self.__ResolvePathIncludeDir(config, allowNoInclude)
            else:
                raise UsageErrorException(
                    "HeaderLibrary is only supported for C++")
コード例 #4
0
def GetGeneratorPluginById(pluginId: str, allowAll: bool) -> GeneratorPlugin:
    pluginId = pluginId.lower()
    if not pluginId in __g_generatorPluginDict:
        raise UsageErrorException("Unknown platform: '{0}'".format(pluginId))
    if pluginId == PluginSharedValues.PLATFORM_ID_ALL and not allowAll:
        raise UsageErrorException(
            "Platform '{0}' is not allowed".format(pluginId))
    return __g_generatorPluginDict[pluginId]
コード例 #5
0
 def GetCircularDependencyString(self,
                                 srcList: List[DependencyGraphNode]) -> str:
     if srcList is None or len(srcList) < 1:
         raise UsageErrorException(
             "No circular dependency exist in the supplied list")
     try:
         index = srcList.index(srcList[-1])
         return self.GetNameListString(srcList[index:], "->")
     except ValueError:
         raise UsageErrorException(
             "No circular dependency exist in the supplied list")
コード例 #6
0
 def GetCircularDependencyString(self,
                                 srcList: List[DependencyGraphNode]) -> str:
     if srcList is None or len(srcList) < 1:
         raise UsageErrorException(
             "No circular dependency exist in the supplied list")
     try:
         # Since the last element is where the circular dependency is detected
         # we need to find the first occurrance of the last element
         index = srcList.index(srcList[-1])
         return self.GetNameListString(srcList[index:], "->")
     except ValueError:
         raise UsageErrorException(
             "No circular dependency exist in the supplied list")
コード例 #7
0
 def ToPath(rootDirectories: List[ToolConfigRootDirectory], path: str) -> str:
     """
     convert to a path that we know reside in one of the package roots
     """
     if path.find("\\") >= 0:
         raise UsageErrorException("Backslash found in the supplied path '{0}'".format(path))
     for rootDir in rootDirectories:
         if path.startswith(rootDir.ResolvedPathEx):
             lenRootPath = len(rootDir.ResolvedPathEx)
             path = path[lenRootPath:]
             return rootDir.Name + "/" + Util.UTF8ToAscii(path)
         elif path == rootDir.ResolvedPath:
             return rootDir.Name + "/"
     raise UsageErrorException("the folder '{0}' does not reside inside one of the root dirs".format(path))
コード例 #8
0
 def ToBashPath(self, path: str) -> str:
     if path.find("\\") >= 0:
         raise UsageErrorException(
             "Backslash found in the supplied path '{0}'".format(path))
     for rootDir in self.RootDirectories:
         if path.startswith(rootDir.ResolvedPathEx):
             lenRootPath = len(rootDir.ResolvedPathEx)
             path = path[lenRootPath:]
             return rootDir.BashName + "/" + Util.UTF8ToAscii(path)
         elif path == rootDir.ResolvedPath:
             return rootDir.Name + "/"
     raise UsageErrorException(
         "the folder '{0}' does not reside inside one of the root dirs".
         format(path))
コード例 #9
0
 def __GetGenerator(self, pluginId: str,
                    defaultPackageLanguage: PackageLanguage,
                    generatorType: GeneratorType) -> GeneratorPlugin:
     pluginId = pluginId.lower()
     generatorPluginDict = self.__GeneratorPluginDict
     if not pluginId in generatorPluginDict:
         raise UsageErrorException(
             "Unknown platform: '{0}'".format(pluginId))
     if generatorType == GeneratorType.CMake:
         platformName = generatorPluginDict[pluginId].PlatformName
         return GeneratorPluginCMakeBase(self.__Log, platformName)
     elif generatorType == GeneratorType.Legacy:
         platformName = generatorPluginDict[pluginId].PlatformName
         if platformName == PlatformNameString.UBUNTU:
             legacyUbuntuGenerator = GeneratorPluginUbuntuLegacy(self.__Log)
             return legacyUbuntuGenerator
         elif platformName == PlatformNameString.YOCTO:
             legacyYoctoGenerator = GeneratorPluginYoctoLegacy(self.__Log)
             return legacyYoctoGenerator
         elif platformName == PlatformNameString.WINDOWS:
             return GeneratorPluginWindowsLegacy(self.__Log)
     elif defaultPackageLanguage == PackageLanguage.CSharp:
         platformName = generatorPluginDict[pluginId].PlatformName
         if platformName == PlatformNameString.WINDOWS:
             return GeneratorPluginWindowsLegacy(self.__Log)
     return generatorPluginDict[pluginId]
コード例 #10
0
 def ToDosPathDirectConversion(self, path: str) -> str:
     """ This does not make the path relative to a root path """
     if path.find("\\") >= 0:
         raise UsageErrorException(
             "Backslash found in the supplied path '{0}'".format(path))
     path = Util.ChangeToDosEnvironmentVariables(path)
     return Util.UTF8ToAscii(path).replace('/', '\\')
コード例 #11
0
    def __ResolvePaths(self, configDisableIncludeDirCheck: bool, configDisableSourceDirCheck: bool, packagePath: PackagePath,
                       allowNoInclude: bool) -> None:

        rootRelativeDirPath = packagePath.RootRelativeDirPath
        if not self.IsVirtual:
            sourcePath = self.BaseSourcePath
            if self.PackageLanguage == PackageLanguage.CPP:
                self.__ResolvePathIncludeDir(configDisableIncludeDirCheck, allowNoInclude)
            elif self.PackageLanguage == PackageLanguage.CSharp:
                #sourcePath = self.Name
                pass
            else:
                raise UnsupportedException("Unsupported package language: {0}".format(self.PackageLanguage))
            self.SourcePath = PackagePath(IOUtil.Join(rootRelativeDirPath, sourcePath), packagePath.PackageRootLocation)

            self.ContentPath = PackagePath(IOUtil.Join(rootRelativeDirPath, ToolSharedValues.CONTENT_FOLDER_NAME), packagePath.PackageRootLocation)
            self.ContentSourcePath = PackagePath(IOUtil.Join(rootRelativeDirPath, ToolSharedValues.CONTENT_BUILD_FOLDER_NAME), packagePath.PackageRootLocation)

            if not os.path.isdir(self.SourcePath.AbsoluteDirPath) and not configDisableSourceDirCheck:
                raise PackageMissingRequiredSourceDirectoryException(self.SourcePath.AbsoluteDirPath)
        elif self.Type == PackageType.HeaderLibrary:
            if self.PackageLanguage == PackageLanguage.CPP:
                self.__ResolvePathIncludeDir(configDisableIncludeDirCheck, allowNoInclude)
            else:
                raise UsageErrorException("HeaderLibrary is only supported for C++")
コード例 #12
0
def DoGetFiles(config: Config,
               toolMiniConfig: ToolMinimalConfig,
               currentDir: str,
               allowRecursiveScan: bool = False) -> List[str]:
    """
    :param currentDir: currentDir must be part of a package root
    :param allowRecursiveScan: if True and not a sdk build all subdirectories will be scanned
    """
    if allowRecursiveScan and config.IsSDKBuild:
        config.DoPrintWarning("recursive is ignored for sdk builds")

    if ToolConfigPackageRootUtil.TryFindRootDirectory(
            toolMiniConfig.RootDirectories, currentDir) is None:
        raise UsageErrorException(
            "the folder '{0}' does not reside inside one of the root dirs".
            format(currentDir))

    theFiles = []  # type: List[str]
    if not config.IsSDKBuild:
        if allowRecursiveScan:
            theFiles += IOUtil.FindFileByName(currentDir, config.GenFileName,
                                              toolMiniConfig.IgnoreDirectories)
        else:
            theFile = IOUtil.Join(currentDir, config.GenFileName)
            if not os.path.isfile(theFile):
                raise Exception("File not found: '{0}'".format(theFile))
            theFiles.append(theFile)
    return theFiles
コード例 #13
0
 def FindProjectContext(contexts: List[ToolConfigProjectContext],
                        path: str) -> ToolConfigProjectContext:
     context = ToolConfigPackageProjectContextUtil.TryFindToProjectContext(
         contexts, path)
     if context is None:
         raise UsageErrorException(
             "Could not locate a context for path '{0}'".format(path))
     return context
コード例 #14
0
 def __init__(self, log: Log, xmlElement: ET.Element, subPackageSupport: SubPackageSupportConfig) -> None:
     if not isinstance(subPackageSupport, SubPackageSupportConfig):
         raise UsageErrorException("The support object was not of the correct type")
     super().__init__(log, xmlElement)
     self.SystemSubPackageSupport = subPackageSupport  # type: SubPackageSupportConfig
     self.ExternalDependencies = self.__GetXMLExternalDependencies(xmlElement)
     self.DirectDefines = self.__GetXMLDefines(xmlElement)
     self.DirectDependencies = self._GetXMLDependencies(xmlElement)
コード例 #15
0
 def AddNodeAndEdges(self, package: Package) -> None:
     if not package in self.UniqueNodeDict:
         newNode = DependencyGraphNode(package)
         for dep in package.ResolvedDirectDependencies:
             if not dep.Package in self.UniqueNodeDict:
                 raise UsageErrorException(
                     "Unknown dependency to: '{0}'".format(dep.Name))
             newNode.AddEdge(self.UniqueNodeDict[dep.Package])
         self.UniqueNodeDict[package] = newNode
         self.Nodes.append(newNode)
コード例 #16
0
    def __init__(self, path: str, location: ToolConfigPackageLocation) -> None:
        super().__init__()

        if not isinstance(location, ToolConfigPackageLocation):
            raise UsageErrorException(
                "the supplied location was not of the type ToolConfigPackageLocation"
            )

        self.Path = path
        self.Location = location
コード例 #17
0
 def ToPath(rootDirectories: List[ToolConfigRootDirectory],
            path: str) -> str:
     """
     convert to a path that we know reside in one of the package roots
     """
     foundPath = ToolConfigPackageRootUtil.TryToPath(rootDirectories, path)
     if foundPath is not None:
         return foundPath
     raise UsageErrorException(
         "the folder '{0}' does not reside inside one of the root dirs".
         format(path))
コード例 #18
0
    def __init__(self, path: str, packageLocation: ToolConfigPackageLocation, normalize: bool = True) -> None:
        super().__init__()

        path = IOUtil.NormalizePath(path) if normalize else path

        if not isinstance(packageLocation, ToolConfigPackageLocation):
            raise UsageErrorException()


        if IOUtil.IsAbsolutePath(path):
            if not path.startswith(packageLocation.ResolvedPathEx):
                raise UsageErrorException("The path '{0}' does not belong to the supplied location '{1}'".format(path, packageLocation.ResolvedPathEx))
            rootRelativeDirPath = path[len(packageLocation.ResolvedPathEx):]
            absoluteDirPath = path
        else:
            rootRelativeDirPath = path
            absoluteDirPath = IOUtil.Join(packageLocation.ResolvedPath, path)

        self.RootRelativeDirPath = rootRelativeDirPath  # The root relative containing directory
        self.AbsoluteDirPath = absoluteDirPath          # type: str
        self.PackageRootLocation = packageLocation      # type: ToolConfigPackageLocation
コード例 #19
0
 def CreatePackage(self, config: Config, platformName: str, genFile: XmlGenFile, insertAtFront: bool = False) -> Package:
     if genFile.Name in self.OriginalPackageDict:
         raise UsageErrorException("Package '{0}' already exist".format(genFile.Name))
     packageProjectContext = self.__FindProjectContext(config, genFile)
     package = self.__PackageFactoryFunction(config, self.__GeneratorInfo, genFile, packageProjectContext)
     self.__ResolvePackageDependencies(platformName, package)
     if not insertAtFront:
         self.Packages.append(package)
     else:
         self.Packages.insert(0, package)
     self.OriginalPackageDict[package.Name] = package
     return package
コード例 #20
0
def GetGeneratorPluginById(
        pluginId: str, generatorType: int, allowAll: bool,
        cmakeConfiguration: CMakeConfiguration,
        userCMakeConfig: Optional[UserCMakeConfig]) -> GeneratorPlugin:
    pluginId = pluginId.lower()
    if not pluginId in __g_generatorPluginDict:
        raise UsageErrorException("Unknown platform: '{0}'".format(pluginId))
    if pluginId == PluginSharedValues.PLATFORM_ID_ALL and not allowAll:
        raise UsageErrorException(
            "Platform '{0}' is not allowed".format(pluginId))
    if generatorType == GeneratorType.CMake:
        platformName = __g_generatorPluginDict[pluginId].PlatformName
        cmakeGenerator = GeneratorPluginCMakeBase(platformName)
        cmakeGenerator.DotEnabled = __g_globalContext.DotEnabled
        cmakeGenerator.ToolVersion = __g_globalContext.VSVersion
        cmakeGenerator.CMakeConfig = CMakeConfigUtil.BuildGeneratorCMakeConfig(
            platformName, userCMakeConfig, cmakeConfiguration,
            cmakeGenerator.ToolVersion)
        cmakeGenerator.SetLegacyGeneratorType(
            __g_globalContext.LegacyGeneratorType)
        return cmakeGenerator
    return __g_generatorPluginDict[pluginId]
コード例 #21
0
ファイル: Filter.py プロジェクト: yancc02/gtec-demo-framework
    def GetRequirementList(topLevelPackage: Package,
                           requestedPackages: Optional[List[Package]],
                           requirementType: Optional[str] = None) -> List[PackageRequirement]:
        """ Generate a requirement list based on input, the requirement list can be optionally filtered by requirementType.
            If requestedPackages are None then then all packages used by the top level package will be filtered.
            If a top level package is supplied then we return the 'ResolvedAllRequirements' for it (filtered as requested).
        """
        if topLevelPackage is None:
            raise UsageErrorException("topLevelPackage can not be None")

        if requestedPackages is None or len(requestedPackages) <= 0:
            # Since no files were supplied we use the topLevelPackage
            return RequirementFilter.FilterRequirementsByType(topLevelPackage.ResolvedAllRequirements, requirementType)
        return RequirementFilter.GetRequirementListFromPackages(requestedPackages, requirementType)
コード例 #22
0
    def __init__(self, filename: str, strPackageName: Optional[str],
                 packageLocation: ToolConfigPackageLocation) -> None:
        filename = IOUtil.NormalizePath(filename)
        if not IOUtil.IsAbsolutePath(filename):
            raise UsageErrorException()

        rootRelativePath = filename[len(packageLocation.ResolvedPathEx):]
        super().__init__(IOUtil.GetDirectoryName(rootRelativePath),
                         packageLocation, False)

        self.Filename = IOUtil.GetFileName(filename)
        self.RootRelativeFilePath = rootRelativePath  # The full root relative path to the file
        self.AbsoluteFilePath = filename  # type: str
        self.PackageName = self.__DeterminePackageNameFromRelativeName(
            self.RootRelativeDirPath
        ) if strPackageName is None else strPackageName  # type: str
コード例 #23
0
 def __FindProjectContext(self, config: Config, genFile: XmlGenFile) -> PackageProjectContext:
     """
     Associate the package with the 'project' that it belongs to
     """
     if genFile.PackageLocation is None:
         if genFile.Type != PackageType.TopLevel:
             raise UsageErrorException("Package '{0}' did not contain a valid location".format(genFile.Name))
         # The top level package is not associated with a project context
         topLevelProjectContext = PackageProjectContext(ProjectId("__TopLevel__"), "__TopLevel__", "0.0.0.0", [])
         self.__ProjectContextCache.Add(topLevelProjectContext)
         return topLevelProjectContext
     projectContext = ToolConfigPackageProjectContextUtil.FindProjectContext(config.ToolConfig.ProjectInfo.Contexts, genFile.PackageLocation.ResolvedPath)
     basePackages = self.__CreateBasePackageList(projectContext.BasePackages)
     packageProjectContext = self.__ProjectContextCache.TryGet(projectContext.ProjectName)
     if packageProjectContext is None:
         packageProjectContext = PackageProjectContext(projectContext.ProjectId, projectContext.ProjectName, projectContext.ProjectVersion, basePackages)
         self.__ProjectContextCache.Add(packageProjectContext)
     return packageProjectContext
コード例 #24
0
    def Extend(self, variant: 'PackagePlatformVariant',
               extendingPackageName: str) -> 'PackagePlatformVariant':
        if not variant.AllowExtend:
            raise VariantNotMarkedAsExtendingException(self, variant)

        extendedVariant = PackagePlatformVariant(extendingPackageName, self,
                                                 False)
        extendedVariant.ExtensionInfo = "{0}<-{1}".format(
            self.IntroducedByPackageName, extendingPackageName)

        dstOptions = extendedVariant.Options
        srcOptions = variant.Options
        for entry in srcOptions:
            index = self.__IndexOf(dstOptions, entry.Name)
            if index >= 0:
                dstOptions[index] = dstOptions[index].Extend(
                    entry, extendingPackageName)
            else:
                raise UsageErrorException(
                    "A extending variant can not introduce new options")
        extendedVariant.__BuildOptionDict(dstOptions)
        return extendedVariant
コード例 #25
0
    def CreatePackage(self, log: Log, configBuildDir: str, configIgnoreNotSupported: bool, toolConfig: ToolConfig,
                      platformName: str, hostPlatformName: str, genFile: XmlGenFile, insertAtFront: bool = False) -> Package:

        filePackageInstanceName = PackageInstanceName(genFile.Name)
        if filePackageInstanceName in self.OriginalPackageDict:
            raise UsageErrorException("Package '{0}' already exist".format(filePackageInstanceName))

        createContext = PackageManager.__CreateFactoryCreateContext(log, toolConfig, self.__GeneratorInfo)
        packageProjectContext = self.__FindProjectContext(toolConfig, genFile)
        processedPackage = PackageManager.__AllocatePreprocessedPackage(createContext, packageProjectContext, configIgnoreNotSupported, platformName,
                                                                        hostPlatformName, genFile, True)
        packageLookupDict = PreResolver.CreatePackageLookupDict(self.__unresolvedPackages)
        preResolvedPackageResult = PreResolver.PreResolvePackage(log, packageLookupDict, processedPackage, 0xffffffff)
        package = Package(log, configBuildDir, preResolvedPackageResult)

        self.__ResolvePackageDependencies(package, self.OriginalPackageDict)
        if not insertAtFront:
            self.Packages.append(package)
        else:
            self.Packages.insert(0, package)
        self.OriginalPackageDict[package.NameInfo.FullName] = package
        return package