From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (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 82ECF20082E77 for ; Thu, 15 Jun 2017 02:49:29 -0700 (PDT) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.jf.intel.com with ESMTP; 15 Jun 2017 02:50:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,343,1493708400"; d="scan'208";a="274581945" Received: from shwde7172.ccr.corp.intel.com ([10.239.9.14]) by fmsmga004.fm.intel.com with ESMTP; 15 Jun 2017 02:50:45 -0700 From: Liming Gao To: edk2-devel@lists.01.org Date: Thu, 15 Jun 2017 17:46:09 +0800 Message-Id: <1497519972-11796-2-git-send-email-liming.gao@intel.com> X-Mailer: git-send-email 2.8.0.windows.1 In-Reply-To: <1497519972-11796-1-git-send-email-liming.gao@intel.com> References: <1497519972-11796-1-git-send-email-liming.gao@intel.com> Subject: [PATCH v2 staging][BaseToolsOpt 1/4] BaseTools: Merge multiple drivers into one for size and link performance X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Jun 2017 09:49:29 -0000 Update BaseTools to support the multiple driver combination. The merge style reuses the library instance syntax in package.dsc file. The below example is to combine DriverHealthManagerDxe and BootManagerPolicyDxe driver into one driver. BootManagerPolicyDxe driver entry point will be executed first, DriverHealthManagerDxe entry point will run last. After combination, their Depex will be AND together. [Components] MdeModulePkg/Universal/DriverHealthManagerDxe/DriverHealthManagerDxe.inf { NULL|MdeModulePkg/Universal/BootManagerPolicyDxe/BootManagerPolicyDxe.inf } Notes: When try combining some drivers, the compile failure may happen, because the same function name are used in the different drivers. Those drivers are required to be clean up first, then be combined. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Liming Gao --- BaseTools/Source/Python/AutoGen/GenC.py | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py index 67aaef7..6579457 100644 --- a/BaseTools/Source/Python/AutoGen/GenC.py +++ b/BaseTools/Source/Python/AutoGen/GenC.py @@ -1359,10 +1359,17 @@ def CreateLibraryDestructorCode(Info, AutoGenC, AutoGenH): def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH): if Info.IsLibrary or Info.ModuleType in ['USER_DEFINED', 'SEC']: return + + ModuleEntryPointList = [] + for Lib in Info.DependentLibraryList: + if len (Lib.ModuleEntryPointList) > 0: + ModuleEntryPointList = ModuleEntryPointList + Lib.ModuleEntryPointList + ModuleEntryPointList = ModuleEntryPointList + Info.Module.ModuleEntryPointList + # # Module Entry Points # - NumEntryPoints = len(Info.Module.ModuleEntryPointList) + NumEntryPoints = len(ModuleEntryPointList) if 'PI_SPECIFICATION_VERSION' in Info.Module.Specification: PiSpecVersion = Info.Module.Specification['PI_SPECIFICATION_VERSION'] else: @@ -1372,7 +1379,7 @@ def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH): else: UefiSpecVersion = '0x00000000' Dict = { - 'Function' : Info.Module.ModuleEntryPointList, + 'Function' : ModuleEntryPointList, 'PiSpecVersion' : PiSpecVersion + 'U', 'UefiSpecVersion': UefiSpecVersion + 'U' } @@ -1385,7 +1392,7 @@ def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH): AUTOGEN_ERROR, '%s must have exactly one entry point' % Info.ModuleType, File=str(Info), - ExtraData= ", ".join(Info.Module.ModuleEntryPointList) + ExtraData= ", ".join(ModuleEntryPointList) ) if Info.ModuleType == 'PEI_CORE': AutoGenC.Append(gPeiCoreEntryPointString.Replace(Dict)) @@ -1430,11 +1437,18 @@ def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH): def CreateModuleUnloadImageCode(Info, AutoGenC, AutoGenH): if Info.IsLibrary or Info.ModuleType in ['USER_DEFINED', 'SEC']: return + + ModuleUnloadImageList = [] + for Lib in Info.DependentLibraryList: + if len (Lib.ModuleUnloadImageList) > 0: + ModuleUnloadImageList = ModuleUnloadImageList + Lib.ModuleUnloadImageList + ModuleUnloadImageList = ModuleUnloadImageList + Info.Module.ModuleUnloadImageList + # # Unload Image Handlers # - NumUnloadImage = len(Info.Module.ModuleUnloadImageList) - Dict = {'Count':str(NumUnloadImage) + 'U', 'Function':Info.Module.ModuleUnloadImageList} + NumUnloadImage = len(ModuleUnloadImageList) + Dict = {'Count':str(NumUnloadImage) + 'U', 'Function':ModuleUnloadImageList} if NumUnloadImage < 2: AutoGenC.Append(gUefiUnloadImageString[NumUnloadImage].Replace(Dict)) else: -- 2.8.0.windows.1