]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/Workspace/WorkspaceDatabase.py
BaseTools/build: Expand PREBUILD/POSTBUILD DSC actions
[mirror_edk2.git] / BaseTools / Source / Python / Workspace / WorkspaceDatabase.py
index 2e6c68e33aaef2a1961c1a02b4589f9d61c88ba8..fe2c7c17c4699b3d03ad6202f39b2744411c7a43 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # This file is used to create a database used by build tool\r
 #\r
-# Copyright (c) 2008 - 2016, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2008 - 2017, Intel Corporation. All rights reserved.<BR>\r
 # (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
@@ -231,9 +231,21 @@ class DscBuildData(PlatformBuildClassObject):
                     EdkLogger.error('build', ErrorCode, File=self.MetaFile, Line=Record[-1],\r
                                     ExtraData=ErrorInfo)\r
             elif Name == TAB_DSC_PREBUILD:\r
-                self._Prebuild = PathClass(NormPath(Record[2], self._Macros), GlobalData.gWorkspace)\r
+                PrebuildValue = Record[2]\r
+                if Record[2][0] == '"':\r
+                    if Record[2][-1] != '"':\r
+                        EdkLogger.error('build', FORMAT_INVALID, 'Missing double quotes in the end of %s statement.' % TAB_DSC_PREBUILD,\r
+                                    File=self.MetaFile, Line=Record[-1])\r
+                    PrebuildValue = Record[2][1:-1]\r
+                self._Prebuild = PrebuildValue\r
             elif Name == TAB_DSC_POSTBUILD:\r
-                self._Postbuild = PathClass(NormPath(Record[2], self._Macros), GlobalData.gWorkspace)\r
+                PostbuildValue = Record[2]\r
+                if Record[2][0] == '"':\r
+                    if Record[2][-1] != '"':\r
+                        EdkLogger.error('build', FORMAT_INVALID, 'Missing double quotes in the end of %s statement.' % TAB_DSC_POSTBUILD,\r
+                                    File=self.MetaFile, Line=Record[-1])\r
+                    PostbuildValue = Record[2][1:-1]\r
+                self._Postbuild = PostbuildValue\r
             elif Name == TAB_DSC_DEFINES_SUPPORTED_ARCHITECTURES:\r
                 self._SupArchList = GetSplitValueList(Record[2], TAB_VALUE_SPLIT)\r
             elif Name == TAB_DSC_DEFINES_BUILD_TARGETS:\r
@@ -545,12 +557,6 @@ class DscBuildData(PlatformBuildClassObject):
         for Record in RecordList:\r
             DuplicatedFile = False\r
 \r
-            # process only records COMMON and self.Arch\r
-            SectionArch = Record[3].upper()\r
-            if SectionArch != 'COMMON':\r
-                if SectionArch != self.Arch:\r
-                    continue\r
-\r
             ModuleFile = PathClass(NormPath(Record[0], Macros), GlobalData.gWorkspace, Arch=self._Arch)\r
             ModuleId = Record[5]\r
             LineNo = Record[6]\r
@@ -808,9 +814,10 @@ class DscBuildData(PlatformBuildClassObject):
             options = sdict()\r
             self._ModuleTypeOptions[Edk, ModuleType] = options\r
             DriverType = '%s.%s' % (Edk, ModuleType)\r
+            CommonDriverType = '%s.%s' % ('COMMON', ModuleType)\r
             RecordList = self._RawData[MODEL_META_DATA_BUILD_OPTION, self._Arch, DriverType]\r
             for ToolChainFamily, ToolChain, Option, Arch, Type, Dummy3, Dummy4 in RecordList:\r
-                if Type == DriverType:\r
+                if Type == DriverType or Type == CommonDriverType:\r
                     Key = (ToolChainFamily, ToolChain, Edk)\r
                     if Key not in options or not ToolChain.endswith('_FLAGS') or Option.startswith('='):\r
                         options[Key] = Option\r
@@ -1334,6 +1341,10 @@ class DecBuildData(PackageBuildClassObject):
         self._LibraryClasses    = None\r
         self._Pcds              = None\r
         self.__Macros           = None\r
+        self._PrivateProtocols  = None\r
+        self._PrivatePpis       = None\r
+        self._PrivateGuids      = None\r
+        self._PrivateIncludes   = None\r
 \r
     ## Get current effective macros\r
     def _GetMacros(self):\r
