]>
Commit | Line | Data |
---|---|---|
1bf9fa5a | 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 | |
8 | Copyright (c) 2006, Intel Corporation\r | |
9 | All rights reserved. This program and the accompanying materials\r | |
10 | are licensed and made available under the terms and conditions of the BSD License\r | |
11 | which accompanies this distribution. The full text of the license may be found at\r | |
12 | http://opensource.org/licenses/bsd-license.php\r | |
13 | \r | |
14 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
15 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
16 | **/\r | |
17 | package org.tianocore.frameworkwizard.platform.ui.global;\r | |
18 | \r | |
1bf9fa5a | 19 | import org.tianocore.ModuleSurfaceAreaDocument;\r |
3658f95e | 20 | import org.tianocore.PackageSurfaceAreaDocument;\r |
1bf9fa5a | 21 | import org.tianocore.PcdCodedDocument;\r |
3658f95e | 22 | import org.tianocore.frameworkwizard.common.GlobalData;\r |
23 | import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification;\r | |
24 | import org.tianocore.frameworkwizard.packaging.PackageIdentification;\r | |
1bf9fa5a | 25 | import java.util.Iterator;\r |
1bf9fa5a | 26 | import java.util.ListIterator;\r |
1bf9fa5a | 27 | import java.util.Vector;\r |
1bf9fa5a | 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 | |
39 | public class WorkspaceProfile {\r | |
1bf9fa5a | 40 | ///\r |
41 | /// Record current WORKSPACE Directory\r | |
42 | ///\r | |
43 | private static String workspaceDir = "";\r | |
44 | \r | |
1bf9fa5a | 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 | |
1bf9fa5a | 54 | public synchronized static PackageIdentification getPackageForModule(ModuleIdentification moduleId) {\r |
55 | //\r | |
56 | // If package already defined in module\r | |
57 | //\r | |
3658f95e | 58 | if (moduleId.getPackageId() != null) {\r |
59 | return moduleId.getPackageId();\r | |
1bf9fa5a | 60 | }\r |
61 | \r | |
3658f95e | 62 | return null;\r |
1bf9fa5a | 63 | }\r |
64 | //\r | |
65 | // expanded by FrameworkWizard\r | |
66 | //\r | |
3658f95e | 67 | public synchronized static ModuleSurfaceAreaDocument.ModuleSurfaceArea getModuleXmlObject(ModuleIdentification moduleId) {\r |
68 | return GlobalData.openingModuleList.getModuleSurfaceAreaFromId(moduleId);\r | |
1bf9fa5a | 69 | }\r |
70 | \r | |
3658f95e | 71 | public synchronized static PackageSurfaceAreaDocument.PackageSurfaceArea getPackageXmlObject(PackageIdentification packageId) {\r |
72 | return GlobalData.openingPackageList.getPackageSurfaceAreaFromId(packageId);\r | |
1bf9fa5a | 73 | }\r |
74 | \r | |
1bf9fa5a | 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 | |
3658f95e | 80 | \r |
81 | Iterator<ModuleIdentification> iMiList = GlobalData.vModuleList.iterator();\r | |
1bf9fa5a | 82 | \r |
3658f95e | 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 | |
1bf9fa5a | 91 | \r |
3658f95e | 92 | PackageIdentification pi = mi.getPackageId();\r |
93 | if ( !pi.getGuid().equalsIgnoreCase(keyPart[2])){ \r | |
1bf9fa5a | 94 | continue;\r |
95 | }\r | |
3658f95e | 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 | |
1bf9fa5a | 99 | }\r |
1bf9fa5a | 100 | }\r |
3658f95e | 101 | return mi;\r |
1bf9fa5a | 102 | }\r |
103 | }\r | |
3658f95e | 104 | \r |
1bf9fa5a | 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 | |
2b70a636 | 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 | |
1b69863a | 133 | public static boolean pcdInMsa (String cName, String tsGuid, ModuleIdentification mi) {\r |
1bf9fa5a | 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 | |
1bf9fa5a | 150 | \r |