]> git.proxmox.com Git - mirror_edk2.git/blob - 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
1 ## @file
2 # process depex section generation
3 #
4 # Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
5 #
6 # This program and the accompanying materials
7 # are licensed and made available under the terms and conditions of the BSD License
8 # which accompanies this distribution. The full text of the license may be found at
9 # http://opensource.org/licenses/bsd-license.php
10 #
11 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 #
14
15 ##
16 # Import Modules
17 #
18 import Section
19 from GenFdsGlobalVariable import GenFdsGlobalVariable
20 import subprocess
21 from Ffs import Ffs
22 import Common.LongFilePathOs as os
23 from CommonDataClass.FdfClass import DepexSectionClassObject
24 from AutoGen.GenDepex import DependencyExpression
25 from Common import EdkLogger
26 from Common.BuildToolError import *
27
28 ## generate data section
29 #
30 #
31 class DepexSection (DepexSectionClassObject):
32 ## The constructor
33 #
34 # @param self The object pointer
35 #
36 def __init__(self):
37 DepexSectionClassObject.__init__(self)
38
39 def __FindGuidValue(self, CName):
40 for Arch in GenFdsGlobalVariable.ArchList:
41 for PkgDb in GenFdsGlobalVariable.WorkSpace.GetPackageList(GenFdsGlobalVariable.ActivePlatform,
42 Arch,
43 GenFdsGlobalVariable.TargetName,
44 GenFdsGlobalVariable.ToolChainTag):
45 if CName in PkgDb.Ppis:
46 return PkgDb.Ppis[CName]
47 if CName in PkgDb.Protocols:
48 return PkgDb.Protocols[CName]
49 if CName in PkgDb.Guids:
50 return PkgDb.Guids[CName]
51 return None
52
53 ## GenSection() method
54 #
55 # Generate compressed section
56 #
57 # @param self The object pointer
58 # @param OutputPath Where to place output file
59 # @param ModuleName Which module this section belongs to
60 # @param SecNum Index of section
61 # @param KeyStringList Filter for inputs of section generation
62 # @param FfsInf FfsInfStatement object that contains this section data
63 # @param Dict dictionary contains macro and its value
64 # @retval tuple (Generated file name list, section alignment)
65 #
66 def GenSection(self, OutputPath, ModuleName, SecNum, keyStringList, FfsFile = None, Dict = {}):
67
68 if self.ExpressionProcessed == False:
69 self.Expression = self.Expression.replace("\n", " ").replace("\r", " ")
70 ExpList = self.Expression.split()
71 ExpGuidDict = {}
72
73 for Exp in ExpList:
74 if Exp.upper() not in ('AND', 'OR', 'NOT', 'TRUE', 'FALSE', 'SOR', 'BEFORE', 'AFTER', 'END'):
75 GuidStr = self.__FindGuidValue(Exp)
76 if GuidStr == None:
77 EdkLogger.error("GenFds", RESOURCE_NOT_AVAILABLE,
78 "Depex GUID %s could not be found in build DB! (ModuleName: %s)" % (Exp, ModuleName))
79
80 ExpGuidDict[Exp] = GuidStr
81
82 for Item in ExpGuidDict:
83 self.Expression = self.Expression.replace(Item, ExpGuidDict[Item])
84
85 self.Expression = self.Expression.strip()
86 self.ExpressionProcessed = True
87
88 if self.DepexType == 'PEI_DEPEX_EXP':
89 ModuleType = 'PEIM'
90 SecType = 'PEI_DEPEX'
91 elif self.DepexType == 'DXE_DEPEX_EXP':
92 ModuleType = 'DXE_DRIVER'
93 SecType = 'DXE_DEPEX'
94 elif self.DepexType == 'SMM_DEPEX_EXP':
95 ModuleType = 'DXE_SMM_DRIVER'
96 SecType = 'SMM_DEPEX'
97 else:
98 EdkLogger.error("GenFds", FORMAT_INVALID,
99 "Depex type %s is not valid for module %s" % (self.DepexType, ModuleName))
100
101 InputFile = os.path.join (OutputPath, ModuleName + 'SEC' + SecNum + '.depex')
102 InputFile = os.path.normpath(InputFile)
103 Depex = DependencyExpression(self.Expression, ModuleType)
104 Depex.Generate(InputFile)
105
106 OutputFile = os.path.join (OutputPath, ModuleName + 'SEC' + SecNum + '.dpx')
107 OutputFile = os.path.normpath(OutputFile)
108
109 GenFdsGlobalVariable.GenerateSection(OutputFile, [InputFile], Section.Section.SectionType.get (SecType))
110 FileList = [OutputFile]
111 return FileList, self.Alignment