@@ -1408,21 +1419,38 @@ class DecBuildData(PackageBuildClassObject):
             # protocol defition for given ARCH\r
             #\r
             ProtocolDict = tdict(True)\r
+            PrivateProtocolDict = tdict(True)\r
             NameList = []\r
+            PrivateNameList = []\r
+            PublicNameList = []\r
             # find out all protocol definitions for specific and 'common' arch\r
             RecordList = self._RawData[MODEL_EFI_PROTOCOL, self._Arch]\r
-            for Name, Guid, Dummy, Arch, ID, LineNo in RecordList:\r
+            for Name, Guid, Dummy, Arch, PrivateFlag, ID, LineNo in RecordList:\r
+                if PrivateFlag == 'PRIVATE':\r
+                    if Name not in PrivateNameList:\r
+                        PrivateNameList.append(Name)\r
+                        PrivateProtocolDict[Arch, Name] = Guid\r
+                    if Name in PublicNameList:\r
+                        EdkLogger.error('build', OPTION_CONFLICT, "Can't determine %s's attribute, it is both defined as Private and non-Private attribute in DEC file." % Name, File=self.MetaFile, Line=LineNo)\r
+                else:\r
+                    if Name not in PublicNameList:\r
+                        PublicNameList.append(Name)\r
+                    if Name in PrivateNameList:\r
+                        EdkLogger.error('build', OPTION_CONFLICT, "Can't determine %s's attribute, it is both defined as Private and non-Private attribute in DEC file." % Name, File=self.MetaFile, Line=LineNo)\r
                 if Name not in NameList:\r
                     NameList.append(Name)\r
                 ProtocolDict[Arch, Name] = Guid\r
             # use sdict to keep the order\r
             self._Protocols = sdict()\r
+            self._PrivateProtocols = sdict()\r
             for Name in NameList:\r
                 #\r
                 # limit the ARCH to self._Arch, if no self._Arch found, tdict\r
                 # will automatically turn to 'common' ARCH for trying\r
                 #\r
                 self._Protocols[Name] = ProtocolDict[self._Arch, Name]\r
+            for Name in PrivateNameList:\r
+                self._PrivateProtocols[Name] = PrivateProtocolDict[self._Arch, Name]\r
         return self._Protocols\r
 \r
     ## Retrieve PPI definitions (name/value pairs)\r
@@ -1433,21 +1461,38 @@ class DecBuildData(PackageBuildClassObject):
             # PPI defition for given ARCH\r
             #\r
             PpiDict = tdict(True)\r
+            PrivatePpiDict = tdict(True)\r
             NameList = []\r
+            PrivateNameList = []\r
+            PublicNameList = []\r
             # find out all PPI definitions for specific arch and 'common' arch\r
             RecordList = self._RawData[MODEL_EFI_PPI, self._Arch]\r
-            for Name, Guid, Dummy, Arch, ID, LineNo in RecordList:\r
+            for Name, Guid, Dummy, Arch, PrivateFlag, ID, LineNo in RecordList:\r
+                if PrivateFlag == 'PRIVATE':\r
+                    if Name not in PrivateNameList:\r
+                        PrivateNameList.append(Name)\r
+                        PrivatePpiDict[Arch, Name] = Guid\r
+                    if Name in PublicNameList:\r
+                        EdkLogger.error('build', OPTION_CONFLICT, "Can't determine %s's attribute, it is both defined as Private and non-Private attribute in DEC file." % Name, File=self.MetaFile, Line=LineNo)\r
+                else:\r
+                    if Name not in PublicNameList:\r
+                        PublicNameList.append(Name)\r
+                    if Name in PrivateNameList:\r
+                        EdkLogger.error('build', OPTION_CONFLICT, "Can't determine %s's attribute, it is both defined as Private and non-Private attribute in DEC file." % Name, File=self.MetaFile, Line=LineNo)\r
                 if Name not in NameList:\r
                     NameList.append(Name)\r
                 PpiDict[Arch, Name] = Guid\r
             # use sdict to keep the order\r
             self._Ppis = sdict()\r
