]> git.proxmox.com Git - mirror_edk2.git/blame - BaseTools/Source/Python/GenFds/DepexSection.py
There is a limitation on WINDOWS OS for the length of entire file path can’t be large...
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / DepexSection.py
CommitLineData
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
18import Section\r
19from GenFdsGlobalVariable import GenFdsGlobalVariable\r
20import subprocess\r
21from Ffs import Ffs\r
1be2ed90 22import Common.LongFilePathOs as os\r
30fdf114
LG
23from CommonDataClass.FdfClass import DepexSectionClassObject\r
24from AutoGen.GenDepex import DependencyExpression\r
30fdf114
LG
25from Common import EdkLogger\r
26from Common.BuildToolError import *\r
27\r
28## generate data section\r
29#\r
30#\r
31class DepexSection (DepexSectionClassObject):\r
32 ## The constructor\r
33 #\r
34 # @param self The object pointer\r
35 #\r
36 def __init__(self):\r
37 DepexSectionClassObject.__init__(self)\r
38\r
39 def __FindGuidValue(self, CName):\r
40 for Arch in GenFdsGlobalVariable.ArchList:\r
0d2711a6
LG
41 for PkgDb in GenFdsGlobalVariable.WorkSpace.GetPackageList(GenFdsGlobalVariable.ActivePlatform, \r
42 Arch, \r
43 GenFdsGlobalVariable.TargetName, \r
44 GenFdsGlobalVariable.ToolChainTag):\r
30fdf114
LG
45 if CName in PkgDb.Ppis:\r
46 return PkgDb.Ppis[CName]\r
47 if CName in PkgDb.Protocols:\r
48 return PkgDb.Protocols[CName]\r
49 if CName in PkgDb.Guids:\r
50 return PkgDb.Guids[CName]\r
51 return None\r
52\r
53 ## GenSection() method\r
54 #\r
55 # Generate compressed section\r
56 #\r
57 # @param self The object pointer\r
58 # @param OutputPath Where to place output file\r
59 # @param ModuleName Which module this section belongs to\r
60 # @param SecNum Index of section\r
61 # @param KeyStringList Filter for inputs of section generation\r
62 # @param FfsInf FfsInfStatement object that contains this section data\r
63 # @param Dict dictionary contains macro and its value\r
64 # @retval tuple (Generated file name list, section alignment)\r
65 #\r
66 def GenSection(self, OutputPath, ModuleName, SecNum, keyStringList, FfsFile = None, Dict = {}):\r
52302d4d
LG
67 \r
68 if self.ExpressionProcessed == False:\r
69 self.Expression = self.Expression.replace("\n", " ").replace("\r", " ")\r
70 ExpList = self.Expression.split()\r
71 ExpGuidDict = {}\r
30fdf114 72\r
52302d4d
LG
73 for Exp in ExpList:\r
74 if Exp.upper() not in ('AND', 'OR', 'NOT', 'TRUE', 'FALSE', 'SOR', 'BEFORE', 'AFTER', 'END'):\r
75 GuidStr = self.__FindGuidValue(Exp)\r
76 if GuidStr == None:\r
77 EdkLogger.error("GenFds", RESOURCE_NOT_AVAILABLE,\r
78 "Depex GUID %s could not be found in build DB! (ModuleName: %s)" % (Exp, ModuleName))\r
30fdf114 79\r
52302d4d 80 ExpGuidDict[Exp] = GuidStr\r
30fdf114 81\r
52302d4d
LG
82 for Item in ExpGuidDict:\r
83 self.Expression = self.Expression.replace(Item, ExpGuidDict[Item])\r
30fdf114 84\r
52302d4d
LG
85 self.Expression = self.Expression.strip()\r
86 self.ExpressionProcessed = True\r
30fdf114 87\r
b303ea72
LG
88 if self.DepexType == 'PEI_DEPEX_EXP':\r
89 ModuleType = 'PEIM'\r
90 SecType = 'PEI_DEPEX'\r
91 elif self.DepexType == 'DXE_DEPEX_EXP':\r
92 ModuleType = 'DXE_DRIVER'\r
93 SecType = 'DXE_DEPEX'\r
94 elif self.DepexType == 'SMM_DEPEX_EXP':\r
95 ModuleType = 'DXE_SMM_DRIVER'\r
96 SecType = 'SMM_DEPEX'\r
97 else:\r
98 EdkLogger.error("GenFds", FORMAT_INVALID,\r
99 "Depex type %s is not valid for module %s" % (self.DepexType, ModuleName))\r
30fdf114 100\r
b303ea72
LG
101 InputFile = os.path.join (OutputPath, ModuleName + 'SEC' + SecNum + '.depex')\r
102 InputFile = os.path.normpath(InputFile)\r
103 Depex = DependencyExpression(self.Expression, ModuleType)\r
104 Depex.Generate(InputFile)\r
30fdf114 105\r
b303ea72 106 OutputFile = os.path.join (OutputPath, ModuleName + 'SEC' + SecNum + '.dpx')\r
30fdf114 107 OutputFile = os.path.normpath(OutputFile)\r
b303ea72 108\r
30fdf114
LG
109 GenFdsGlobalVariable.GenerateSection(OutputFile, [InputFile], Section.Section.SectionType.get (SecType))\r
110 FileList = [OutputFile]\r
111 return FileList, self.Alignment\r