]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/msa2inf/ConvertModule.py
Check In tool source code based on Build tool project revision r1655.
[mirror_edk2.git] / BaseTools / Source / Python / msa2inf / ConvertModule.py
1 ## @file
2 # Convert an MSA Module class object ot an INF Module class object by filling
3 # several info required by INF file.
4 #
5 # Copyright (c) 2007, Intel Corporation
6 # All rights reserved. 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 from LoadMsa import LoadMsa
19 from StoreInf import StoreInf
20 from Common.MigrationUtilities import *
21 from EdkIIWorkspaceGuidsInfo import gEdkIIWorkspaceGuidsInfo
22
23 #The default INF version number tool generates.
24 gInfVersion = "0x00010005"
25
26 ## Add required version information.
27 #
28 # Add the default INF version, EFI specificiation version and EDK release
29 # version to Module class object.
30 #
31 # @param Module An input Module class object.
32 #
33 def AddModuleMiscVersion(Module):
34 Version = gInfVersion
35 Module.Header.InfVersion = Version
36
37 Version = Module.Header.Specification.get("EFI_SPECIFICATION_VERSION", "")
38 Module.Header.EfiSpecificationVersion = Version
39
40 Version = Module.Header.Specification.get("EDK_RELEASE_VERSION", "")
41 Module.Header.EdkReleaseVersion = Version
42
43
44 ## Add Module produced library class.
45 #
46 # Add the produced library class from library class list whose usage type is
47 # always produced.
48 #
49 # @param Module An input Module class object.
50 #
51 def AddModuleProducedLibraryClass(Module):
52 for LibraryClass in Module.LibraryClasses:
53 if "ALWAYS_PRODUCED" in LibraryClass.Usage:
54 Module.Header.LibraryClass.append(LibraryClass)
55
56
57 ## Add Module Package Dependency path.
58 #
59 # Translate Package Dependency Guid to a file path relative to workspace.
60 #
61 # @param Module An input Module class object.
62 #
63 def AddModulePackageDependencyPath(Module):
64 for PackageDependency in Module.PackageDependencies:
65 PackageGuid = PackageDependency.PackageGuid
66 PackageVersion = PackageDependency.PackageVersion
67
68 GuidToFilePath = gEdkIIWorkspaceGuidsInfo.ResolvePackageFilePath
69 PackageFilePath = GuidToFilePath(PackageGuid, PackageVersion)
70 PackageDependency.FilePath = PackageFilePath
71
72
73 ## Add Module Recommended Library Instance path.
74 #
75 # Translate Module Recommened Library Instance Guid to a file path relative to
76 # workspace.
77 #
78 # @param Module An input Module class object.
79 #
80 def AddModuleRecommonedLibraryInstancePath(Module):
81 for LibraryClass in Module.LibraryClasses:
82 if "ALWAYS_PRODUCED" in LibraryClass.Usage:
83 continue
84
85 if LibraryClass.RecommendedInstanceGuid == "":
86 continue
87
88 LibraryGuid = LibraryClass.RecommendedInstanceGuid
89 LibraryVersion = LibraryClass.RecommendedIntanceVersion
90
91 GuidToFilePath = gEdkIIWorkspaceGuidsInfo.ResolveModuleFilePath
92 LibraryInstance = GuidToFilePath(LibraryGuid, LibraryVersion)
93 LibraryClass.RecommendedIntance = LibraryInstance
94
95
96 ## Convert MSA Module class object to INF Module class object.
97 #
98 # Convert MSA module class ojbect to INF Module class object by filling in
99 # several information required by INF file.
100 #
101 # @param Module An input Module class object.
102 #
103 def ConvertMsaModuleToInfModule(Module):
104 AddModuleMiscVersion(Module)
105 AddModuleProducedLibraryClass(Module)
106 AddModulePackageDependencyPath(Module)
107 AddModuleRecommonedLibraryInstancePath(Module)
108
109
110 if __name__ == '__main__':
111 pass
112