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