From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.151; helo=mga17.intel.com; envelope-from=liming.gao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 9E4F9211B1103 for ; Sun, 13 Jan 2019 19:00:23 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Jan 2019 19:00:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,476,1539673200"; d="scan'208";a="266878861" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga004.jf.intel.com with ESMTP; 13 Jan 2019 19:00:22 -0800 Received: from fmsmsx154.amr.corp.intel.com (10.18.116.70) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.408.0; Sun, 13 Jan 2019 19:00:22 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX154.amr.corp.intel.com (10.18.116.70) with Microsoft SMTP Server (TLS) id 14.3.408.0; Sun, 13 Jan 2019 19:00:22 -0800 Received: from shsmsx152.ccr.corp.intel.com ([169.254.6.44]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.196]) with mapi id 14.03.0415.000; Mon, 14 Jan 2019 11:00:19 +0800 From: "Gao, Liming" To: "Feng, Bob C" , "edk2-devel@lists.01.org" CC: "Carsey, Jaben" Thread-Topic: [Patch] BaseTools: Enable component override functionality Thread-Index: AQHUqVbQMrFVadgdMkS7KfQHQc+BYaWuF98w Date: Mon, 14 Jan 2019 03:00:18 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E3B0FD1@SHSMSX152.ccr.corp.intel.com> References: <20190111023851.9172-1-bob.c.feng@intel.com> In-Reply-To: <20190111023851.9172-1-bob.c.feng@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch] BaseTools: Enable component override functionality X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Jan 2019 03:00:23 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao >-----Original Message----- >From: Feng, Bob C >Sent: Friday, January 11, 2019 10:39 AM >To: edk2-devel@lists.01.org >Cc: Feng, Bob C ; Gao, Liming >; Carsey, Jaben >Subject: [Patch] BaseTools: Enable component override functionality > >https://bugzilla.tianocore.org/show_bug.cgi?id=3D1449 >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 >Cc: Liming Gao >Cc: Carsey Jaben >--- > .../Source/Python/Workspace/DscBuildData.py | 24 ++++++++++++------- > .../Source/Python/Workspace/MetaFileParser.py | 5 ++++ > .../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 7e82e8e934..f9805f58f5 100644 >--- a/BaseTools/Source/Python/Workspace/DscBuildData.py >+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py >@@ -704,36 +704,44 @@ class DscBuildData(PlatformBuildClassObject): > if TAB_DEFAULT_STORES_DEFAULT not in self.DefaultStores: > self.DefaultStores[TAB_DEFAULT_STORES_DEFAULT] =3D (0, >TAB_DEFAULT_STORES_DEFAULT) > GlobalData.gDefaultStores =3D sorted(self.DefaultStores.keys(= )) > return self.DefaultStores > >+ def OverrideDuplicateModule(self): >+ RecordList =3D self._RawData[MODEL_META_DATA_COMPONENT, >self._Arch] >+ Macros =3D self._Macros >+ Macros["EDK_SOURCE"] =3D GlobalData.gEcpSource >+ Components =3D {} >+ for Record in RecordList: >+ ModuleId =3D Record[6] >+ file_guid =3D self._RawData[MODEL_META_DATA_HEADER, self._Arc= h, >None, ModuleId] >+ file_guid_str =3D file_guid[0][2] if file_guid else "NULL" >+ ModuleFile =3D PathClass(NormPath(Record[0], Macros), >GlobalData.gWorkspace, Arch=3Dself._Arch) >+ if self._Arch !=3D TAB_ARCH_COMMON and >(file_guid_str,str(ModuleFile)) in Components: >+ >self._RawData.DisableOverrideComponent(Components[(file_guid_str,str(M >oduleFile))]) >+ Components[(file_guid_str,str(ModuleFile))] =3D ModuleId >+ self._RawData._PostProcessed =3D False > ## Retrieve [Components] section information > @property > def Modules(self): > if self._Modules is not None: > return self._Modules >- >+ self.OverrideDuplicateModule() > self._Modules =3D OrderedDict() > RecordList =3D self._RawData[MODEL_META_DATA_COMPONENT, >self._Arch] > Macros =3D self._Macros > Macros["EDK_SOURCE"] =3D GlobalData.gEcpSource > for Record in RecordList: >- DuplicatedFile =3D False >- > ModuleFile =3D PathClass(NormPath(Record[0], Macros), >GlobalData.gWorkspace, Arch=3Dself._Arch) > ModuleId =3D Record[6] > LineNo =3D Record[7] > > # check the file validation > ErrorCode, ErrorInfo =3D ModuleFile.Validate('.inf') > if ErrorCode !=3D 0: > EdkLogger.error('build', ErrorCode, File=3Dself.MetaFile,= Line=3DLineNo, > ExtraData=3DErrorInfo) >- # Check duplication >- # If arch is COMMON, no duplicate module is checked since all= modules >in all component sections are selected >- if self._Arch !=3D TAB_ARCH_COMMON and ModuleFile in self._Mo= dules: >- DuplicatedFile =3D True > > Module =3D ModuleBuildClassObject() > Module.MetaFile =3D ModuleFile > > # get module private library instance >@@ -792,12 +800,10 @@ class DscBuildData(PlatformBuildClassObject): > else: > OptionString =3D Module.BuildOptions[ToolChainFamily,= ToolChain] > Module.BuildOptions[ToolChainFamily, ToolChain] =3D O= ptionString + >" " + Option > > RecordList =3D self._RawData[MODEL_META_DATA_HEADER, self._Ar= ch, >None, ModuleId] >- if DuplicatedFile and not RecordList: >- EdkLogger.error('build', FILE_DUPLICATED, File=3Dself.Met= aFile, >ExtraData=3Dstr(ModuleFile), Line=3DLineNo) > if RecordList: > if len(RecordList) !=3D 1: > EdkLogger.error('build', OPTION_UNKNOWN, 'Only FILE_G= UID can >be listed in section.', > File=3Dself.MetaFile, ExtraData=3Dstr= (ModuleFile), Line=3DLineNo) > ModuleFile =3D ProcessDuplicatedInf(ModuleFile, RecordLis= t[0][2], >GlobalData.gWorkspace) >diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py >b/BaseTools/Source/Python/Workspace/MetaFileParser.py >index 032220813b..a52e9229df 100644 >--- a/BaseTools/Source/Python/Workspace/MetaFileParser.py >+++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py >@@ -1711,10 +1711,15 @@ class DscParser(MetaFileParser): > > def __ProcessBuildOption(self): > self._ValueList =3D [ReplaceMacro(Value, self._Macros, RaiseError= =3DFalse) > for Value in self._ValueList] > >+ def DisableOverrideComponent(self,module_id): >+ for ori_id in self._IdMapping: >+ if self._IdMapping[ori_id] =3D=3D module_id: >+ self._RawTable.DisableComponent(ori_id) >+ > _SectionParser =3D { > MODEL_META_DATA_HEADER : _DefineParser= , > MODEL_EFI_SKU_ID : _SkuIdParser, > MODEL_EFI_DEFAULT_STORES : _DefaultStore= sParser, > MODEL_EFI_LIBRARY_INSTANCE : _LibraryInsta= nceParser, >diff --git a/BaseTools/Source/Python/Workspace/MetaFileTable.py >b/BaseTools/Source/Python/Workspace/MetaFileTable.py >index 004e9494c3..823a87e057 100644 >--- a/BaseTools/Source/Python/Workspace/MetaFileTable.py >+++ b/BaseTools/Source/Python/Workspace/MetaFileTable.py >@@ -74,11 +74,11 @@ class MetaFileTable(): > > def SetEndFlag(self): > self.CurrentContent.append(self._DUMMY_) > > def GetAll(self): >- return [item for item in self.CurrentContent if item[0] >=3D 0 ] >+ return [item for item in self.CurrentContent if item[0] >=3D 0 an= d item[- >1]>=3D0] > > ## Python class representation of table storing module data > class ModuleTable(MetaFileTable): > _COLUMN_ =3D ''' > ID REAL PRIMARY KEY, >@@ -371,11 +371,10 @@ class PlatformTable(MetaFileTable): > # > def Query(self, Model, Scope1=3DNone, Scope2=3DNone, >BelongsToItem=3DNone, FromItem=3DNone): > > QueryTab =3D self.CurrentContent > result =3D [item for item in QueryTab if item[1] =3D=3D Model and= item[-1]>0 ] >- > if Scope1 is not None and Scope1 !=3D TAB_ARCH_COMMON: > Sc1 =3D set(['COMMON']) > Sc1.add(Scope1) > result =3D [item for item in result if item[5] in Sc1] > Sc2 =3D set( ['COMMON','DEFAULT']) >@@ -395,10 +394,14 @@ class PlatformTable(MetaFileTable): > result =3D [item for item in result if item[9] =3D=3D FromIte= m] > > result =3D [ [r[2],r[3],r[4],r[5],r[6],r[7],r[0],r[9]] for r in r= esult ] > return result > >+ def DisableComponent(self,comp_id): >+ for item in self.CurrentContent: >+ if item[0] =3D=3D comp_id or item[8] =3D=3D comp_id: >+ item[-1] =3D -1 > > ## Factory class to produce different storage for different type of meta-= file > class MetaFileStorage(object): > _FILE_TABLE_ =3D { > MODEL_FILE_INF : ModuleTable, >-- >2.19.1.windows.1