]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - BaseTools/Source/Python/GenFds/DepexSection.py
BaseTools: Cleanup unneeded code
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / DepexSection.py
... / ...
CommitLineData
1## @file\r
2# process depex section generation\r
3#\r
4# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
5#\r
6# This program and the accompanying materials\r
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 Common.LongFilePathOs as os\r
23from CommonDataClass.FdfClass import DepexSectionClassObject\r
24from AutoGen.GenDepex import DependencyExpression\r
25from Common import EdkLogger\r
26from Common.BuildToolError import *\r
27from Common.Misc import PathClass\r
28from Common.DataType import *\r
29\r
30## generate data section\r
31#\r
32#\r
33class DepexSection (DepexSectionClassObject):\r
34 ## The constructor\r
35 #\r
36 # @param self The object pointer\r
37 #\r
38 def __init__(self):\r
39 DepexSectionClassObject.__init__(self)\r
40\r
41 def __FindGuidValue(self, CName):\r
42 for Arch in GenFdsGlobalVariable.ArchList:\r
43 PkgList = GenFdsGlobalVariable.WorkSpace.GetPackageList(GenFdsGlobalVariable.ActivePlatform,\r
44 Arch,\r
45 GenFdsGlobalVariable.TargetName,\r
46 GenFdsGlobalVariable.ToolChainTag)\r
47 for Inf in GenFdsGlobalVariable.FdfParser.Profile.InfList:\r
48 ModuleFile = PathClass(Inf, GenFdsGlobalVariable.WorkSpaceDir)\r
49 ModuleData = GenFdsGlobalVariable.WorkSpace.BuildObject[\r
50 ModuleFile,\r
51 Arch,\r
52 GenFdsGlobalVariable.TargetName,\r
53 GenFdsGlobalVariable.ToolChainTag\r
54 ]\r
55 for Pkg in ModuleData.Packages:\r
56 if Pkg not in PkgList:\r
57 PkgList.append(Pkg)\r
58 for PkgDb in PkgList:\r
59 if CName in PkgDb.Ppis:\r
60 return PkgDb.Ppis[CName]\r
61 if CName in PkgDb.Protocols:\r
62 return PkgDb.Protocols[CName]\r
63 if CName in PkgDb.Guids:\r
64 return PkgDb.Guids[CName]\r
65 return None\r
66\r
67 ## GenSection() method\r
68 #\r
69 # Generate compressed section\r
70 #\r
71 # @param self The object pointer\r
72 # @param OutputPath Where to place output file\r
73 # @param ModuleName Which module this section belongs to\r
74 # @param SecNum Index of section\r
75 # @param KeyStringList Filter for inputs of section generation\r
76 # @param FfsInf FfsInfStatement object that contains this section data\r
77 # @param Dict dictionary contains macro and its value\r
78 # @retval tuple (Generated file name list, section alignment)\r
79 #\r
80 def GenSection(self, OutputPath, ModuleName, SecNum, keyStringList, FfsFile = None, Dict = None, IsMakefile = False):\r
81 if self.ExpressionProcessed == False:\r
82 self.Expression = self.Expression.replace("\n", " ").replace("\r", " ")\r
83 ExpList = self.Expression.split()\r
84\r
85 for Exp in ExpList:\r
86 if Exp.upper() not in ('AND', 'OR', 'NOT', 'TRUE', 'FALSE', 'SOR', 'BEFORE', 'AFTER', 'END'):\r
87 GuidStr = self.__FindGuidValue(Exp)\r
88 if GuidStr is None:\r
89 EdkLogger.error("GenFds", RESOURCE_NOT_AVAILABLE,\r
90 "Depex GUID %s could not be found in build DB! (ModuleName: %s)" % (Exp, ModuleName))\r
91\r
92 self.Expression = self.Expression.replace(Exp, GuidStr)\r
93\r
94 self.Expression = self.Expression.strip()\r
95 self.ExpressionProcessed = True\r
96\r
97 if self.DepexType == 'PEI_DEPEX_EXP':\r
98 ModuleType = SUP_MODULE_PEIM\r
99 SecType = BINARY_FILE_TYPE_PEI_DEPEX\r
100 elif self.DepexType == 'DXE_DEPEX_EXP':\r
101 ModuleType = SUP_MODULE_DXE_DRIVER\r
102 SecType = BINARY_FILE_TYPE_DXE_DEPEX\r
103 elif self.DepexType == 'SMM_DEPEX_EXP':\r
104 ModuleType = SUP_MODULE_DXE_SMM_DRIVER\r
105 SecType = BINARY_FILE_TYPE_SMM_DEPEX\r
106 else:\r
107 EdkLogger.error("GenFds", FORMAT_INVALID,\r
108 "Depex type %s is not valid for module %s" % (self.DepexType, ModuleName))\r
109\r
110 InputFile = os.path.join (OutputPath, ModuleName + SUP_MODULE_SEC + SecNum + '.depex')\r
111 InputFile = os.path.normpath(InputFile)\r
112 Depex = DependencyExpression(self.Expression, ModuleType)\r
113 Depex.Generate(InputFile)\r
114\r
115 OutputFile = os.path.join (OutputPath, ModuleName + SUP_MODULE_SEC + SecNum + '.dpx')\r
116 OutputFile = os.path.normpath(OutputFile)\r
117\r
118 GenFdsGlobalVariable.GenerateSection(OutputFile, [InputFile], Section.Section.SectionType.get (SecType), IsMakefile=IsMakefile)\r
119 return [OutputFile], self.Alignment\r