+            self._PrivatePpis = sdict()\r
             for Name in NameList:\r
                 #\r
                 # limit the ARCH to self._Arch, if no self._Arch found, tdict\r
                 # will automatically turn to 'common' ARCH for trying\r
                 #\r
                 self._Ppis[Name] = PpiDict[self._Arch, Name]\r
+            for Name in PrivateNameList:\r
+                self._PrivatePpis[Name] = PrivatePpiDict[self._Arch, Name]\r
         return self._Ppis\r
 \r
     ## Retrieve GUID definitions (name/value pairs)\r
@@ -1458,27 +1503,46 @@ class DecBuildData(PackageBuildClassObject):
             # GUID defition for given ARCH\r
             #\r
             GuidDict = tdict(True)\r
+            PrivateGuidDict = tdict(True)\r
             NameList = []\r
+            PrivateNameList = []\r
+            PublicNameList = []\r
             # find out all protocol definitions for specific and 'common' arch\r
             RecordList = self._RawData[MODEL_EFI_GUID, self._Arch]\r
-            for Name, Guid, Dummy, Arch, ID, LineNo in RecordList:\r
+            for Name, Guid, Dummy, Arch, PrivateFlag, ID, LineNo in RecordList:\r
+                if PrivateFlag == 'PRIVATE':\r
+                    if Name not in PrivateNameList:\r
+                        PrivateNameList.append(Name)\r
+                        PrivateGuidDict[Arch, Name] = Guid\r
+                    if Name in PublicNameList:\r
+                        EdkLogger.error('build', OPTION_CONFLICT, "Can't determine %s's attribute, it is both defined as Private and non-Private attribute in DEC file." % Name, File=self.MetaFile, Line=LineNo)\r
+                else:\r
+                    if Name not in PublicNameList:\r
+                        PublicNameList.append(Name)\r
+                    if Name in PrivateNameList:\r
+                        EdkLogger.error('build', OPTION_CONFLICT, "Can't determine %s's attribute, it is both defined as Private and non-Private attribute in DEC file." % Name, File=self.MetaFile, Line=LineNo)\r
                 if Name not in NameList:\r
                     NameList.append(Name)\r
                 GuidDict[Arch, Name] = Guid\r
             # use sdict to keep the order\r
             self._Guids = sdict()\r
+            self._PrivateGuids = sdict()\r
             for Name in NameList:\r
                 #\r
                 # limit the ARCH to self._Arch, if no self._Arch found, tdict\r
                 # will automatically turn to 'common' ARCH for trying\r
                 #\r
                 self._Guids[Name] = GuidDict[self._Arch, Name]\r
+            for Name in PrivateNameList:\r
+                self._PrivateGuids[Name] = PrivateGuidDict[self._Arch, Name]\r
         return self._Guids\r
 \r
     ## Retrieve public include paths declared in this package\r
     def _GetInclude(self):\r
         if self._Includes == None:\r
             self._Includes = []\r
+            self._PrivateIncludes = []\r
+            PublicInclues = []\r
             RecordList = self._RawData[MODEL_EFI_INCLUDE, self._Arch]\r
             Macros = self._Macros\r
             Macros["EDK_SOURCE"] = GlobalData.gEcpSource\r
@@ -1493,6 +1557,17 @@ class DecBuildData(PackageBuildClassObject):
                 # avoid duplicate include path\r
                 if File not in self._Includes:\r
                     self._Includes.append(File)\r
+                if Record[4] == 'PRIVATE':\r
+                    if File not in self._PrivateIncludes:\r
+                        self._PrivateIncludes.append(File)\r
+                    if File in PublicInclues:\r
+                        EdkLogger.error('build', OPTION_CONFLICT, "Can't determine %s's attribute, it is both defined as Private and non-Private attribute in DEC file." % File, File=self.MetaFile, Line=LineNo)\r
+                else:\r
+                    if File not in PublicInclues:\r
+                        PublicInclues.append(File)\r
+                    if File in self._PrivateIncludes:\r
+                        EdkLogger.error('build', OPTION_CONFLICT, "Can't determine %s's attribute, it is both defined as Private and non-Private attribute in DEC file." % File, File=self.MetaFile, Line=LineNo)\r
+\r
         return self._Includes\r
 \r
     ## Retrieve library class declarations (not used in build at present)\r
