]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/global/WorkspaceProfile.java
Generate Module Orders in FV at BuildOptions, UserExtensions with UserId "IMAGES...
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / platform / ui / global / WorkspaceProfile.java
... / ...
CommitLineData
1/** @file\r
2 WorkspaceProfile class. \r
3 \r
4 WorkspaceProfile provide initializing, instoring, querying and update global data.\r
5 It is a bridge to intercommunicate between multiple component, such as AutoGen,\r
6 PCD and so on. \r
7 \r
8Copyright (c) 2006, Intel Corporation\r
9All rights reserved. This program and the accompanying materials\r
10are licensed and made available under the terms and conditions of the BSD License\r
11which accompanies this distribution. The full text of the license may be found at\r
12http://opensource.org/licenses/bsd-license.php\r
13\r
14THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
15WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
16**/\r
17package org.tianocore.frameworkwizard.platform.ui.global;\r
18\r
19import org.tianocore.ModuleSurfaceAreaDocument;\r
20import org.tianocore.PackageSurfaceAreaDocument;\r
21import org.tianocore.PcdCodedDocument;\r
22import org.tianocore.frameworkwizard.common.GlobalData;\r
23import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification;\r
24import org.tianocore.frameworkwizard.packaging.PackageIdentification;\r
25import java.util.Iterator;\r
26import java.util.ListIterator;\r
27import java.util.Vector;\r
28\r
29/**\r
30 WorkspaceProfile provide initializing, instoring, querying and update global data.\r
31 It is a bridge to intercommunicate between multiple component, such as AutoGen,\r
32 PCD and so on. \r
33 \r
34 <p>Note that all global information are initialized incrementally. All data will \r
35 parse and record only of necessary during build time. </p>\r
36 \r
37 @since GenBuild 1.0\r
38**/\r
39public class WorkspaceProfile {\r
40 ///\r
41 /// Record current WORKSPACE Directory\r
42 ///\r
43 private static String workspaceDir = "";\r
44 \r
45 /**\r
46 Get the current WORKSPACE Directory. \r
47 \r
48 @return current workspace directory\r
49 **/\r
50 public synchronized static String getWorkspacePath() {\r
51 return workspaceDir;\r
52 }\r
53\r
54 public synchronized static PackageIdentification getPackageForModule(ModuleIdentification moduleId) {\r
55 //\r
56 // If package already defined in module\r
57 //\r
58 if (moduleId.getPackageId() != null) {\r
59 return moduleId.getPackageId();\r
60 }\r
61 \r
62 return null;\r
63 }\r
64 //\r
65 // expanded by FrameworkWizard\r
66 //\r
67 public synchronized static ModuleSurfaceAreaDocument.ModuleSurfaceArea getModuleXmlObject(ModuleIdentification moduleId) {\r
68 return GlobalData.openingModuleList.getModuleSurfaceAreaFromId(moduleId);\r
69 }\r
70 \r
71 public synchronized static PackageSurfaceAreaDocument.PackageSurfaceArea getPackageXmlObject(PackageIdentification packageId) {\r
72 return GlobalData.openingPackageList.getPackageSurfaceAreaFromId(packageId);\r
73 }\r
74 \r
75 public static ModuleIdentification getModuleId(String key){\r
76 //\r
77 // Get ModuleGuid, ModuleVersion, PackageGuid, PackageVersion, Arch into string array.\r
78 //\r
79 String[] keyPart = key.split(" ");\r
80\r
81 Iterator<ModuleIdentification> iMiList = GlobalData.vModuleList.iterator();\r
82 \r
83 while (iMiList.hasNext()) {\r
84 ModuleIdentification mi = iMiList.next();\r
85 if (mi.getGuid().equalsIgnoreCase(keyPart[0])){\r
86 if (keyPart[1] != null && keyPart[1].length() > 0 && !keyPart[1].equals("null")){\r
87 if(!mi.getVersion().equals(keyPart[1])){\r
88 continue;\r
89 }\r
90 }\r
91\r
92 PackageIdentification pi = mi.getPackageId();\r
93 if ( !pi.getGuid().equalsIgnoreCase(keyPart[2])){ \r
94 continue;\r
95 }\r
96 if (keyPart[3] != null && keyPart[3].length() > 0 && !keyPart[3].equals("null")){\r
97 if(!pi.getVersion().equals(keyPart[3])){\r
98 continue;\r
99 }\r
100 }\r
101 return mi;\r
102 }\r
103 }\r
104 \r
105 return null;\r
106 }\r
107 \r
108 public static Vector<String> getModuleSupArchs(ModuleIdentification mi) throws Exception {\r
109 Vector<String> vArchs = null;\r
110 ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)getModuleXmlObject(mi);\r
111 if (msa.getModuleDefinitions() == null || msa.getModuleDefinitions().getSupportedArchitectures() == null) {\r
112 return vArchs;\r
113 }\r
114 ListIterator li = msa.getModuleDefinitions().getSupportedArchitectures().listIterator();\r
115 while (li.hasNext()) {\r
116 if (vArchs == null) {\r
117 vArchs = new Vector<String>();\r
118 }\r
119 vArchs.add((String)li.next());\r
120 }\r
121 \r
122 return vArchs;\r
123 }\r
124 \r
125 public static String getModuleBaseName (ModuleIdentification mi) {\r
126 ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = getModuleXmlObject(mi);\r
127 if (msa.getModuleDefinitions() == null || msa.getModuleDefinitions().getOutputFileBasename() == null) {\r
128 return null;\r
129 }\r
130 return msa.getModuleDefinitions().getOutputFileBasename();\r
131 }\r
132 \r
133 public static boolean pcdInMsa (String cName, String tsGuid, ModuleIdentification mi) throws Exception {\r
134 ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)getModuleXmlObject(mi);\r
135 if (msa.getPcdCoded() == null || msa.getPcdCoded().getPcdEntryList() == null) {\r
136 return false;\r
137 }\r
138 ListIterator li = msa.getPcdCoded().getPcdEntryList().listIterator();\r
139 while (li.hasNext()) {\r
140 PcdCodedDocument.PcdCoded.PcdEntry msaPcd = (PcdCodedDocument.PcdCoded.PcdEntry)li.next();\r
141 if (msaPcd.getCName().equals(cName) && msaPcd.getTokenSpaceGuidCName().equals(tsGuid)) {\r
142 return true;\r
143 }\r
144 }\r
145 return false;\r
146 }\r
147 \r
148}\r
149\r
150\r