2 # This file is used to define a class object to describe a distribution package
4 # Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
6 # This program and the accompanying materials are licensed and made available
7 # under the terms and conditions of the BSD License which accompanies this
8 # distribution. The full text of the license may be found at
9 # http://opensource.org/licenses/bsd-license.php
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.
15 DistributionPackageClass
23 from Library
.Misc
import Sdict
24 from Library
.Misc
import GetNonMetaDataFiles
25 from PomAdapter
.InfPomAlignment
import InfPomAlignment
26 from PomAdapter
.DecPomAlignment
import DecPomAlignment
27 import Logger
.Log
as Logger
28 from Logger
import StringTable
as ST
29 from Logger
.ToolError
import OPTION_VALUE_INVALID
30 from Logger
.ToolError
import FatalError
31 from Logger
.ToolError
import EDK1_INF_ERROR
32 from Object
.POM
.CommonObject
import IdentificationObject
33 from Object
.POM
.CommonObject
import CommonHeaderObject
34 from Object
.POM
.CommonObject
import MiscFileObject
36 ## DistributionPackageHeaderClass
38 # @param IdentificationObject: Identification Object
39 # @param CommonHeaderObject: Common Header Object
41 class DistributionPackageHeaderObject(IdentificationObject
, \
44 IdentificationObject
.__init
__(self
)
45 CommonHeaderObject
.__init
__(self
)
50 self
.Signature
= 'Md5Sum'
51 self
.XmlSpecification
= ''
53 def GetReadOnly(self
):
56 def SetReadOnly(self
, ReadOnly
):
57 self
.ReadOnly
= ReadOnly
59 def GetRePackage(self
):
62 def SetRePackage(self
, RePackage
):
63 self
.RePackage
= RePackage
68 def SetDate(self
, Date
):
74 def SetSignature(self
, Signature
):
75 self
.Signature
= Signature
77 def GetSignature(self
):
80 def SetXmlSpecification(self
, XmlSpecification
):
81 self
.XmlSpecification
= XmlSpecification
83 def GetXmlSpecification(self
):
84 return self
.XmlSpecification
86 ## DistributionPackageClass
88 # @param object: DistributionPackageClass
90 class DistributionPackageClass(object):
92 self
.Header
= DistributionPackageHeaderObject()
94 # {(Guid, Version, Path) : PackageObj}
96 self
.PackageSurfaceArea
= Sdict()
98 # {(Guid, Version, Name, Path) : ModuleObj}
100 self
.ModuleSurfaceArea
= Sdict()
101 self
.Tools
= MiscFileObject()
102 self
.MiscellaneousFiles
= MiscFileObject()
103 self
.UserExtensions
= []
106 ## Get all included packages and modules for a distribution package
108 # @param WorkspaceDir: WorkspaceDir
109 # @param PackageList: A list of all packages
110 # @param ModuleList: A list of all modules
112 def GetDistributionPackage(self
, WorkspaceDir
, PackageList
, ModuleList
):
117 for PackageFile
in PackageList
:
118 PackageFileFullPath
= \
119 os
.path
.normpath(os
.path
.join(WorkspaceDir
, PackageFile
))
120 DecObj
= DecPomAlignment(PackageFileFullPath
, WorkspaceDir
, CheckMulDec
= True)
123 # Parser inf file one bye one
125 ModuleInfFileList
= PackageObj
.GetModuleFileList()
126 for File
in ModuleInfFileList
:
127 WsRelPath
= os
.path
.join(PackageObj
.GetPackagePath(), File
)
128 WsRelPath
= os
.path
.normpath(WsRelPath
)
129 if ModuleList
and WsRelPath
in ModuleList
:
131 OPTION_VALUE_INVALID
,
132 ST
.ERR_NOT_STANDALONE_MODULE_ERROR
%\
133 (WsRelPath
, PackageFile
))
134 Filename
= os
.path
.normpath\
135 (os
.path
.join(PackageObj
.GetRelaPath(), File
))
136 os
.path
.splitext(Filename
)
138 # Call INF parser to generate Inf Object.
139 # Actually, this call is not directly call, but wrapped by
140 # Inf class in InfPomAlignment.
143 ModuleObj
= InfPomAlignment(Filename
, WorkspaceDir
, \
144 PackageObj
.GetPackagePath())
147 # Add module to package
149 ModuleDict
= PackageObj
.GetModuleDict()
150 ModuleDict
[(ModuleObj
.GetGuid(), \
151 ModuleObj
.GetVersion(), \
152 ModuleObj
.GetName(), \
153 ModuleObj
.GetCombinePath())] = ModuleObj
154 PackageObj
.SetModuleDict(ModuleDict
)
155 except FatalError
, ErrCode
:
156 if ErrCode
.message
== EDK1_INF_ERROR
:
158 ST
.WRN_EDK1_INF_FOUND
%Filename
)
162 self
.PackageSurfaceArea\
163 [(PackageObj
.GetGuid(), PackageObj
.GetVersion(), \
164 PackageObj
.GetCombinePath())] = PackageObj
170 for ModuleFile
in ModuleList
:
171 ModuleFileFullPath
= \
172 os
.path
.normpath(os
.path
.join(WorkspaceDir
, ModuleFile
))
174 ModuleObj
= InfPomAlignment(ModuleFileFullPath
,
176 ModuleKey
= (ModuleObj
.GetGuid(),
177 ModuleObj
.GetVersion(),
179 ModuleObj
.GetCombinePath())
180 self
.ModuleSurfaceArea
[ModuleKey
] = ModuleObj
181 except FatalError
, ErrCode
:
182 if ErrCode
.message
== EDK1_INF_ERROR
:
185 ST
.WRN_EDK1_INF_FOUND
%ModuleFileFullPath
,
186 ExtraData
=ST
.ERR_NOT_SUPPORTED_SA_MODULE
)
190 ## Get all files included for a distribution package, except tool/misc of
193 # @retval DistFileList A list of filepath for NonMetaDataFile, relative to workspace
194 # @retval MetaDataFileList A list of filepath for MetaDataFile, relative to workspace
196 def GetDistributionFileList(self
):
197 MetaDataFileList
= []
199 for Guid
, Version
, Path
in self
.PackageSurfaceArea
:
200 Package
= self
.PackageSurfaceArea
[Guid
, Version
, Path
]
201 PackagePath
= Package
.GetPackagePath()
202 FullPath
= Package
.GetFullPath()
203 MetaDataFileList
.append(Path
)
204 IncludePathList
= Package
.GetIncludePathList()
205 for IncludePath
in IncludePathList
:
206 SearchPath
= os
.path
.normpath(os
.path
.join(os
.path
.dirname(FullPath
), IncludePath
))
207 AddPath
= os
.path
.normpath(os
.path
.join(PackagePath
, IncludePath
))
208 self
.FileList
+= GetNonMetaDataFiles(SearchPath
, ['CVS', '.svn'], False, AddPath
)
211 ModuleDict
= Package
.GetModuleDict()
212 for Guid
, Version
, Name
, Path
in ModuleDict
:
213 Module
= ModuleDict
[Guid
, Version
, Name
, Path
]
214 ModulePath
= Module
.GetModulePath()
215 FullPath
= Module
.GetFullPath()
216 PkgRelPath
= os
.path
.normpath(os
.path
.join(PackagePath
, ModulePath
))
217 MetaDataFileList
.append(Path
)
218 self
.FileList
+= GetNonMetaDataFiles(os
.path
.dirname(FullPath
), ['CVS', '.svn'], False, PkgRelPath
)
220 for Guid
, Version
, Name
, Path
in self
.ModuleSurfaceArea
:
221 Module
= self
.ModuleSurfaceArea
[Guid
, Version
, Name
, Path
]
222 ModulePath
= Module
.GetModulePath()
223 FullPath
= Module
.GetFullPath()
224 MetaDataFileList
.append(Path
)
225 self
.FileList
+= GetNonMetaDataFiles(os
.path
.dirname(FullPath
), ['CVS', '.svn'], False, ModulePath
)
227 return self
.FileList
, MetaDataFileList