2 # Convert an MSA Module class object ot an INF Module class object by filling
3 # several info required by INF file.
5 # Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
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
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.
18 from LoadMsa
import LoadMsa
19 from StoreInf
import StoreInf
20 from Common
.MigrationUtilities
import *
21 from EdkIIWorkspaceGuidsInfo
import gEdkIIWorkspaceGuidsInfo
23 #The default INF version number tool generates.
24 gInfVersion
= "0x00010005"
26 ## Add required version information.
28 # Add the default INF version, EFI specificiation version and EDK release
29 # version to Module class object.
31 # @param Module An input Module class object.
33 def AddModuleMiscVersion(Module
):
35 Module
.Header
.InfVersion
= Version
37 Version
= Module
.Header
.Specification
.get("EFI_SPECIFICATION_VERSION", "")
38 Module
.Header
.UefiSpecificationVersion
= Version
40 Version
= Module
.Header
.Specification
.get("EDK_RELEASE_VERSION", "")
41 Module
.Header
.EdkReleaseVersion
= Version
44 ## Add Module produced library class.
46 # Add the produced library class from library class list whose usage type is
49 # @param Module An input Module class object.
51 def AddModuleProducedLibraryClass(Module
):
52 for LibraryClass
in Module
.LibraryClasses
:
53 if "ALWAYS_PRODUCED" in LibraryClass
.Usage
:
54 Module
.Header
.LibraryClass
.append(LibraryClass
)
57 ## Add Module Package Dependency path.
59 # Translate Package Dependency Guid to a file path relative to workspace.
61 # @param Module An input Module class object.
63 def AddModulePackageDependencyPath(Module
):
64 for PackageDependency
in Module
.PackageDependencies
:
65 PackageGuid
= PackageDependency
.PackageGuid
66 PackageVersion
= PackageDependency
.PackageVersion
68 GuidToFilePath
= gEdkIIWorkspaceGuidsInfo
.ResolvePackageFilePath
69 PackageFilePath
= GuidToFilePath(PackageGuid
, PackageVersion
)
70 PackageDependency
.FilePath
= PackageFilePath
73 ## Add Module Recommended Library Instance path.
75 # Translate Module Recommened Library Instance Guid to a file path relative to
78 # @param Module An input Module class object.
80 def AddModuleRecommonedLibraryInstancePath(Module
):
81 for LibraryClass
in Module
.LibraryClasses
:
82 if "ALWAYS_PRODUCED" in LibraryClass
.Usage
:
85 if LibraryClass
.RecommendedInstanceGuid
== "":
88 LibraryGuid
= LibraryClass
.RecommendedInstanceGuid
89 LibraryVersion
= LibraryClass
.RecommendedIntanceVersion
91 GuidToFilePath
= gEdkIIWorkspaceGuidsInfo
.ResolveModuleFilePath
92 LibraryInstance
= GuidToFilePath(LibraryGuid
, LibraryVersion
)
93 LibraryClass
.RecommendedIntance
= LibraryInstance
96 ## Convert MSA Module class object to INF Module class object.
98 # Convert MSA module class ojbect to INF Module class object by filling in
99 # several information required by INF file.
101 # @param Module An input Module class object.
103 def ConvertMsaModuleToInfModule(Module
):
104 AddModuleMiscVersion(Module
)
105 AddModuleProducedLibraryClass(Module
)
106 AddModulePackageDependencyPath(Module
)
107 AddModuleRecommonedLibraryInstancePath(Module
)
110 if __name__
== '__main__':