]>
Commit | Line | Data |
---|---|---|
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 |
2e351cbe | 6 | # SPDX-License-Identifier: BSD-2-Clause-Patent\r |
30fdf114 LG |
7 | #\r |
8 | \r | |
9 | ##\r | |
10 | # Import Modules\r | |
11 | #\r | |
1ccc4d89 | 12 | from __future__ import absolute_import\r |
bfa65b61 GL |
13 | from . import Section\r |
14 | from .GenFdsGlobalVariable import GenFdsGlobalVariable\r | |
1be2ed90 | 15 | import Common.LongFilePathOs as os\r |
30fdf114 LG |
16 | from CommonDataClass.FdfClass import DepexSectionClassObject\r |
17 | from AutoGen.GenDepex import DependencyExpression\r | |
30fdf114 LG |
18 | from Common import EdkLogger\r |
19 | from Common.BuildToolError import *\r | |
97fa0ee9 | 20 | from Common.Misc import PathClass\r |
8bb63e37 | 21 | from Common.DataType import *\r |
30fdf114 LG |
22 | \r |
23 | ## generate data section\r | |
24 | #\r | |
25 | #\r | |
26 | class DepexSection (DepexSectionClassObject):\r | |
27 | ## The constructor\r | |
28 | #\r | |
29 | # @param self The object pointer\r | |
30 | #\r | |
31 | def __init__(self):\r | |
32 | DepexSectionClassObject.__init__(self)\r | |
33 | \r | |
34 | def __FindGuidValue(self, CName):\r | |
35 | for Arch in GenFdsGlobalVariable.ArchList:\r | |
97fa0ee9 YL |
36 | PkgList = GenFdsGlobalVariable.WorkSpace.GetPackageList(GenFdsGlobalVariable.ActivePlatform,\r |
37 | Arch,\r | |
38 | GenFdsGlobalVariable.TargetName,\r | |
39 | GenFdsGlobalVariable.ToolChainTag)\r | |
40 | for Inf in GenFdsGlobalVariable.FdfParser.Profile.InfList:\r | |
97fa0ee9 | 41 | ModuleData = GenFdsGlobalVariable.WorkSpace.BuildObject[\r |
9e47e6f9 | 42 | PathClass(Inf, GenFdsGlobalVariable.WorkSpaceDir),\r |
97fa0ee9 YL |
43 | Arch,\r |
44 | GenFdsGlobalVariable.TargetName,\r | |
45 | GenFdsGlobalVariable.ToolChainTag\r | |
46 | ]\r | |
47 | for Pkg in ModuleData.Packages:\r | |
48 | if Pkg not in PkgList:\r | |
49 | PkgList.append(Pkg)\r | |
50 | for PkgDb in PkgList:\r | |
30fdf114 LG |
51 | if CName in PkgDb.Ppis:\r |
52 | return PkgDb.Ppis[CName]\r | |
53 | if CName in PkgDb.Protocols:\r | |
54 | return PkgDb.Protocols[CName]\r | |
55 | if CName in PkgDb.Guids:\r | |
56 | return PkgDb.Guids[CName]\r | |
57 | return None\r | |
58 | \r | |
59 | ## GenSection() method\r | |
60 | #\r | |
61 | # Generate compressed section\r | |
62 | #\r | |
63 | # @param self The object pointer\r | |
64 | # @param OutputPath Where to place output file\r | |
65 | # @param ModuleName Which module this section belongs to\r | |
66 | # @param SecNum Index of section\r | |
67 | # @param KeyStringList Filter for inputs of section generation\r | |
68 | # @param FfsInf FfsInfStatement object that contains this section data\r | |
69 | # @param Dict dictionary contains macro and its value\r | |
70 | # @retval tuple (Generated file name list, section alignment)\r | |
71 | #\r | |
c3dc9d29 | 72 | def GenSection(self, OutputPath, ModuleName, SecNum, keyStringList, FfsFile = None, Dict = None, IsMakefile = False):\r |
52302d4d LG |
73 | if self.ExpressionProcessed == False:\r |
74 | self.Expression = self.Expression.replace("\n", " ").replace("\r", " ")\r | |
75 | ExpList = self.Expression.split()\r | |
30fdf114 | 76 | \r |
52302d4d LG |
77 | for Exp in ExpList:\r |
78 | if Exp.upper() not in ('AND', 'OR', 'NOT', 'TRUE', 'FALSE', 'SOR', 'BEFORE', 'AFTER', 'END'):\r | |
79 | GuidStr = self.__FindGuidValue(Exp)\r | |
4231a819 | 80 | if GuidStr is None:\r |
52302d4d LG |
81 | EdkLogger.error("GenFds", RESOURCE_NOT_AVAILABLE,\r |
82 | "Depex GUID %s could not be found in build DB! (ModuleName: %s)" % (Exp, ModuleName))\r | |
30fdf114 | 83 | \r |
c3dc9d29 | 84 | self.Expression = self.Expression.replace(Exp, GuidStr)\r |
30fdf114 | 85 | \r |
52302d4d LG |
86 | self.Expression = self.Expression.strip()\r |
87 | self.ExpressionProcessed = True\r | |
30fdf114 | 88 | \r |
b303ea72 | 89 | if self.DepexType == 'PEI_DEPEX_EXP':\r |
8bb63e37 | 90 | ModuleType = SUP_MODULE_PEIM\r |
91fa33ee | 91 | SecType = BINARY_FILE_TYPE_PEI_DEPEX\r |
b303ea72 | 92 | elif self.DepexType == 'DXE_DEPEX_EXP':\r |
8bb63e37 | 93 | ModuleType = SUP_MODULE_DXE_DRIVER\r |
91fa33ee | 94 | SecType = BINARY_FILE_TYPE_DXE_DEPEX\r |
b303ea72 | 95 | elif self.DepexType == 'SMM_DEPEX_EXP':\r |
8bb63e37 | 96 | ModuleType = SUP_MODULE_DXE_SMM_DRIVER\r |
91fa33ee | 97 | SecType = BINARY_FILE_TYPE_SMM_DEPEX\r |
b303ea72 LG |
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 |
8bb63e37 | 102 | InputFile = os.path.join (OutputPath, ModuleName + SUP_MODULE_SEC + SecNum + '.depex')\r |
b303ea72 LG |
103 | InputFile = os.path.normpath(InputFile)\r |
104 | Depex = DependencyExpression(self.Expression, ModuleType)\r | |
105 | Depex.Generate(InputFile)\r | |
30fdf114 | 106 | \r |
8bb63e37 | 107 | OutputFile = os.path.join (OutputPath, ModuleName + SUP_MODULE_SEC + SecNum + '.dpx')\r |
30fdf114 | 108 | OutputFile = os.path.normpath(OutputFile)\r |
b303ea72 | 109 | \r |
37de70b7 | 110 | GenFdsGlobalVariable.GenerateSection(OutputFile, [InputFile], Section.Section.SectionType.get (SecType), IsMakefile=IsMakefile)\r |
c3dc9d29 | 111 | return [OutputFile], self.Alignment\r |