@@ -1506,7 +1581,7 @@ class DecBuildData(PackageBuildClassObject):
             LibraryClassSet = set()\r
             RecordList = self._RawData[MODEL_EFI_LIBRARY_CLASS, self._Arch]\r
             Macros = self._Macros\r
-            for LibraryClass, File, Dummy, Arch, ID, LineNo in RecordList:\r
+            for LibraryClass, File, Dummy, Arch, PrivateFlag, ID, LineNo in RecordList:\r
                 File = PathClass(NormPath(File, Macros), self._PackageDir, Arch=self._Arch)\r
                 # check the file validation\r
                 ErrorCode, ErrorInfo = File.Validate()\r
@@ -1542,7 +1617,7 @@ class DecBuildData(PackageBuildClassObject):
         PcdSet = set()\r
         # find out all PCDs of the 'type'\r
         RecordList = self._RawData[Type, self._Arch]\r
-        for TokenSpaceGuid, PcdCName, Setting, Arch, Dummy1, Dummy2 in RecordList:\r
+        for TokenSpaceGuid, PcdCName, Setting, Arch, PrivateFlag, Dummy1, Dummy2 in RecordList:\r
             PcdDict[Arch, PcdCName, TokenSpaceGuid] = Setting\r
             PcdSet.add((PcdCName, TokenSpaceGuid))\r
 \r
@@ -1819,6 +1894,7 @@ class InfBuildData(ModuleBuildClassObject):
                 if self._Defs == None:\r
                     self._Defs = sdict()\r
                 self._Defs[Name] = Value\r
+                self._Macros[Name] = Value\r
             # some special items in [Defines] section need special treatment\r
             elif Name in ('EFI_SPECIFICATION_VERSION', 'UEFI_SPECIFICATION_VERSION', 'EDK_RELEASE_VERSION', 'PI_SPECIFICATION_VERSION'):\r
                 if Name in ('EFI_SPECIFICATION_VERSION', 'UEFI_SPECIFICATION_VERSION'):\r
@@ -1879,6 +1955,7 @@ class InfBuildData(ModuleBuildClassObject):
                 if self._Defs == None:\r
                     self._Defs = sdict()\r
                 self._Defs[Name] = Value\r
+                self._Macros[Name] = Value\r
 \r
         #\r
         # Retrieve information in sections specific to Edk.x modules\r
@@ -1900,9 +1977,18 @@ class InfBuildData(ModuleBuildClassObject):
             if (self._Specification == None) or (not 'PI_SPECIFICATION_VERSION' in self._Specification) or (int(self._Specification['PI_SPECIFICATION_VERSION'], 16) < 0x0001000A):\r
                 if self._ModuleType == SUP_MODULE_SMM_CORE:\r
                     EdkLogger.error("build", FORMAT_NOT_SUPPORTED, "SMM_CORE module type can't be used in the module with PI_SPECIFICATION_VERSION less than 0x0001000A", File=self.MetaFile)\r
+            if (self._Specification == None) or (not 'PI_SPECIFICATION_VERSION' in self._Specification) or (int(self._Specification['PI_SPECIFICATION_VERSION'], 16) < 0x00010032):\r
+                if self._ModuleType == SUP_MODULE_MM_CORE_STANDALONE:\r
+                    EdkLogger.error("build", FORMAT_NOT_SUPPORTED, "MM_CORE_STANDALONE module type can't be used in the module with PI_SPECIFICATION_VERSION less than 0x00010032", File=self.MetaFile)\r
+                if self._ModuleType == SUP_MODULE_MM_STANDALONE:\r
+                    EdkLogger.error("build", FORMAT_NOT_SUPPORTED, "MM_STANDALONE module type can't be used in the module with PI_SPECIFICATION_VERSION less than 0x00010032", File=self.MetaFile)\r
             if self._Defs and 'PCI_DEVICE_ID' in self._Defs and 'PCI_VENDOR_ID' in self._Defs \\r
-               and 'PCI_CLASS_CODE' in self._Defs:\r
+               and 'PCI_CLASS_CODE' in self._Defs and 'PCI_REVISION' in self._Defs:\r
                 self._BuildType = 'UEFI_OPTIONROM'\r
