]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/AutoGen/AutoGen.py
Sync BaseTools Trunk (version r2387) to EDKII main trunk.
[mirror_edk2.git] / BaseTools / Source / Python / AutoGen / AutoGen.py
index 8150ea0b69014ca45d2387323f5feb982d715788..2def474b17997bbd00b73ff1ee797267579d3ffc 100644 (file)
@@ -180,16 +180,16 @@ class WorkspaceAutoGen(AutoGen):
             Fvs = []\r
         if Caps is None:\r
             Caps = []\r
-        self.MetaFile       = ActivePlatform.MetaFile\r
+        self.BuildDatabase  = MetaFileDb\r
+        self.MetaFile       = ActivePlatform\r
         self.WorkspaceDir   = WorkspaceDir\r
-        self.Platform       = ActivePlatform\r
+        self.Platform       = self.BuildDatabase[self.MetaFile, 'COMMON', Target, Toolchain]\r
         self.BuildTarget    = Target\r
         self.ToolChain      = Toolchain\r
         self.ArchList       = ArchList\r
         self.SkuId          = SkuId\r
         self.UniFlag        = UniFlag\r
 \r
-        self.BuildDatabase  = MetaFileDb\r
         self.TargetTxt      = BuildConfig\r
         self.ToolDef        = ToolDefinition\r
         self.FdfFile        = FlashDefinitionFile\r
@@ -201,30 +201,74 @@ class WorkspaceAutoGen(AutoGen):
         # there's many relative directory operations, so ...\r
         os.chdir(self.WorkspaceDir)\r
 \r
+        #\r
+        # Merge Arch\r
+        #\r
+        if not self.ArchList:\r
+            ArchList = set(self.Platform.SupArchList)\r
+        else:\r
+            ArchList = set(self.ArchList) & set(self.Platform.SupArchList)\r
+        if not ArchList:\r
+            EdkLogger.error("build", PARAMETER_INVALID,\r
+                            ExtraData = "Invalid ARCH specified. [Valid ARCH: %s]" % (" ".join(self.Platform.SupArchList)))\r
+        elif self.ArchList and len(ArchList) != len(self.ArchList):\r
+            SkippedArchList = set(self.ArchList).symmetric_difference(set(self.Platform.SupArchList))\r
+            EdkLogger.verbose("\nArch [%s] is ignored because the platform supports [%s] only!"\r
+                              % (" ".join(SkippedArchList), " ".join(self.Platform.SupArchList)))\r
+        self.ArchList = tuple(ArchList)\r
+\r
+        # Validate build target\r
+        if self.BuildTarget not in self.Platform.BuildTargets:\r
+            EdkLogger.error("build", PARAMETER_INVALID, \r
+                            ExtraData="Build target [%s] is not supported by the platform. [Valid target: %s]"\r
+                                      % (self.BuildTarget, " ".join(self.Platform.BuildTargets)))\r
+\r
+        # Validate SKU ID\r
+        if not self.SkuId:\r
+            self.SkuId = 'DEFAULT'\r
+\r
+        if self.SkuId not in self.Platform.SkuIds:\r
+            EdkLogger.error("build", PARAMETER_INVALID, \r
+                            ExtraData="SKU-ID [%s] is not supported by the platform. [Valid SKU-ID: %s]"\r
+                                      % (self.SkuId, " ".join(self.Platform.SkuIds.keys())))\r
+\r
         # parse FDF file to get PCDs in it, if any\r
-        if self.FdfFile != None and self.FdfFile != '':\r
-            #\r
-            # Make global macros available when parsing FDF file\r
-            #\r
-            InputMacroDict.update(self.BuildDatabase.WorkspaceDb._GlobalMacros)\r
+        if not self.FdfFile:\r
+            self.FdfFile = self.Platform.FlashDefinition\r
+        EdkLogger.verbose("\nFLASH_DEFINITION = %s" % self.FdfFile)\r
+\r
+        if self.FdfFile:\r
             #\r
             # Mark now build in AutoGen Phase\r
             #\r
-            GlobalData.gAutoGenPhase = True            \r
+            GlobalData.gAutoGenPhase = True    \r
             Fdf = FdfParser(self.FdfFile.Path)\r
             Fdf.ParseFile()\r
-            GlobalData.gAutoGenPhase = False  \r
+            GlobalData.gAutoGenPhase = False\r
             PcdSet = Fdf.Profile.PcdDict\r
             ModuleList = Fdf.Profile.InfList\r
             self.FdfProfile = Fdf.Profile\r
