]>
Commit | Line | Data |
---|---|---|
30fdf114 LG |
1 | ## @file\r |
2 | # process depex section generation\r | |
3 | #\r | |
1be2ed90 | 4 | # Copyright (c) 2007 - 2014, 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 | |
18 | import Section\r | |
19 | from GenFdsGlobalVariable import GenFdsGlobalVariable\r | |
20 | import subprocess\r | |
21 | from Ffs import Ffs\r | |
1be2ed90 | 22 | import Common.LongFilePathOs as os\r |
30fdf114 LG |
23 | from CommonDataClass.FdfClass import DepexSectionClassObject\r |
24 | from AutoGen.GenDepex import DependencyExpression\r | |
30fdf114 LG |
25 | from Common import EdkLogger\r |
26 | from Common.BuildToolError import *\r | |
97fa0ee9 | 27 | from Common.Misc import PathClass\r |
30fdf114 LG |
28 | \r |
29 | ## generate data section\r | |
30 | #\r | |
31 | #\r | |
32 | class 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 | |
47 | ModuleFile = PathClass(Inf, GenFdsGlobalVariable.WorkSpaceDir)\r | |
48 | ModuleData = GenFdsGlobalVariable.WorkSpace.BuildObject[\r | |
49 | ModuleFile,\r | |
50 | Arch,\r | |
51 | GenFdsGlobalVariable.TargetName,\r | |
52 | GenFdsGlobalVariable.ToolChainTag\r | |
53 | ]\r | |
54 | for Pkg in ModuleData.Packages:\r | |
55 | if Pkg not in PkgList:\r | |
56 | PkgList.append(Pkg)\r | |
57 | for PkgDb in PkgList:\r | |
30fdf114 LG |
58 | if CName in PkgDb.Ppis:\r |
59 | return PkgDb.Ppis[CName]\r | |
60 | if CName in PkgDb.Protocols:\r | |
61 | return PkgDb.Protocols[CName]\r | |
62 | if CName in PkgDb.Guids:\r | |
63 | return PkgDb.Guids[CName]\r | |
64 | return None\r | |
65 | \r | |
66 | ## GenSection() method\r | |
67 | #\r | |
68 | # Generate compressed section\r | |
69 | #\r | |
70 | # @param self The object pointer\r | |
71 | # @param OutputPath Where to place output file\r | |
72 | # @param ModuleName Which module this section belongs to\r | |
73 | # @param SecNum Index of section\r | |
74 | # @param KeyStringList Filter for inputs of section generation\r | |
75 | # @param FfsInf FfsInfStatement object that contains this section data\r | |
76 | # @param Dict dictionary contains macro and its value\r | |
77 | # @retval tuple (Generated file name list, section alignment)\r | |
78 | #\r | |
79 | def GenSection(self, OutputPath, ModuleName, SecNum, keyStringList, FfsFile = None, Dict = {}):\r | |
52302d4d LG |
80 | \r |
81 | if self.ExpressionProcessed == False:\r | |
82 | self.Expression = self.Expression.replace("\n", " ").replace("\r", " ")\r | |
83 | ExpList = self.Expression.split()\r | |
84 | ExpGuidDict = {}\r | |
30fdf114 | 85 | \r |
52302d4d LG |
86 | for Exp in ExpList:\r |
87 | if Exp.upper() not in ('AND', 'OR', 'NOT', 'TRUE', 'FALSE', 'SOR', 'BEFORE', 'AFTER', 'END'):\r | |
88 | GuidStr = self.__FindGuidValue(Exp)\r | |
89 | if GuidStr == None:\r | |
90 | EdkLogger.error("GenFds", RESOURCE_NOT_AVAILABLE,\r | |
91 | "Depex GUID %s could not be found in build DB! (ModuleName: %s)" % (Exp, ModuleName))\r | |
30fdf114 | 92 | \r |
52302d4d | 93 | ExpGuidDict[Exp] = GuidStr\r |
30fdf114 | 94 | \r |
52302d4d LG |
95 | for Item in ExpGuidDict:\r |
96 | self.Expression = self.Expression.replace(Item, ExpGuidDict[Item])\r | |
30fdf114 | 97 | \r |
52302d4d LG |
98 | self.Expression = self.Expression.strip()\r |
99 | self.ExpressionProcessed = True\r | |
30fdf114 | 100 | \r |
b303ea72 LG |
101 | if self.DepexType == 'PEI_DEPEX_EXP':\r |
102 | ModuleType = 'PEIM'\r | |
103 | SecType = 'PEI_DEPEX'\r | |
104 | elif self.DepexType == 'DXE_DEPEX_EXP':\r | |
105 | ModuleType = 'DXE_DRIVER'\r | |
106 | SecType = 'DXE_DEPEX'\r | |
107 | elif self.DepexType == 'SMM_DEPEX_EXP':\r | |
108 | ModuleType = 'DXE_SMM_DRIVER'\r | |
109 | SecType = 'SMM_DEPEX'\r | |
110 | else:\r | |
111 | EdkLogger.error("GenFds", FORMAT_INVALID,\r | |
112 | "Depex type %s is not valid for module %s" % (self.DepexType, ModuleName))\r | |
30fdf114 | 113 | \r |
b303ea72 LG |
114 | InputFile = os.path.join (OutputPath, ModuleName + 'SEC' + SecNum + '.depex')\r |
115 | InputFile = os.path.normpath(InputFile)\r | |
116 | Depex = DependencyExpression(self.Expression, ModuleType)\r | |
117 | Depex.Generate(InputFile)\r | |
30fdf114 | 118 | \r |
b303ea72 | 119 | OutputFile = os.path.join (OutputPath, ModuleName + 'SEC' + SecNum + '.dpx')\r |
30fdf114 | 120 | OutputFile = os.path.normpath(OutputFile)\r |
b303ea72 | 121 | \r |
30fdf114 LG |
122 | GenFdsGlobalVariable.GenerateSection(OutputFile, [InputFile], Section.Section.SectionType.get (SecType))\r |
123 | FileList = [OutputFile]\r | |
124 | return FileList, self.Alignment\r |