+                if 'PCI_COMPRESS' in self._Defs:\r
+                    if self._Defs['PCI_COMPRESS'] not in ('TRUE', 'FALSE'):\r
+                        EdkLogger.error("build", FORMAT_INVALID, "Expected TRUE/FALSE for PCI_COMPRESS: %s" %self.MetaFile)\r
+\r
             elif self._Defs and 'UEFI_HII_RESOURCE_SECTION' in self._Defs \\r
                and self._Defs['UEFI_HII_RESOURCE_SECTION'] == 'TRUE':\r
                 self._BuildType = 'UEFI_HII'\r
@@ -2281,7 +2367,7 @@ class InfBuildData(ModuleBuildClassObject):
             RecordList = self._RawData[MODEL_EFI_PROTOCOL, self._Arch, self._Platform]\r
             for Record in RecordList:\r
                 CName = Record[0]\r
-                Value = ProtocolValue(CName, self.Packages)\r
+                Value = ProtocolValue(CName, self.Packages, self.MetaFile.Path)\r
                 if Value == None:\r
                     PackageList = "\n\t".join([str(P) for P in self.Packages])\r
                     EdkLogger.error('build', RESOURCE_NOT_AVAILABLE,\r
@@ -2306,7 +2392,7 @@ class InfBuildData(ModuleBuildClassObject):
             RecordList = self._RawData[MODEL_EFI_PPI, self._Arch, self._Platform]\r
             for Record in RecordList:\r
                 CName = Record[0]\r
-                Value = PpiValue(CName, self.Packages)\r
+                Value = PpiValue(CName, self.Packages, self.MetaFile.Path)\r
                 if Value == None:\r
                     PackageList = "\n\t".join([str(P) for P in self.Packages])\r
                     EdkLogger.error('build', RESOURCE_NOT_AVAILABLE,\r
@@ -2331,7 +2417,7 @@ class InfBuildData(ModuleBuildClassObject):
             RecordList = self._RawData[MODEL_EFI_GUID, self._Arch, self._Platform]\r
             for Record in RecordList:\r
                 CName = Record[0]\r
-                Value = GuidValue(CName, self.Packages)\r
+                Value = GuidValue(CName, self.Packages, self.MetaFile.Path)\r
                 if Value == None:\r
                     PackageList = "\n\t".join([str(P) for P in self.Packages])\r
                     EdkLogger.error('build', RESOURCE_NOT_AVAILABLE,\r
@@ -2500,11 +2586,11 @@ class InfBuildData(ModuleBuildClassObject):
                         DepexList.append(Module.Guid)\r
                     else:\r
                         # get the GUID value now\r
-                        Value = ProtocolValue(Token, self.Packages)\r
+                        Value = ProtocolValue(Token, self.Packages, self.MetaFile.Path)\r
                         if Value == None:\r
-                            Value = PpiValue(Token, self.Packages)\r
+                            Value = PpiValue(Token, self.Packages, self.MetaFile.Path)\r
                             if Value == None:\r
-                                Value = GuidValue(Token, self.Packages)\r
+                                Value = GuidValue(Token, self.Packages, self.MetaFile.Path)\r
                         if Value == None:\r
                             PackageList = "\n\t".join([str(P) for P in self.Packages])\r
                             EdkLogger.error('build', RESOURCE_NOT_AVAILABLE,\r
@@ -2547,7 +2633,7 @@ class InfBuildData(ModuleBuildClassObject):
             PcdList.append((PcdCName, TokenSpaceGuid))\r
             # get the guid value\r
             if TokenSpaceGuid not in self.Guids:\r
-                Value = GuidValue(TokenSpaceGuid, self.Packages)\r
+                Value = GuidValue(TokenSpaceGuid, self.Packages, self.MetaFile.Path)\r
                 if Value == None:\r
                     PackageList = "\n\t".join([str(P) for P in self.Packages])\r
                     EdkLogger.error('build', RESOURCE_NOT_AVAILABLE,\r
@@ -2859,6 +2945,7 @@ class WorkspaceDatabase(object):
             MetaFile = self._FILE_PARSER_[FileType](\r
                                 FilePath, \r
                                 FileType, \r
+                                Arch,\r
                                 MetaFileStorage(self.WorkspaceDb.Cur, FilePath, FileType)\r
                                 )\r
             # alwasy do post-process, in case of macros change\r