]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/GenFds/FfsInfStatement.py
Sync BaseTools Branch (version r2321) to EDKII main trunk.
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / FfsInfStatement.py
index 742b2162fe3ff49caf11444323b7546e503014b5..b9e18f6bca922ca09b82717026cdeb8fc41712bd 100644 (file)
@@ -36,6 +36,7 @@ from Common.BuildToolError import *
 from GuidSection import GuidSection\r
 from FvImageSection import FvImageSection\r
 from Common.Misc import PeImageClass\r
+from AutoGen.GenDepex import DependencyExpression\r
 \r
 ## generate FFS from INF\r
 #\r
@@ -54,17 +55,75 @@ class FfsInfStatement(FfsInfStatementClassObject):
         self.OptRomDefs = {}\r
         self.PiSpecVersion = '0x00000000'\r
         self.InfModule = None\r
-        self.FinalBuildTargetList = []\r
+        self.FinalTargetSuffixMap = {}\r
 \r
-    ## GetFinalBuildTargetList() method\r
+    ## GetFinalTargetSuffixMap() method\r
     #\r
     #    Get final build target list\r
-    def GetFinalBuildTargetList(self):\r
+    def GetFinalTargetSuffixMap(self):\r
         if not self.InfModule or not self.CurrentArch:\r
             return []\r
-        if not self.FinalBuildTargetList:\r
-            self.FinalBuildTargetList = GenFdsGlobalVariable.GetModuleCodaTargetList(self.InfModule, self.CurrentArch)\r
-        return self.FinalBuildTargetList\r
+        if not self.FinalTargetSuffixMap:\r
+            FinalBuildTargetList = GenFdsGlobalVariable.GetModuleCodaTargetList(self.InfModule, self.CurrentArch)\r
+            for File in FinalBuildTargetList:\r
+                self.FinalTargetSuffixMap.setdefault(os.path.splitext(File)[1], []).append(File)\r
+\r
+            # Check if current INF module has DEPEX\r
+            if '.depex' not in self.FinalTargetSuffixMap and self.InfModule.ModuleType != "USER_DEFINED" \\r
+                and not self.InfModule.DxsFile and not self.InfModule.LibraryClass:\r
+                ModuleType = self.InfModule.ModuleType\r
+                PlatformDataBase = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, self.CurrentArch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]\r
+\r
+                if ModuleType != DataType.SUP_MODULE_USER_DEFINED:\r
+                    for LibraryClass in PlatformDataBase.LibraryClasses.GetKeys():\r
+                        if LibraryClass.startswith("NULL") and PlatformDataBase.LibraryClasses[LibraryClass, ModuleType]:\r
+                            self.InfModule.LibraryClasses[LibraryClass] = PlatformDataBase.LibraryClasses[LibraryClass, ModuleType]\r
+\r
+                StrModule = str(self.InfModule)\r
+                PlatformModule = None\r
+                if StrModule in PlatformDataBase.Modules:\r
+                    PlatformModule = PlatformDataBase.Modules[StrModule]\r
+                    for LibraryClass in PlatformModule.LibraryClasses:\r
+                        if LibraryClass.startswith("NULL"):\r
+                            self.InfModule.LibraryClasses[LibraryClass] = PlatformModule.LibraryClasses[LibraryClass]\r
+\r
+                DependencyList = [self.InfModule]\r
+                LibraryInstance = {}\r
+                DepexList = []\r
+                while len(DependencyList) > 0:\r
+                    Module = DependencyList.pop(0)\r
+                    if not Module:\r
+                        continue\r
+                    for Dep in Module.Depex[self.CurrentArch, ModuleType]:\r
+                        if DepexList != []:\r
+                            DepexList.append('AND')\r
+                        DepexList.append('(')\r
+                        DepexList.extend(Dep)\r
+                        if DepexList[-1] == 'END':  # no need of a END at this time\r
+                            DepexList.pop()\r
+                        DepexList.append(')')\r
+                    if 'BEFORE' in DepexList or 'AFTER' in DepexList:\r
+                        break\r
+                    for LibName in Module.LibraryClasses:\r
+                        if LibName in LibraryInstance:\r
+                            continue\r
+                        if PlatformModule and LibName in PlatformModule.LibraryClasses:\r
+                            LibraryPath = PlatformModule.LibraryClasses[LibName]\r
+                        else:\r
+                            LibraryPath = PlatformDataBase.LibraryClasses[LibName, ModuleType]\r
+                        if not LibraryPath:\r
+                            LibraryPath = Module.LibraryClasses[LibName]\r
+                        if not LibraryPath:\r
+                            continue\r
+                        LibraryModule = GenFdsGlobalVariable.WorkSpace.BuildObject[LibraryPath, self.CurrentArch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]\r
+                        LibraryInstance[LibName] = LibraryModule\r
+                        DependencyList.append(LibraryModule)\r
+                if DepexList:\r
+                    Dpx = DependencyExpression(DepexList, ModuleType, True)\r
+                    if len(Dpx.PostfixNotation) != 0:\r
+                        # It means this module has DEPEX\r
+                        self.FinalTargetSuffixMap['.depex'] = [os.path.join(self.EfiOutputPath, self.BaseName) + '.depex']\r
+        return self.FinalTargetSuffixMap\r
 \r
     ## __InfParse() method\r
     #\r