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