+            for fvname in self.FvTargetList:\r
+                if fvname.upper() not in self.FdfProfile.FvDict:\r
+                    EdkLogger.error("build", OPTION_VALUE_INVALID,\r
+                                    "No such an FV in FDF file: %s" % fvname)\r
         else:\r
             PcdSet = {}\r
             ModuleList = []\r
             self.FdfProfile = None\r
+            if self.FdTargetList:\r
+                EdkLogger.info("No flash definition file found. FD [%s] will be ignored." % " ".join(self.FdTargetList))\r
+                self.FdTargetList = []\r
+            if self.FvTargetList:\r
+                EdkLogger.info("No flash definition file found. FV [%s] will be ignored." % " ".join(self.FvTargetList))\r
+                self.FvTargetList = []\r
+            if self.CapTargetList:\r
+                EdkLogger.info("No flash definition file found. Capsule [%s] will be ignored." % " ".join(self.CapTargetList))\r
+                self.CapTargetList = []\r
         \r
         # apply SKU and inject PCDs from Flash Definition file\r
         for Arch in self.ArchList:\r
-            Platform = self.BuildDatabase[self.MetaFile, Arch]\r
+            Platform = self.BuildDatabase[self.MetaFile, Arch, Target, Toolchain]\r
             Platform.SkuName = self.SkuId\r
             for Name, Guid in PcdSet:\r
                 Platform.AddPcd(Name, Guid, PcdSet[Name, Guid])\r
@@ -971,7 +1015,7 @@ class PlatformAutoGen(AutoGen):
     ## Return the platform build data object\r
     def _GetPlatform(self):\r
         if self._Platform == None:\r
-            self._Platform = self.BuildDatabase[self.MetaFile, self.Arch]\r
+            self._Platform = self.BuildDatabase[self.MetaFile, self.Arch, self.BuildTarget, self.ToolChain]\r
         return self._Platform\r
 \r
     ## Return platform name\r
@@ -1309,7 +1353,7 @@ class PlatformAutoGen(AutoGen):
                                             File=self.MetaFile,\r
                                             ExtraData="in [%s] [%s]\n\tconsumed by module [%s]" % (str(M), self.Arch, str(Module)))\r
 \r
-                    LibraryModule = self.BuildDatabase[LibraryPath, self.Arch]\r
+                    LibraryModule = self.BuildDatabase[LibraryPath, self.Arch, self.BuildTarget, self.ToolChain]\r
                     # for those forced library instance (NULL library), add a fake library class\r
                     if LibraryClassName.startswith("NULL"):\r
                         LibraryModule.LibraryClass.append(LibraryClassObject(LibraryClassName, [ModuleType]))\r
@@ -1907,6 +1951,7 @@ class ModuleAutoGen(AutoGen):
             self._Macro["ARCH"                  ] = self.Arch\r
             self._Macro["TOOLCHAIN"             ] = self.ToolChain\r
             self._Macro["TOOLCHAIN_TAG"         ] = self.ToolChain\r
+            self._Macro["TOOL_CHAIN_TAG"        ] = self.ToolChain\r
             self._Macro["TARGET"                ] = self.BuildTarget\r
 \r
             self._Macro["BUILD_DIR"             ] = self.PlatformInfo.BuildDir\r
@@ -1920,7 +1965,7 @@ class ModuleAutoGen(AutoGen):
     ## Return the module build data object\r
     def _GetModule(self):\r
         if self._Module == None:\r
-            self._Module = self.Workspace.BuildDatabase[self.MetaFile, self.Arch]\r
+            self._Module = self.Workspace.BuildDatabase[self.MetaFile, self.Arch, self.BuildTarget, self.ToolChain]\r
         return self._Module\r
 \r
     ## Return the module name\r
@@ -2279,7 +2324,7 @@ class ModuleAutoGen(AutoGen):
             if File.IsBinary and File == Source and self._BinaryFileList != None and File in self._BinaryFileList:\r
                 # Skip all files that are not binary libraries\r
                 if not self.IsLibrary:\r
-                    continue\r
+                    continue            \r
                 RuleObject = self.BuildRules[TAB_DEFAULT_BINARY_FILE]\r
             elif FileType in self.BuildRules:\r
                 RuleObject = self.BuildRules[FileType]\r
@@ -2672,7 +2717,7 @@ class ModuleAutoGen(AutoGen):
             DpxFile = gAutoGenDepexFileName % {"module_name" : self.Name}\r
 \r
             if len(Dpx.PostfixNotation) <> 0:\r
-              self.DepexGenerated = True\r
+                self.DepexGenerated = True\r
 \r
             if Dpx.Generate(path.join(self.OutputDir, DpxFile)):\r
                 AutoGenList.append(str(DpxFile))\r