]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/AutoGen/DataPipe.py
BaseTools: Fix the bug of --cmd-len build option
[mirror_edk2.git] / BaseTools / Source / Python / AutoGen / DataPipe.py
1 ## @file
2 # Create makefile for MS nmake and GNU make
3 #
4 # Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
5 # SPDX-License-Identifier: BSD-2-Clause-Patent
6 #
7 from __future__ import absolute_import
8 from Workspace.WorkspaceDatabase import BuildDB
9 from Workspace.WorkspaceCommon import GetModuleLibInstances
10 import Common.GlobalData as GlobalData
11 import os
12 import pickle
13 from pickle import HIGHEST_PROTOCOL
14 from Common import EdkLogger
15
16 class PCD_DATA():
17 def __init__(self,TokenCName,TokenSpaceGuidCName,Type,DatumType,SkuInfoList,DefaultValue,
18 MaxDatumSize,UserDefinedDefaultStoresFlag,validateranges,
19 validlists,expressions,CustomAttribute,TokenValue):
20 self.TokenCName = TokenCName
21 self.TokenSpaceGuidCName = TokenSpaceGuidCName
22 self.Type = Type
23 self.DatumType = DatumType
24 self.SkuInfoList = SkuInfoList
25 self.DefaultValue = DefaultValue
26 self.MaxDatumSize = MaxDatumSize
27 self.UserDefinedDefaultStoresFlag = UserDefinedDefaultStoresFlag
28 self.validateranges = validateranges
29 self.validlists = validlists
30 self.expressions = expressions
31 self.CustomAttribute = CustomAttribute
32 self.TokenValue = TokenValue
33
34 class DataPipe(object):
35 def __init__(self, BuildDir=None):
36 self.data_container = {}
37 self.BuildDir = BuildDir
38 self.dump_file = ""
39
40 class MemoryDataPipe(DataPipe):
41
42 def Get(self,key):
43 return self.data_container.get(key)
44
45 def dump(self,file_path):
46 self.dump_file = file_path
47 with open(file_path,'wb') as fd:
48 pickle.dump(self.data_container,fd,pickle.HIGHEST_PROTOCOL)
49
50 def load(self,file_path):
51 with open(file_path,'rb') as fd:
52 self.data_container = pickle.load(fd)
53
54 @property
55 def DataContainer(self):
56 return self.data_container
57 @DataContainer.setter
58 def DataContainer(self,data):
59 self.data_container.update(data)
60
61 def FillData(self,PlatformInfo):
62 #Platform Pcds
63 self.DataContainer = {
64 "PLA_PCD" : [PCD_DATA(
65 pcd.TokenCName,pcd.TokenSpaceGuidCName,pcd.Type,
66 pcd.DatumType,pcd.SkuInfoList,pcd.DefaultValue,
67 pcd.MaxDatumSize,pcd.UserDefinedDefaultStoresFlag,pcd.validateranges,
68 pcd.validlists,pcd.expressions,pcd.CustomAttribute,pcd.TokenValue)
69 for pcd in PlatformInfo.Platform.Pcds.values()]
70 }
71
72 #Platform Module Pcds
73 ModulePcds = {}
74 for m in PlatformInfo.Platform.Modules:
75 module = PlatformInfo.Platform.Modules[m]
76 m_pcds = module.Pcds
77 if m_pcds:
78 ModulePcds[module.Guid] = [PCD_DATA(
79 pcd.TokenCName,pcd.TokenSpaceGuidCName,pcd.Type,
80 pcd.DatumType,pcd.SkuInfoList,pcd.DefaultValue,
81 pcd.MaxDatumSize,pcd.UserDefinedDefaultStoresFlag,pcd.validateranges,
82 pcd.validlists,pcd.expressions,pcd.CustomAttribute,pcd.TokenValue)
83 for pcd in PlatformInfo.Platform.Modules[m].Pcds.values()]
84
85
86 self.DataContainer = {"MOL_PCDS":ModulePcds}
87
88 #Module's Library Instance
89 ModuleLibs = {}
90 libModules = {}
91 for m in PlatformInfo.Platform.Modules:
92 module_obj = BuildDB.BuildObject[m,PlatformInfo.Arch,PlatformInfo.BuildTarget,PlatformInfo.ToolChain]
93 Libs = GetModuleLibInstances(module_obj, PlatformInfo.Platform, BuildDB.BuildObject, PlatformInfo.Arch,PlatformInfo.BuildTarget,PlatformInfo.ToolChain,PlatformInfo.MetaFile,EdkLogger)
94 for lib in Libs:
95 try:
96 libModules[(lib.MetaFile.File,lib.MetaFile.Root,lib.Arch,lib.MetaFile.Path)].append((m.File,m.Root,module_obj.Arch,m.Path))
97 except:
98 libModules[(lib.MetaFile.File,lib.MetaFile.Root,lib.Arch,lib.MetaFile.Path)] = [(m.File,m.Root,module_obj.Arch,m.Path)]
99 ModuleLibs[(m.File,m.Root,module_obj.Arch,m.Path)] = [(l.MetaFile.File,l.MetaFile.Root,l.Arch,l.MetaFile.Path) for l in Libs]
100 self.DataContainer = {"DEPS":ModuleLibs}
101 self.DataContainer = {"REFS":libModules}
102
103 #Platform BuildOptions
104
105 platform_build_opt = PlatformInfo.EdkIIBuildOption
106
107 ToolDefinition = PlatformInfo.ToolDefinition
108 module_build_opt = {}
109 for m in PlatformInfo.Platform.Modules:
110 ModuleTypeOptions, PlatformModuleOptions = PlatformInfo.GetGlobalBuildOptions(BuildDB.BuildObject[m,PlatformInfo.Arch,PlatformInfo.BuildTarget,PlatformInfo.ToolChain])
111 if ModuleTypeOptions or PlatformModuleOptions:
112 module_build_opt.update({(m.File,m.Root): {"ModuleTypeOptions":ModuleTypeOptions, "PlatformModuleOptions":PlatformModuleOptions}})
113
114 self.DataContainer = {"PLA_BO":platform_build_opt,
115 "TOOLDEF":ToolDefinition,
116 "MOL_BO":module_build_opt
117 }
118
119
120
121 #Platform Info
122 PInfo = {
123 "WorkspaceDir":PlatformInfo.Workspace.WorkspaceDir,
124 "Target":PlatformInfo.BuildTarget,
125 "ToolChain":PlatformInfo.Workspace.ToolChain,
126 "BuildRuleFile":PlatformInfo.BuildRule,
127 "Arch": PlatformInfo.Arch,
128 "ArchList":PlatformInfo.Workspace.ArchList,
129 "ActivePlatform":PlatformInfo.MetaFile
130 }
131 self.DataContainer = {'P_Info':PInfo}
132
133 self.DataContainer = {'M_Name':PlatformInfo.UniqueBaseName}
134
135 self.DataContainer = {"ToolChainFamily": PlatformInfo.ToolChainFamily}
136
137 self.DataContainer = {"BuildRuleFamily": PlatformInfo.BuildRuleFamily}
138
139 self.DataContainer = {"MixedPcd":GlobalData.MixedPcd}
140
141 self.DataContainer = {"BuildOptPcd":GlobalData.BuildOptionPcd}
142
143 self.DataContainer = {"BuildCommand": PlatformInfo.BuildCommand}
144
145 self.DataContainer = {"AsBuildModuleList": PlatformInfo._AsBuildModuleList}
146
147 self.DataContainer = {"G_defines": GlobalData.gGlobalDefines}
148
149 self.DataContainer = {"CL_defines": GlobalData.gCommandLineDefines}
150
151 self.DataContainer = {"gCommandMaxLength": GlobalData.gCommandMaxLength}
152
153 self.DataContainer = {"Env_Var": {k:v for k, v in os.environ.items()}}
154
155 self.DataContainer = {"PackageList": [(dec.MetaFile,dec.Arch) for dec in PlatformInfo.PackageList]}
156
157 self.DataContainer = {"GuidDict": PlatformInfo.Platform._GuidDict}
158
159 self.DataContainer = {"DatabasePath":GlobalData.gDatabasePath}
160
161 self.DataContainer = {"FdfParser": True if GlobalData.gFdfParser else False}
162
163 self.DataContainer = {"LogLevel": EdkLogger.GetLevel()}
164
165 self.DataContainer = {"UseHashCache":GlobalData.gUseHashCache}
166
167 self.DataContainer = {"BinCacheSource":GlobalData.gBinCacheSource}
168
169 self.DataContainer = {"BinCacheDest":GlobalData.gBinCacheDest}
170
171 self.DataContainer = {"EnableGenfdsMultiThread":GlobalData.gEnableGenfdsMultiThread}