]>
Commit | Line | Data |
---|---|---|
1 | ## @file\r | |
2 | # process depex section generation\r | |
3 | #\r | |
4 | # Copyright (c) 2007, Intel Corporation\r | |
5 | #\r | |
6 | # All rights reserved. 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 | |
18 | import Section\r | |
19 | from GenFdsGlobalVariable import GenFdsGlobalVariable\r | |
20 | import subprocess\r | |
21 | from Ffs import Ffs\r | |
22 | import os\r | |
23 | from CommonDataClass.FdfClass import DepexSectionClassObject\r | |
24 | from AutoGen.GenDepex import DependencyExpression\r | |
25 | import shutil\r | |
26 | from Common import EdkLogger\r | |
27 | from Common.BuildToolError import *\r | |
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 | |
42 | for PkgDb in GenFdsGlobalVariable.WorkSpace.PackageList:\r | |
43 | if CName in PkgDb.Ppis:\r | |
44 | return PkgDb.Ppis[CName]\r | |
45 | if CName in PkgDb.Protocols:\r | |
46 | return PkgDb.Protocols[CName]\r | |
47 | if CName in PkgDb.Guids:\r | |
48 | return PkgDb.Guids[CName]\r | |
49 | return None\r | |
50 | \r | |
51 | ## GenSection() method\r | |
52 | #\r | |
53 | # Generate compressed section\r | |
54 | #\r | |
55 | # @param self The object pointer\r | |
56 | # @param OutputPath Where to place output file\r | |
57 | # @param ModuleName Which module this section belongs to\r | |
58 | # @param SecNum Index of section\r | |
59 | # @param KeyStringList Filter for inputs of section generation\r | |
60 | # @param FfsInf FfsInfStatement object that contains this section data\r | |
61 | # @param Dict dictionary contains macro and its value\r | |
62 | # @retval tuple (Generated file name list, section alignment)\r | |
63 | #\r | |
64 | def GenSection(self, OutputPath, ModuleName, SecNum, keyStringList, FfsFile = None, Dict = {}):\r | |
65 | \r | |
66 | self.Expression = self.Expression.replace("\n", " ").replace("\r", " ")\r | |
67 | ExpList = self.Expression.split()\r | |
68 | ExpGuidDict = {}\r | |
69 | \r | |
70 | for Exp in ExpList:\r | |
71 | if Exp.upper() not in ('AND', 'OR', 'NOT', 'TRUE', 'FALSE', 'SOR', 'BEFORE', 'AFTER', 'END'):\r | |
72 | GuidStr = self.__FindGuidValue(Exp)\r | |
73 | if GuidStr == None:\r | |
74 | EdkLogger.error("GenFds", RESOURCE_NOT_AVAILABLE,\r | |
75 | "Depex GUID %s could not be found in build DB! (ModuleName: %s)" % (Exp, ModuleName))\r | |
76 | \r | |
77 | ExpGuidDict[Exp] = GuidStr\r | |
78 | \r | |
79 | for Item in ExpGuidDict:\r | |
80 | self.Expression = self.Expression.replace(Item, ExpGuidDict[Item])\r | |
81 | \r | |
82 | self.Expression = self.Expression.strip()\r | |
83 | if self.DepexType == 'PEI_DEPEX_EXP':\r | |
84 | ModuleType = 'PEIM'\r | |
85 | SecType = 'PEI_DEPEX'\r | |
86 | elif self.DepexType == 'DXE_DEPEX_EXP':\r | |
87 | ModuleType = 'DXE_DRIVER'\r | |
88 | SecType = 'DXE_DEPEX'\r | |
89 | elif self.DepexType == 'SMM_DEPEX_EXP':\r | |
90 | ModuleType = 'DXE_SMM_DRIVER'\r | |
91 | SecType = 'SMM_DEPEX'\r | |
92 | else:\r | |
93 | EdkLogger.error("GenFds", FORMAT_INVALID,\r | |
94 | "Depex type %s is not valid for module %s" % (self.DepexType, ModuleName))\r | |
95 | \r | |
96 | InputFile = os.path.join (OutputPath, ModuleName + 'SEC' + SecNum + '.depex')\r | |
97 | InputFile = os.path.normpath(InputFile)\r | |
98 | Depex = DependencyExpression(self.Expression, ModuleType)\r | |
99 | Depex.Generate(InputFile)\r | |
100 | \r | |
101 | OutputFile = os.path.join (OutputPath, ModuleName + 'SEC' + SecNum + '.dpx')\r | |
102 | OutputFile = os.path.normpath(OutputFile)\r | |
103 | \r | |
104 | GenFdsGlobalVariable.GenerateSection(OutputFile, [InputFile], Section.Section.SectionType.get (SecType))\r | |
105 | FileList = [OutputFile]\r | |
106 | return FileList, self.Alignment\r |