]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools:BaseTools supports to the driver combination.
authorFan, ZhijuX <zhijux.fan@intel.com>
Tue, 19 Feb 2019 10:46:41 +0000 (18:46 +0800)
committerFeng, Bob C <bob.c.feng@intel.com>
Wed, 20 Feb 2019 05:16:56 +0000 (13:16 +0800)
BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=1520

To save the image size without the compression, more than
one drivers can be combined into single one. When more than
one drivers are combined, their depex will be AND together.
Below is the example to combine BootManagerPolicyDxe into
DriverHealthManagerDxe.

Besides this patch, BaseTools also needs to check the module
type and make sure all module type are same. Otherwise,
BaseTools will report the error.
DRIVER INF has the parameter ENTRY_POINT
LIBRARY INF has the parameter LIBRARY_CLASS

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhiju.Fan <zhijux.fan@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
BaseTools/Source/Python/AutoGen/GenC.py
BaseTools/Source/Python/Workspace/WorkspaceCommon.py

index 9700bf85270586cb337a4bf5f2a2768299a3fd11..e6fc5cda3cdd16f7114020d8f650ef7fe61c7cc9 100644 (file)
@@ -1455,10 +1455,25 @@ def CreateLibraryDestructorCode(Info, AutoGenC, AutoGenH):
 def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH):\r
     if Info.IsLibrary or Info.ModuleType in [SUP_MODULE_USER_DEFINED, SUP_MODULE_SEC]:\r
         return\r
+    ModuleEntryPointList = []\r
+    for Lib in Info.DependentLibraryList:\r
+        if len(Lib.ModuleEntryPointList) > 0:\r
+            if Lib.ModuleType == Info.ModuleType:\r
+                ModuleEntryPointList = ModuleEntryPointList + Lib.ModuleEntryPointList\r
+            else:\r
+                EdkLogger.error(\r
+                    "build",\r
+                    PREBUILD_ERROR,\r
+                    "Driver's ModuleType must be consistent [%s]"%(str(Lib)),\r
+                    File=str(Info.PlatformInfo),\r
+                    ExtraData="consumed by [%s]" % str(Info.MetaFile)\r
+                )\r
+    ModuleEntryPointList = ModuleEntryPointList + Info.Module.ModuleEntryPointList\r
+\r
     #\r
     # Module Entry Points\r
     #\r
-    NumEntryPoints = len(Info.Module.ModuleEntryPointList)\r
+    NumEntryPoints = len(ModuleEntryPointList)\r
     if 'PI_SPECIFICATION_VERSION' in Info.Module.Specification:\r
         PiSpecVersion = Info.Module.Specification['PI_SPECIFICATION_VERSION']\r
     else:\r
@@ -1468,7 +1483,7 @@ def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH):
     else:\r
         UefiSpecVersion = '0x00000000'\r
     Dict = {\r
-        'Function'       :   Info.Module.ModuleEntryPointList,\r
+        'Function'       :   ModuleEntryPointList,\r
         'PiSpecVersion'  :   PiSpecVersion + 'U',\r
         'UefiSpecVersion':   UefiSpecVersion + 'U'\r
     }\r
@@ -1481,7 +1496,7 @@ def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH):
                   AUTOGEN_ERROR,\r
                   '%s must have exactly one entry point' % Info.ModuleType,\r
                   File=str(Info),\r
-                  ExtraData= ", ".join(Info.Module.ModuleEntryPointList)\r
+                  ExtraData= ", ".join(ModuleEntryPointList)\r
                   )\r
     if Info.ModuleType == SUP_MODULE_PEI_CORE:\r
         AutoGenC.Append(gPeiCoreEntryPointString.Replace(Dict))\r
@@ -1535,11 +1550,18 @@ def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH):
 def CreateModuleUnloadImageCode(Info, AutoGenC, AutoGenH):\r
     if Info.IsLibrary or Info.ModuleType in [SUP_MODULE_USER_DEFINED, SUP_MODULE_SEC]:\r
         return\r
+\r
+    ModuleUnloadImageList = []\r
+    for Lib in Info.DependentLibraryList:\r
+        if len(Lib.ModuleUnloadImageList) > 0:\r
+            ModuleUnloadImageList = ModuleUnloadImageList + Lib.ModuleUnloadImageList\r
+    ModuleUnloadImageList = ModuleUnloadImageList + Info.Module.ModuleUnloadImageList\r
+\r
     #\r
     # Unload Image Handlers\r
     #\r
-    NumUnloadImage = len(Info.Module.ModuleUnloadImageList)\r
-    Dict = {'Count':str(NumUnloadImage) + 'U', 'Function':Info.Module.ModuleUnloadImageList}\r
+    NumUnloadImage = len(ModuleUnloadImageList)\r
+    Dict = {'Count':str(NumUnloadImage) + 'U', 'Function':ModuleUnloadImageList}\r
     if NumUnloadImage < 2:\r
         AutoGenC.Append(gUefiUnloadImageString[NumUnloadImage].Replace(Dict))\r
     else:\r
index b79280bc2e839c754eb5a83a69c9997212f93a50..22abda87439279be8e66a3184d2efea61f932326 100644 (file)
@@ -20,6 +20,8 @@ from Workspace.BuildClassObject import StructurePcd
 from Common.BuildToolError import RESOURCE_NOT_AVAILABLE\r
 from Common.BuildToolError import OPTION_MISSING\r
 from Common.BuildToolError import BUILD_ERROR\r
+from Common.BuildToolError import PREBUILD_ERROR\r
+import Common.EdkLogger as EdkLogError\r
 \r
 class OrderedListDict(OrderedDict):\r
     def __init__(self, *args, **kwargs):\r
@@ -138,6 +140,12 @@ def GetModuleLibInstances(Module, Platform, BuildDatabase, Arch, Target, Toolcha
                             return []\r
 \r
                 LibraryModule = BuildDatabase[LibraryPath, Arch, Target, Toolchain]\r
+                if LibraryModule.ModuleEntryPointList and LibraryModule.ModuleType != Module.ModuleType:\r
+                    EdkLogError.error(\r
+                        "build", PREBUILD_ERROR,\r
+                        "Driver's ModuleType must be consistent [%s]" % (str(Module)),\r
+                        File=str(FileName),\r
+                        ExtraData="consumed by [%s]" % str(LibraryModule))\r
                 # for those forced library instance (NULL library), add a fake library class\r
                 if LibraryClassName.startswith("NULL"):\r
                     LibraryModule.LibraryClass.append(LibraryClassObject(LibraryClassName, [ModuleType]))\r