]> 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 ceaa4b8e0aa36ae16adeb306c2132b2b8a19abc6..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
@@ -1410,6 +1422,7 @@ class DecBuildData(PackageBuildClassObject):
             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, PrivateFlag, ID, LineNo in RecordList:\r
@@ -1417,6 +1430,13 @@ class DecBuildData(PackageBuildClassObject):
                     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
@@ -1444,6 +1464,7 @@ class DecBuildData(PackageBuildClassObject):
             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, PrivateFlag, ID, LineNo in RecordList:\r
@@ -1451,6 +1472,13 @@ class DecBuildData(PackageBuildClassObject):
                     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
@@ -1478,6 +1506,7 @@ class DecBuildData(PackageBuildClassObject):
             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, PrivateFlag, ID, LineNo in RecordList:\r
@@ -1485,6 +1514,13 @@ class DecBuildData(PackageBuildClassObject):
                     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
@@ -1506,6 +1542,7 @@ class DecBuildData(PackageBuildClassObject):
         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
@@ -1523,6 +1560,14 @@ class DecBuildData(PackageBuildClassObject):
                 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
@@ -1849,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
@@ -1909,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
@@ -1930,6 +1977,11 @@ 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 and 'PCI_REVISION' in self._Defs:\r
                 self._BuildType = 'UEFI_OPTIONROM'\r