diff options
author | Feng, Bob C <bob.c.feng@intel.com> | 2019-01-10 17:03:29 +0800 |
---|---|---|
committer | Feng, Bob C <bob.c.feng@intel.com> | 2019-01-14 11:14:24 +0800 |
commit | 5bc96263ea2bfecb07deea81c68a6c3e226ebda1 (patch) | |
tree | af553c434ac2b33b4c6dcd4f84634ddfd8ce18ca | |
parent | 7217b8796d2727db76cd6684ba706c3b643b1d62 (diff) | |
download | edk2-5bc96263ea2bfecb07deea81c68a6c3e226ebda1.zip edk2-5bc96263ea2bfecb07deea81c68a6c3e226ebda1.tar.gz edk2-5bc96263ea2bfecb07deea81c68a6c3e226ebda1.tar.bz2 |
BaseTools: Enable component override functionality
https://bugzilla.tianocore.org/show_bug.cgi?id=1449
This patch enable build tools to recognize that
when two given files have the same GUID, file path and ARCH in Dsc,
The later one's definition will be used.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Carsey Jaben <jaben.carsey@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
-rw-r--r-- | BaseTools/Source/Python/Workspace/DscBuildData.py | 24 | ||||
-rw-r--r-- | BaseTools/Source/Python/Workspace/MetaFileParser.py | 5 | ||||
-rw-r--r-- | BaseTools/Source/Python/Workspace/MetaFileTable.py | 7 |
3 files changed, 25 insertions, 11 deletions
diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index ff41af1..9375167 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -706,18 +706,30 @@ class DscBuildData(PlatformBuildClassObject): GlobalData.gDefaultStores = sorted(self.DefaultStores.keys())
return self.DefaultStores
+ def OverrideDuplicateModule(self):
+ RecordList = self._RawData[MODEL_META_DATA_COMPONENT, self._Arch]
+ Macros = self._Macros
+ Macros["EDK_SOURCE"] = GlobalData.gEcpSource
+ Components = {}
+ for Record in RecordList:
+ ModuleId = Record[6]
+ file_guid = self._RawData[MODEL_META_DATA_HEADER, self._Arch, None, ModuleId]
+ file_guid_str = file_guid[0][2] if file_guid else "NULL"
+ ModuleFile = PathClass(NormPath(Record[0], Macros), GlobalData.gWorkspace, Arch=self._Arch)
+ if self._Arch != TAB_ARCH_COMMON and (file_guid_str,str(ModuleFile)) in Components:
+ self._RawData.DisableOverrideComponent(Components[(file_guid_str,str(ModuleFile))])
+ Components[(file_guid_str,str(ModuleFile))] = ModuleId
+ self._RawData._PostProcessed = False
## Retrieve [Components] section information
@property
def Modules(self):
if self._Modules is not None:
return self._Modules
-
+ self.OverrideDuplicateModule()
self._Modules = OrderedDict()
RecordList = self._RawData[MODEL_META_DATA_COMPONENT, self._Arch]
Macros = self._Macros
for Record in RecordList:
- DuplicatedFile = False
-
ModuleFile = PathClass(NormPath(Record[0], Macros), GlobalData.gWorkspace, Arch=self._Arch)
ModuleId = Record[6]
LineNo = Record[7]
@@ -727,10 +739,6 @@ class DscBuildData(PlatformBuildClassObject): if ErrorCode != 0:
EdkLogger.error('build', ErrorCode, File=self.MetaFile, Line=LineNo,
ExtraData=ErrorInfo)
- # Check duplication
- # If arch is COMMON, no duplicate module is checked since all modules in all component sections are selected
- if self._Arch != TAB_ARCH_COMMON and ModuleFile in self._Modules:
- DuplicatedFile = True
Module = ModuleBuildClassObject()
Module.MetaFile = ModuleFile
@@ -793,8 +801,6 @@ class DscBuildData(PlatformBuildClassObject): Module.BuildOptions[ToolChainFamily, ToolChain] = OptionString + " " + Option
RecordList = self._RawData[MODEL_META_DATA_HEADER, self._Arch, None, ModuleId]
- if DuplicatedFile and not RecordList:
- EdkLogger.error('build', FILE_DUPLICATED, File=self.MetaFile, ExtraData=str(ModuleFile), Line=LineNo)
if RecordList:
if len(RecordList) != 1:
EdkLogger.error('build', OPTION_UNKNOWN, 'Only FILE_GUID can be listed in <Defines> section.',
diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py index f2322b3..6df0d3c 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py @@ -1697,6 +1697,11 @@ class DscParser(MetaFileParser): self._ValueList = [ReplaceMacro(Value, self._Macros, RaiseError=False)
for Value in self._ValueList]
+ def DisableOverrideComponent(self,module_id):
+ for ori_id in self._IdMapping:
+ if self._IdMapping[ori_id] == module_id:
+ self._RawTable.DisableComponent(ori_id)
+
_SectionParser = {
MODEL_META_DATA_HEADER : _DefineParser,
MODEL_EFI_SKU_ID : _SkuIdParser,
diff --git a/BaseTools/Source/Python/Workspace/MetaFileTable.py b/BaseTools/Source/Python/Workspace/MetaFileTable.py index 004e949..823a87e 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileTable.py +++ b/BaseTools/Source/Python/Workspace/MetaFileTable.py @@ -76,7 +76,7 @@ class MetaFileTable(): self.CurrentContent.append(self._DUMMY_)
def GetAll(self):
- return [item for item in self.CurrentContent if item[0] >= 0 ]
+ return [item for item in self.CurrentContent if item[0] >= 0 and item[-1]>=0]
## Python class representation of table storing module data
class ModuleTable(MetaFileTable):
@@ -373,7 +373,6 @@ class PlatformTable(MetaFileTable): QueryTab = self.CurrentContent
result = [item for item in QueryTab if item[1] == Model and item[-1]>0 ]
-
if Scope1 is not None and Scope1 != TAB_ARCH_COMMON:
Sc1 = set(['COMMON'])
Sc1.add(Scope1)
@@ -397,6 +396,10 @@ class PlatformTable(MetaFileTable): result = [ [r[2],r[3],r[4],r[5],r[6],r[7],r[0],r[9]] for r in result ]
return result
+ def DisableComponent(self,comp_id):
+ for item in self.CurrentContent:
+ if item[0] == comp_id or item[8] == comp_id:
+ item[-1] = -1
## Factory class to produce different storage for different type of meta-file
class MetaFileStorage(object):
|