]> git.proxmox.com Git - mirror_edk2.git/blame - BaseTools/Source/Python/GenFds/DepexSection.py
Sync BaseTools Trunk (version r2518) to EDKII main trunk.
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / DepexSection.py
CommitLineData
30fdf114
LG
1## @file\r
2# process depex section generation\r
3#\r
40d841f6 4# Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
30fdf114 5#\r
40d841f6 6# This program and the accompanying materials\r
30fdf114
LG
7# are licensed and made available under the terms and conditions of the BSD License\r
8# which accompanies this distribution. The full text of the license may be found at\r
9# http://opensource.org/licenses/bsd-license.php\r
10#\r
11# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13#\r
14\r
15##\r
16# Import Modules\r
17#\r
18import Section\r
19from GenFdsGlobalVariable import GenFdsGlobalVariable\r
20import subprocess\r
21from Ffs import Ffs\r
22import os\r
23from CommonDataClass.FdfClass import DepexSectionClassObject\r
24from AutoGen.GenDepex import DependencyExpression\r
25import shutil\r
26from Common import EdkLogger\r
27from Common.BuildToolError import *\r
28\r
29## generate data section\r
30#\r
31#\r
32class DepexSection (DepexSectionClassObject):\r
33 ## The constructor\r
34 #\r
35 # @param self The object pointer\r
36 #\r
37 def __init__(self):\r
38 DepexSectionClassObject.__init__(self)\r
39\r
40 def __FindGuidValue(self, CName):\r
41 for Arch in GenFdsGlobalVariable.ArchList:\r
0d2711a6
LG
42 for PkgDb in GenFdsGlobalVariable.WorkSpace.GetPackageList(GenFdsGlobalVariable.ActivePlatform, \r
43 Arch, \r
44 GenFdsGlobalVariable.TargetName, \r
45 GenFdsGlobalVariable.ToolChainTag):\r
30fdf114
LG
46 if CName in PkgDb.Ppis:\r
47 return PkgDb.Ppis[CName]\r
48 if CName in PkgDb.Protocols:\r
49 return PkgDb.Protocols[CName]\r
50 if CName in PkgDb.Guids:\r
51 return PkgDb.Guids[CName]\r
52 return None\r
53\r
54 ## GenSection() method\r
55 #\r
56 # Generate compressed section\r
57 #\r
58 # @param self The object pointer\r
59 # @param OutputPath Where to place output file\r
60 # @param ModuleName Which module this section belongs to\r
61 # @param SecNum Index of section\r
62 # @param KeyStringList Filter for inputs of section generation\r
63 # @param FfsInf FfsInfStatement object that contains this section data\r
64 # @param Dict dictionary contains macro and its value\r
65 # @retval tuple (Generated file name list, section alignment)\r
66 #\r
67 def GenSection(self, OutputPath, ModuleName, SecNum, keyStringList, FfsFile = None, Dict = {}):\r
52302d4d
LG
68 \r
69 if self.ExpressionProcessed == False:\r
70 self.Expression = self.Expression.replace("\n", " ").replace("\r", " ")\r
71 ExpList = self.Expression.split()\r
72 ExpGuidDict = {}\r
30fdf114 73\r
52302d4d
LG
74 for Exp in ExpList:\r
75 if Exp.upper() not in ('AND', 'OR', 'NOT', 'TRUE', 'FALSE', 'SOR', 'BEFORE', 'AFTER', 'END'):\r
76 GuidStr = self.__FindGuidValue(Exp)\r
77 if GuidStr == None:\r
78 EdkLogger.error("GenFds", RESOURCE_NOT_AVAILABLE,\r
79 "Depex GUID %s could not be found in build DB! (ModuleName: %s)" % (Exp, ModuleName))\r
30fdf114 80\r
52302d4d 81 ExpGuidDict[Exp] = GuidStr\r
30fdf114 82\r
52302d4d
LG
83 for Item in ExpGuidDict:\r
84 self.Expression = self.Expression.replace(Item, ExpGuidDict[Item])\r
30fdf114 85\r
52302d4d
LG
86 self.Expression = self.Expression.strip()\r
87 self.ExpressionProcessed = True\r
30fdf114 88\r
b303ea72
LG
89 if self.DepexType == 'PEI_DEPEX_EXP':\r
90 ModuleType = 'PEIM'\r
91 SecType = 'PEI_DEPEX'\r
92 elif self.DepexType == 'DXE_DEPEX_EXP':\r
93 ModuleType = 'DXE_DRIVER'\r
94 SecType = 'DXE_DEPEX'\r
95 elif self.DepexType == 'SMM_DEPEX_EXP':\r
96 ModuleType = 'DXE_SMM_DRIVER'\r
97 SecType = 'SMM_DEPEX'\r
98 else:\r
99 EdkLogger.error("GenFds", FORMAT_INVALID,\r
100 "Depex type %s is not valid for module %s" % (self.DepexType, ModuleName))\r
30fdf114 101\r
b303ea72
LG
102 InputFile = os.path.join (OutputPath, ModuleName + 'SEC' + SecNum + '.depex')\r
103 InputFile = os.path.normpath(InputFile)\r
104 Depex = DependencyExpression(self.Expression, ModuleType)\r
105 Depex.Generate(InputFile)\r
30fdf114 106\r
b303ea72 107 OutputFile = os.path.join (OutputPath, ModuleName + 'SEC' + SecNum + '.dpx')\r
30fdf114 108 OutputFile = os.path.normpath(OutputFile)\r
b303ea72 109\r
30fdf114
LG
110 GenFdsGlobalVariable.GenerateSection(OutputFile, [InputFile], Section.Section.SectionType.get (SecType))\r
111 FileList = [OutputFile]\r
112 return FileList, self.Alignment\r