示例#1
0
 def __init__(self, config: Config, defaultPackageLanguage: int) -> None:
     super().__init__(
         config,
         FakeXmlElementFactory.CreateWithName(
             "FakeGenFile", "FSLBUILD_INVALID_INITIAL_VALUE"),
         SubPackageSupportConfig(PackageType.TopLevel,
                                 SubPackageSupport.Disabled))
     self.SourceFilename = None  # type: Optional[str]
     self.SourceFileHash = ""  # type: str
     self.Name = ''
     self.ShortName = None  # type: Optional[str]
     self.Namespace = None  # type: Optional[str]
     self.PackageFile = None  # type: Optional[PackageFile]
     self.PackageLocation = None  # type: Optional[ToolConfigPackageLocation]
     self.Type = PackageType.Library
     self.IsVirtual = False
     self.DirectDependencies = []  # type: List[XmlGenFileDependency]
     self.DirectRequirements = []  # type: List[XmlGenFileRequirement]
     self.DirectDefines = []
     self.DirectExperimentalRecipe = None  # type: Optional[XmlExperimentalRecipe]
     self.Platforms = {}  # type: Dict[str, XmlGenFilePlatform]
     self.IncludePath = None  # type: Optional[PackagePath]
     self.SourcePath = None  # type: Optional[PackagePath]
     self.ContentPath = None  # type: Optional[PackagePath]
     self.ContentSourcePath = None  # type: Optional[PackagePath]
     self.PackageLanguage = defaultPackageLanguage
     self.BaseIncludePath = "include"
     self.BaseSourcePath = "source"
     self.BuildCustomization = {
     }  # type: Dict[str, XmlGenFileBuildCustomization]
     self.CompanyName = "NotDefined"
     self.CreationYear = None  # type: Optional[str]
     self.TemplateType = ""
     self.AllowCheck = True
     self.EnableExtendedSourceExtensions = False
     self.AllowCombinedDirectory = False
     self.PackageNameBasedIncludePath = True
     self.PlatformDefaultSupportedValue = True
     self.SystemDefaultValues = LocalPackageDefaultValues()
     self.UnitTest = False
     self.ShowInMainReadme = True
示例#2
0
    def Load(self, config: Config,
             packageTemplateLoader: PackageTemplateLoader,
             packageFile: PackageFile) -> None:
        filename = packageFile.AbsoluteFilePath
        if not os.path.isfile(filename):
            raise FileNotFoundException("Could not locate gen file %s",
                                        filename)

        self.SourceFilename = filename
        self.PackageLocation = packageFile.PackageRootLocation

        fileContent = IOUtil.ReadFile(filename)
        self.SourceFileHash = self.__CalcContentHash(fileContent)
        elem = ET.fromstring(fileContent)
        if elem.tag != 'FslBuildGen':
            raise XmlInvalidRootElement(
                "The file did not contain the expected root tag 'FslBuildGen'")

        elem, theType = self.__FindPackageElementAndType(elem)

        packageName = self._ReadAttrib(elem, 'Name')
        defaultValues = self.__GetDefaultValues(elem, packageName)
        allowNoInclude = self._ReadBoolAttrib(elem, 'NoInclude', False)
        companyName = self._ReadAttrib(elem, 'Company',
                                       config.ToolConfig.DefaultCompany)

        if config.ToolConfig.RequirePackageCreationYear:
            creationYear = self._ReadAttrib(elem, 'CreationYear')
        else:
            creationYear = self._ReadAttrib(
                elem, 'CreationYear', PackageCreationYearString.NotDefined)

        templateType = self._ReadAttrib(elem, 'TemplateType', "")
        self.AllowCheck = self._ReadBoolAttrib(elem, 'AllowCheck', True)
        # if this is set we allow '.cc' files for C++ code.
        self.EnableExtendedSourceExtensions = self._ReadBoolAttrib(
            elem, 'EnableExtendedSourceExtensions', False)

        self.BaseIncludePath = self._ReadAttrib(elem, 'OverrideInclude',
                                                'include')
        self.BaseSourcePath = self._ReadAttrib(elem, 'OverrideSource',
                                               'source')
        self.AllowCombinedDirectory = self._ReadBoolAttrib(
            elem, 'AllowCombinedDirectory', False)
        self.PackageNameBasedIncludePath = self._ReadBoolAttrib(
            elem, 'PackageNameBasedIncludePath', True)

        self.BaseLoad(
            elem, SubPackageSupportConfig(theType, config.SubPackageSupport))

        requirements = self._GetXMLRequirements(elem)
        allowRecipes = self.__DoesTypeAllowRecipes(theType)

        # Add recipe and dependencies
        self.DirectExperimentalRecipe = self._TryGetExperimentalRecipe(
            elem, packageName, allowRecipes)
        if self.DirectExperimentalRecipe is not None:
            self.DirectDependencies += self.__AddExperimentalRecipeDependencies(
                self.DirectDependencies, [], self.DirectExperimentalRecipe)

        platforms = self.__GetXMLPlatforms(elem, packageName,
                                           self.DirectDependencies,
                                           allowRecipes, defaultValues)
        self.BuildCustomization = self.__GetBuildCustomizations(
            elem, packageName)

        templates = self.__GetXMLImportTemplates(elem)
        self.__ImportTemplates(packageTemplateLoader, templates, requirements,
                               self.DirectDependencies,
                               self.ExternalDependencies, self.DirectDefines)

        if self.BaseIncludePath == self.BaseSourcePath and not self.AllowCombinedDirectory:
            raise XmlException2(
                elem,
                "Package '{0}' uses the same directory for include and source '{1}'"
                .format(packageName, self.BaseIncludePath))

        self.SourcePackageFile = packageFile
        self.XMLElement = elem
        self.Name = packageName
        self.ShortName = None
        self.Namespace = None
        self.SetType(theType)
        self.Platforms = platforms
        self.DirectRequirements = requirements
        self.AbsolutePath = None
        self.AbsoluteIncludePath = None
        self.AbsoluteSourcePath = None
        self.CompanyName = companyName
        self.CreationYear = creationYear
        self.TemplateType = templateType
        self.PlatformDefaultSupportedValue = defaultValues.Platform_Supported
        self.SystemDefaultValues = defaultValues

        self._ValidateName(elem, self.Name)
        # This check was moved to the package loader where it belongs
        #self.__ValidateFilename(config, filename)
        self.__ResolveNames(self.Name)
        self.__ValidateBasicDependencyCorrectness()
        self.__ValidateDefines()
        self.__ResolvePaths(config, filename, allowNoInclude)