summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdLibClassDecls.java10
-rw-r--r--Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdPcdDefs.java4
-rw-r--r--Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdDynamicPcdBuildDefinitions.java6
-rw-r--r--Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFileContents.java206
-rw-r--r--Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFrameworkModules.java25
-rw-r--r--Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdModuleSA.java28
-rw-r--r--Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/TableSorter.java2
-rw-r--r--Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/global/Spd.java2
-rw-r--r--Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/global/SurfaceAreaQuery.java8
-rw-r--r--Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/global/WorkspaceProfile.java508
-rw-r--r--Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/id/ModuleIdentification.java4
-rw-r--r--Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/id/PackageIdentification.java6
-rw-r--r--Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/id/PlatformIdentification.java4
13 files changed, 689 insertions, 124 deletions
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdLibClassDecls.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdLibClassDecls.java
index d1363f7..2a52e31 100644
--- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdLibClassDecls.java
+++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdLibClassDecls.java
@@ -52,7 +52,7 @@ import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
import org.tianocore.frameworkwizard.common.ui.StarLabel;
import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;
import org.tianocore.frameworkwizard.platform.ui.ListEditor;
-import org.tianocore.frameworkwizard.platform.ui.global.GlobalData;
+import org.tianocore.frameworkwizard.platform.ui.global.WorkspaceProfile;
import org.tianocore.frameworkwizard.platform.ui.global.SurfaceAreaQuery;
import org.tianocore.frameworkwizard.platform.ui.id.ModuleIdentification;
import org.tianocore.frameworkwizard.platform.ui.id.PackageIdentification;
@@ -920,19 +920,19 @@ public class SpdLibClassDecls extends IInternalFrame implements TableModelListen
private void getLibInstances(String libClass){
libNameGuidMap.clear();
try {
- GlobalData.initInfo("Tools" + File.separator + "Conf" + File.separator + "FrameworkDatabase.db", System.getenv("WORKSPACE"));
+ WorkspaceProfile.initInfo("Tools" + File.separator + "Conf" + File.separator + "FrameworkDatabase.db", System.getenv("WORKSPACE"));
- Set<PackageIdentification> spi = GlobalData.getPackageList();
+ Set<PackageIdentification> spi = WorkspaceProfile.getPackageList();
Iterator ispi = spi.iterator();
while (ispi.hasNext()) {
PackageIdentification pi = (PackageIdentification) ispi.next();
- Set<ModuleIdentification> smi = GlobalData.getModules(pi);
+ Set<ModuleIdentification> smi = WorkspaceProfile.getModules(pi);
Iterator ismi = smi.iterator();
while (ismi.hasNext()) {
ModuleIdentification mi = (ModuleIdentification) ismi.next();
- Map<String, XmlObject> m = GlobalData.getNativeMsa(mi);
+ Map<String, XmlObject> m = WorkspaceProfile.getNativeMsa(mi);
SurfaceAreaQuery.setDoc(m);
Vector<String> classProduced = SurfaceAreaQuery.getLibraryClasses("ALWAYS_PRODUCED", mi);
for (int i = 0; i < classProduced.size(); ++i) {
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdPcdDefs.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdPcdDefs.java
index c3a71e8..76a4dea 100644
--- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdPcdDefs.java
+++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdPcdDefs.java
@@ -909,8 +909,8 @@ public class SpdPcdDefs extends IInternalFrame implements TableModelListener{
JOptionPane.showMessageDialog(frame, "C_Name is NOT C_NameType.");
return false;
}
- if (!(DataValidation.isHexDoubleWordDataType(row[1].toString()) ||
- DataValidation.isInt(row[1].toString(), 0, 0xffffffff))) {
+ if (!DataValidation.isHexDoubleWordDataType(row[1].toString()) &&
+ !DataValidation.isInt(row[1].toString(), Integer.MIN_VALUE, Integer.MAX_VALUE)) {
JOptionPane.showMessageDialog(frame, "Token is NOT correct.");
return false;
}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdDynamicPcdBuildDefinitions.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdDynamicPcdBuildDefinitions.java
index 416889a..23378cc 100644
--- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdDynamicPcdBuildDefinitions.java
+++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdDynamicPcdBuildDefinitions.java
@@ -481,6 +481,12 @@ public class FpdDynamicPcdBuildDefinitions extends IInternalFrame {
return;
}
else{
+ jTextFieldDefaultValue.setText("");
+ jTextFieldVpdOffset.setText("");
+ jTextFieldVarName.setText("");
+ jTextFieldVarGuid.setText("");
+ jTextFieldVarOffset.setText("");
+ jTextFieldHiiDefaultValue.setText("");
int selected = lsm.getMinSelectionIndex();
displaySkuInfoDetails(selected);
}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFileContents.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFileContents.java
index 2b1cffe..a11a635 100644
--- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFileContents.java
+++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFileContents.java
@@ -57,7 +57,8 @@ import org.tianocore.LicenseDocument;
import org.tianocore.PlatformHeaderDocument;
import org.tianocore.SkuInfoDocument;
import org.tianocore.UserDefinedAntTasksDocument;
-import org.tianocore.frameworkwizard.platform.ui.global.GlobalData;
+import org.tianocore.UserExtensionsDocument;
+import org.tianocore.frameworkwizard.platform.ui.global.WorkspaceProfile;
import org.tianocore.frameworkwizard.platform.ui.global.SurfaceAreaQuery;
import org.tianocore.frameworkwizard.platform.ui.id.ModuleIdentification;
import org.tianocore.frameworkwizard.platform.ui.id.PackageIdentification;
@@ -88,6 +89,8 @@ public class FpdFileContents {
private HashMap<String, ArrayList<String>> dynPcdMap = null;
+ private HashMap<String, String> defaultPcdValue = new HashMap<String, String>();
+
/**
* look through all pcd data in all ModuleSA, create pcd -> ModuleSA mappings.
*/
@@ -329,19 +332,19 @@ public class FpdFileContents {
int libCount = getLibraryInstancesCount(moduleKey);
String[][] saaLib = new String[libCount][5];
getLibraryInstances(moduleKey, saaLib);
- ModuleIdentification mi = GlobalData.getModuleId(moduleKey);
+ ModuleIdentification mi = WorkspaceProfile.getModuleId(moduleKey);
Vector<ModuleIdentification> vMi = new Vector<ModuleIdentification>();
vMi.add(mi);
try {
nextPcd:for (int i = 0; i < saaModuleSaPcd.length; ++i) {
- if (GlobalData.pcdInMsa(saaModuleSaPcd[i][0], saaModuleSaPcd[i][1], mi)){
+ if (WorkspaceProfile.pcdInMsa(saaModuleSaPcd[i][0], saaModuleSaPcd[i][1], mi)){
continue;
}
for (int j = 0; j < saaLib.length; ++j) {
String libKey = saaLib[j][1] + " " + saaLib[j][2] + " " + saaLib[j][3] + " " + saaLib[j][4];
- ModuleIdentification libMi = GlobalData.getModuleId(libKey);
+ ModuleIdentification libMi = WorkspaceProfile.getModuleId(libKey);
vMi.add(libMi);
- if (GlobalData.pcdInMsa(saaModuleSaPcd[i][0], saaModuleSaPcd[i][1], libMi)) {
+ if (WorkspaceProfile.pcdInMsa(saaModuleSaPcd[i][0], saaModuleSaPcd[i][1], libMi)) {
continue nextPcd;
}
}
@@ -358,7 +361,7 @@ public class FpdFileContents {
try {
for (int i = 0; i < vMi.size(); ++i) {
- ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea) GlobalData
+ ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea) WorkspaceProfile
.getModuleXmlObject(vMi
.get(i));
if (msa.getPcdCoded() == null || msa.getPcdCoded().getPcdEntryList() == null) {
@@ -428,6 +431,7 @@ public class FpdFileContents {
}
if (al.size() == 0) {
+ defaultPcdValue.remove(pcdKey);
dynPcdMap.remove(pcdKey);
String[] s1 = pcdKey.split(" ");
removeDynamicPcdBuildData(s1[0], s1[1]);
@@ -516,6 +520,7 @@ public class FpdFileContents {
pcdData.setMaxDatumSize(new Integer(maxSize));
}
pcdData.setValue(value);
+ defaultPcdValue.put(cName + " " + tsGuid, value);
break;
}
}
@@ -533,7 +538,7 @@ public class FpdFileContents {
public boolean getPcdBuildDataInfo(ModuleIdentification mi, String cName, String tsGuid, String[] sa) throws Exception{
try {
- ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)GlobalData.getModuleXmlObject(mi);
+ ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)WorkspaceProfile.getModuleXmlObject(mi);
if (msa.getPcdCoded() == null) {
return false;
}
@@ -586,7 +591,7 @@ public class FpdFileContents {
*/
public void removePcdData(String moduleKey, ModuleIdentification consumer) {
try {
- ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)GlobalData.getModuleXmlObject(consumer);
+ ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)WorkspaceProfile.getModuleXmlObject(consumer);
if (msa.getPcdCoded() == null) {
return;
}
@@ -704,7 +709,7 @@ public class FpdFileContents {
XmlCursor cursor = instance.newCursor();
try{
String comment = "Pkg: " + pn + " Mod: " + mn
- + " Path: " + GlobalData.getMsaFile(libMi).getPath().substring(System.getenv("WORKSPACE").length() + 1);
+ + " Path: " + WorkspaceProfile.getMsaFile(libMi).getPath().substring(System.getenv("WORKSPACE").length() + 1);
cursor.insertComment(comment);
}
catch (Exception e){
@@ -888,7 +893,7 @@ public class FpdFileContents {
moduleSa = genModuleSA(mi, arch);
}
- ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)GlobalData.getModuleXmlObject(mi);
+ ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)WorkspaceProfile.getModuleXmlObject(mi);
if (msa.getPcdCoded() == null) {
return;
}
@@ -932,7 +937,7 @@ public class FpdFileContents {
Map<String, XmlObject> m = new HashMap<String, XmlObject>();
PcdDeclarationsDocument.PcdDeclarations.PcdEntry spdPcd = null;
for (int i = 0; i < depPkgs.length; ++i) {
- m.put("PackageSurfaceArea", GlobalData.getPackageXmlObject(depPkgs[i]));
+ m.put("PackageSurfaceArea", WorkspaceProfile.getPackageXmlObject(depPkgs[i]));
SurfaceAreaQuery.setDoc(m);
XmlObject[] xo = SurfaceAreaQuery.getSpdPcdDeclarations();
if (xo == null) {
@@ -958,12 +963,12 @@ public class FpdFileContents {
}
private ModuleSADocument.ModuleSA genModuleSA (ModuleIdentification mi, String arch) {
- PackageIdentification pi = GlobalData.getPackageForModule(mi);
+ PackageIdentification pi = WorkspaceProfile.getPackageForModule(mi);
ModuleSADocument.ModuleSA msa = getfpdFrameworkModules().addNewModuleSA();
XmlCursor cursor = msa.newCursor();
try{
String comment = "Mod: " + mi.getName() + " Type: " + mi.getModuleType() + " Path: "
- + GlobalData.getMsaFile(mi).getPath().substring(System.getenv("WORKSPACE").length() + 1);
+ + WorkspaceProfile.getMsaFile(mi).getPath().substring(System.getenv("WORKSPACE").length() + 1);
cursor.insertComment(comment);
}
catch(Exception e){
@@ -998,41 +1003,19 @@ public class FpdFileContents {
if (pcdConsumer == null) {
pcdConsumer = new ArrayList<String>();
}
+ //
+ // Using existing Pcd type, if this pcd already exists in other ModuleSA
+ //
+ if (pcdConsumer.size() > 0) {
+ String[] valPart = pcdConsumer.get(0).split(" ");
+ itemType = valPart[5];
+ }
String listValue = moduleSa.getModuleGuid() + " " + moduleSa.getModuleVersion()
+ " " + moduleSa.getPackageGuid() + " " + moduleSa.getPackageVersion() + " " + listToString(moduleSa.getSupArchList())
+ " " + itemType;
pcdConsumer.add(listValue);
dynPcdMap.put(cName + " " + tsGuid, pcdConsumer);
- //
- // Special dynamic type, if this pcd already exists in other ModuleSA
- //
- /* Comment out Item type checking temporarily.
- if (itemType.equals("DYNAMIC")) {
-
- ListIterator li = pcdConsumer.listIterator();
- while(li.hasNext()) {
- String value = li.next().toString();
- String[] valuePart= value.split(" ");
- if (!valuePart[5].equals("DYNAMIC")) {
- //ToDo error for same pcd, other type than dynamic
- pcdConsumer.remove(listValue);
- throw new PcdItemTypeConflictException(cName, value);
- }
- }
- }
- else {
- ListIterator li = pcdConsumer.listIterator();
- while(li.hasNext()) {
- String value = li.next().toString();
- String[] valuePart= value.split(" ");
- if (valuePart[5].equals("DYNAMIC")) {
- //ToDo error for same pcd, other type than non-dynamic
- pcdConsumer.remove(listValue);
- throw new PcdItemTypeConflictException(cName, value);
- }
- }
- }
- */
+
PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData fpdPcd = moduleSa.getPcdBuildDefinition().addNewPcdData();
fpdPcd.setCName(cName);
fpdPcd.setToken(token);
@@ -1054,6 +1037,16 @@ public class FpdFileContents {
fpdPcd.setValue("");
}
}
+ //
+ // Using existing pcd value, if this pcd already exists in other moduleSa.
+ //
+ if (defaultPcdValue.get(cName + " " + tsGuid) == null) {
+ defaultPcdValue.put(cName + " " + tsGuid, fpdPcd.getValue());
+ }
+ else {
+ fpdPcd.setValue(defaultPcdValue.get(cName + " " + tsGuid));
+ }
+
if (dataType.equals("UINT8")){
fpdPcd.setMaxDatumSize(1);
}
@@ -1085,44 +1078,7 @@ public class FpdFileContents {
addDynamicPcdBuildData(cName, token, tsGuid, itemType, dataType, defaultVal);
}
}
- else {
- /*
- if (defaultVal != null){
- fpdPcd.setValue(defaultVal);
- }
- else {
- if (dataType.equals("UINT8") || dataType.equals("UINT16") || dataType.equals("UINT32") || dataType.equals("UINT64")) {
- fpdPcd.setValue("0");
- }
- if (dataType.equals("BOOLEAN")){
- fpdPcd.setValue("false");
- }
- if (dataType.equals("VOID*")) {
- fpdPcd.setValue("");
- }
- }
-
- if (dataType.equals("UINT8")){
- fpdPcd.setMaxDatumSize(1);
- }
- if (dataType.equals("UINT16")) {
- fpdPcd.setMaxDatumSize(2);
- }
- if (dataType.equals("UINT32")) {
- fpdPcd.setMaxDatumSize(4);
- }
- if (dataType.equals("UINT64")){
- fpdPcd.setMaxDatumSize(8);
- }
- if (dataType.equals("BOOLEAN")){
- fpdPcd.setMaxDatumSize(1);
- }
- if (dataType.equals("VOID*")) {
- int maxSize = setMaxSizeForPointer(fpdPcd.getValue());
- fpdPcd.setMaxDatumSize(maxSize);
- }
- */
- }
+
}
public int setMaxSizeForPointer(String datum) throws PcdValueMalFormed{
@@ -1529,6 +1485,92 @@ public class FpdFileContents {
return fpdBuildOpts;
}
+ public void genBuildOptionsUserExtensions(String fvName, String infName, String outputFileName, String[][] includeModules) {
+ UserExtensionsDocument.UserExtensions userExts = getfpdBuildOpts().addNewUserExtensions();
+ userExts.setUserID("IMAGES");
+ userExts.setIdentifier(new BigInteger("1"));
+ XmlCursor cursor = userExts.newCursor();
+ cursor.toEndToken();
+
+ cursor.beginElement("FvName");
+ cursor.insertChars(fvName);
+ cursor.toNextToken();
+
+ cursor.beginElement("InfFileName");
+ cursor.insertChars(infName);
+ cursor.toNextToken();
+
+ cursor.beginElement("IncludeModules");
+ for (int i = 0; i < includeModules.length; ++i) {
+ cursor.beginElement("Module");
+ cursor.insertAttributeWithValue("ModuleGuid", includeModules[i][0]);
+ cursor.insertAttributeWithValue("BaseName", includeModules[i][1]);
+ cursor.toEndToken();
+ cursor.toNextToken();
+ }
+ cursor.dispose();
+ }
+
+ public int getUserExtsIncModCount (String fvName) {
+ if (getfpdBuildOpts().getUserExtensionsList() == null) {
+ return -1;
+ }
+ ListIterator<UserExtensionsDocument.UserExtensions> li = getfpdBuildOpts().getUserExtensionsList().listIterator();
+ while (li.hasNext()) {
+ UserExtensionsDocument.UserExtensions ues = li.next();
+ if (!ues.getUserID().equals("IMAGES")) {
+ continue;
+ }
+ XmlCursor cursor = ues.newCursor();
+ cursor.toFirstChild();
+ String elementName = cursor.getTextValue();
+ if (elementName.equals(fvName)) {
+ cursor.toNextSibling(new QName("", "IncludeModules"));
+ if (cursor.toFirstChild()) {
+ int i = 1;
+ for (i = 1; cursor.toNextSibling(); ++i);
+ cursor.dispose();
+ return i;
+ }
+ cursor.dispose();
+ return 0;
+ }
+ cursor.dispose();
+ }
+ return -1;
+ }
+
+ public void getUserExtsIncMods(String fvName, String[][] saa) {
+ if (getfpdBuildOpts().getUserExtensionsList() == null) {
+ return;
+ }
+ ListIterator<UserExtensionsDocument.UserExtensions> li = getfpdBuildOpts().getUserExtensionsList().listIterator();
+ while (li.hasNext()) {
+ UserExtensionsDocument.UserExtensions ues = li.next();
+ if (!ues.getUserID().equals("IMAGES")) {
+ continue;
+ }
+ XmlCursor cursor = ues.newCursor();
+ cursor.toFirstChild();
+ String elementName = cursor.getTextValue();
+ if (elementName.equals(fvName)) {
+ cursor.toNextSibling(new QName("", "IncludeModules"));
+ if (cursor.toFirstChild()) {
+ int i = 0;
+ do {
+ saa[i][0] = cursor.getAttributeText(new QName("ModuleGuid"));
+ saa[i][1] = cursor.getAttributeText(new QName("BaseName"));
+ ++i;
+ }while (cursor.toNextSibling());
+ }
+ cursor.dispose();
+ return;
+ }
+ cursor.dispose();
+ }
+
+ }
+
public void genBuildOptionsUserDefAntTask (String id, String fileName, String execOrder) {
UserDefinedAntTasksDocument.UserDefinedAntTasks udats = getfpdBuildOpts().getUserDefinedAntTasks();
if (udats == null) {
@@ -2637,7 +2679,7 @@ class PcdItemTypeConflictException extends Exception {
private String details = null;
PcdItemTypeConflictException(String pcdName, String info){
- ModuleIdentification mi = GlobalData.getModuleId(info);
+ ModuleIdentification mi = WorkspaceProfile.getModuleId(info);
details = pcdName + " ItemType Conflicts with " + mi.getName() + " in Pkg " + mi.getPackage().getName();
}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFrameworkModules.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFrameworkModules.java
index 06d0d0d..e0c1167 100644
--- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFrameworkModules.java
+++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFrameworkModules.java
@@ -16,7 +16,7 @@ import javax.swing.table.DefaultTableModel;
import org.tianocore.PlatformSurfaceAreaDocument;
import org.tianocore.frameworkwizard.common.Identifications.OpeningPlatformType;
import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
-import org.tianocore.frameworkwizard.platform.ui.global.GlobalData;
+import org.tianocore.frameworkwizard.platform.ui.global.WorkspaceProfile;
import org.tianocore.frameworkwizard.platform.ui.id.ModuleIdentification;
import org.tianocore.frameworkwizard.platform.ui.id.PackageIdentification;
@@ -326,7 +326,7 @@ public class FpdFrameworkModules extends IInternalFrame {
ModuleIdentification mi = miList.get(selectedRow);
Vector<String> vArchs = null;
try {
- vArchs = GlobalData.getModuleSupArchs(mi);
+ vArchs = WorkspaceProfile.getModuleSupArchs(mi);
}
catch (Exception exp) {
JOptionPane.showMessageDialog(frame, exp.getMessage());
@@ -418,7 +418,9 @@ public class FpdFrameworkModules extends IInternalFrame {
s += " was added Successfully.";
}
JOptionPane.showMessageDialog(frame, s);
- jTableFpdModules.changeSelection(modelFpdModules.getRowCount() - 1, 0, false, false);
+ TableSorter sorterFpdModules = (TableSorter)jTableFpdModules.getModel();
+ int viewIndex = sorterFpdModules.getModelToView()[modelFpdModules.getRowCount() - 1];
+ jTableFpdModules.changeSelection(viewIndex, 0, false, false);
}
});
}
@@ -591,7 +593,7 @@ public class FpdFrameworkModules extends IInternalFrame {
String pg = sa[ffcPkgGuid];
String pv = sa[ffcPkgVer];
String arch = sa[ffcModArch];
- ModuleIdentification mi = GlobalData.getModuleId(mg + " " + mv + " " + pg + " " + pv + " " + arch);
+ ModuleIdentification mi = WorkspaceProfile.getModuleId(mg + " " + mv + " " + pg + " " + pv + " " + arch);
mv = mi.getVersion();
pv = mi.getPackage().getVersion();
modelFpdModules.removeRow(selectedRow);
@@ -644,7 +646,7 @@ public class FpdFrameworkModules extends IInternalFrame {
private void init(PlatformSurfaceAreaDocument.PlatformSurfaceArea fpd) {
try {
- GlobalData.initInfo("Tools" + File.separator + "Conf" + File.separator + "FrameworkDatabase.db", System.getenv("WORKSPACE"));
+ WorkspaceProfile.initInfo("Tools" + File.separator + "Conf" + File.separator + "FrameworkDatabase.db", System.getenv("WORKSPACE"));
}
catch(Exception e){
JOptionPane.showMessageDialog(frame, "Error occurred when getting module data.");
@@ -663,7 +665,7 @@ public class FpdFrameworkModules extends IInternalFrame {
String[][] saa = new String[ffc.getFrameworkModulesCount()][5];
ffc.getFrameworkModulesInfo(saa);
for (int i = 0; i < saa.length; ++i) {
- ModuleIdentification mi = GlobalData.getModuleId(saa[i][ffcModGuid] + " " + saa[i][ffcModVer] + " "
+ ModuleIdentification mi = WorkspaceProfile.getModuleId(saa[i][ffcModGuid] + " " + saa[i][ffcModVer] + " "
+ saa[i][ffcPkgGuid] + " " + saa[i][ffcPkgVer]);
String[] row = { "", "", "", "", "", "", "" };
if (mi != null) {
@@ -674,14 +676,13 @@ public class FpdFrameworkModules extends IInternalFrame {
row[pkgVerColForFpdModTable] = mi.getPackage().getVersion();
row[archColForFpdModTable] = saa[i][ffcModArch];
try {
- row[pathColForFpdModTable] = GlobalData.getMsaFile(mi).getPath().substring(
+ row[pathColForFpdModTable] = WorkspaceProfile.getMsaFile(mi).getPath().substring(
System.getenv("WORKSPACE")
.length() + 1);
} catch (Exception e) {
JOptionPane.showMessageDialog(frame, "Show FPD Modules:" + e.getMessage());
}
- modelFpdModules.addRow(row);
String fpdMsaKey = saa[i][ffcModGuid] + row[modVerColForFpdModTable]
+ saa[i][ffcPkgGuid] + row[pkgVerColForFpdModTable];
ArrayList<String> al = fpdMsa.get(fpdMsaKey);
@@ -691,7 +692,7 @@ public class FpdFrameworkModules extends IInternalFrame {
}
al.add(saa[i][ffcModArch]);
}
-
+ modelFpdModules.addRow(row);
}
TableSorter sorter = (TableSorter)jTableFpdModules.getModel();
@@ -707,14 +708,14 @@ public class FpdFrameworkModules extends IInternalFrame {
if (miList == null) {
miList = new ArrayList<ModuleIdentification>();
}
- Set<PackageIdentification> spi = GlobalData.getPackageList();
+ Set<PackageIdentification> spi = WorkspaceProfile.getPackageList();
Iterator ispi = spi.iterator();
while (ispi.hasNext()) {
PackageIdentification pi = (PackageIdentification) ispi.next();
String[] s = { "", "", "", "", "", "" };
- Set<ModuleIdentification> smi = GlobalData.getModules(pi);
+ Set<ModuleIdentification> smi = WorkspaceProfile.getModules(pi);
Iterator ismi = smi.iterator();
while (ismi.hasNext()) {
ModuleIdentification mi = (ModuleIdentification) ismi.next();
@@ -724,7 +725,7 @@ public class FpdFrameworkModules extends IInternalFrame {
s[pkgNameColForAllModTable] = pi.getName();
s[pkgVerColForAllModTable] = pi.getVersion();
try {
- s[pathColForAllModTable] = GlobalData.getMsaFile(mi).getPath()
+ s[pathColForAllModTable] = WorkspaceProfile.getMsaFile(mi).getPath()
.substring(System.getenv("WORKSPACE").length() + 1);
} catch (Exception e) {
JOptionPane.showMessageDialog(frame, "Show All Modules:" + e.getMessage());
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdModuleSA.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdModuleSA.java
index a34fa5a..ed3b6e2 100644
--- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdModuleSA.java
+++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdModuleSA.java
@@ -25,7 +25,7 @@ import javax.swing.table.TableModel;
import org.tianocore.frameworkwizard.common.DataValidation;
import org.tianocore.frameworkwizard.common.Identifications.OpeningPlatformType;
-import org.tianocore.frameworkwizard.platform.ui.global.GlobalData;
+import org.tianocore.frameworkwizard.platform.ui.global.WorkspaceProfile;
import org.tianocore.frameworkwizard.platform.ui.global.SurfaceAreaQuery;
import org.tianocore.frameworkwizard.platform.ui.id.ModuleIdentification;
import org.tianocore.frameworkwizard.platform.ui.id.PackageIdentification;
@@ -151,6 +151,10 @@ public class FpdModuleSA extends JDialog implements ActionListener {
// display pcd for key.
//
model.setRowCount(0);
+ jTextAreaPcdHelp.setText("");
+ jComboBoxItemType.setSelectedIndex(-1);
+ jTextFieldMaxDatumSize.setText("");
+ jTextFieldPcdDefault.setText("");
int pcdCount = ffc.getPcdDataCount(i);
if (pcdCount != 0) {
String[][] saa = new String[pcdCount][7];
@@ -175,7 +179,7 @@ public class FpdModuleSA extends JDialog implements ActionListener {
String[][] saa = new String[instanceCount][5];
ffc.getLibraryInstances(key, saa);
for (int i = 0; i < saa.length; ++i) {
- ModuleIdentification mi = GlobalData.getModuleId(saa[i][1] + " " + saa[i][2] + " " + saa[i][3] + " " + saa[i][4]);
+ ModuleIdentification mi = WorkspaceProfile.getModuleId(saa[i][1] + " " + saa[i][2] + " " + saa[i][3] + " " + saa[i][4]);
if (mi != null) {
saa[i][0] = mi.getName();
saa[i][2] = mi.getVersion();
@@ -221,7 +225,7 @@ public class FpdModuleSA extends JDialog implements ActionListener {
}
private void resolveLibraryInstances(String key) {
- ModuleIdentification mi = GlobalData.getModuleId(key);
+ ModuleIdentification mi = WorkspaceProfile.getModuleId(key);
PackageIdentification[] depPkgList = null;
try{
//
@@ -288,7 +292,7 @@ public class FpdModuleSA extends JDialog implements ActionListener {
ArrayList<String> al = new ArrayList<String>();
for (int i = 0; i < depPkgList.length; ++i) {
- Set<ModuleIdentification> smi = GlobalData.getModules(depPkgList[i]);
+ Set<ModuleIdentification> smi = WorkspaceProfile.getModules(depPkgList[i]);
Iterator ismi = smi.iterator();
while(ismi.hasNext()) {
ModuleIdentification mi = (ModuleIdentification)ismi.next();
@@ -319,7 +323,7 @@ public class FpdModuleSA extends JDialog implements ActionListener {
}
private void removeInstance(String key) {
- ModuleIdentification mi = GlobalData.getModuleId(key);
+ ModuleIdentification mi = WorkspaceProfile.getModuleId(key);
//
// remove pcd information of instance from current ModuleSA
//
@@ -629,11 +633,11 @@ public class FpdModuleSA extends JDialog implements ActionListener {
ffc.getLibraryInstances(moduleKey, saa);
try{
- if (ffc.getPcdBuildDataInfo(GlobalData.getModuleId(moduleKey), cName, tsGuid, sa)) {
+ if (ffc.getPcdBuildDataInfo(WorkspaceProfile.getModuleId(moduleKey), cName, tsGuid, sa)) {
return;
}
for (int j = 0; j < saa.length; ++j) {
- if (ffc.getPcdBuildDataInfo(GlobalData.getModuleId(saa[j][1] + " " + saa[j][2] + " " + saa[j][3] + " " + saa[j][4]),
+ if (ffc.getPcdBuildDataInfo(WorkspaceProfile.getModuleId(saa[j][1] + " " + saa[j][2] + " " + saa[j][3] + " " + saa[j][4]),
cName, tsGuid, sa)) {
return;
}
@@ -841,8 +845,8 @@ public class FpdModuleSA extends JDialog implements ActionListener {
while(li.hasNext()) {
String instance = li.next();
String[] s = {"", "", "", "", ""};
- if (GlobalData.getModuleId(instance) != null) {
- s[0] = GlobalData.getModuleId(instance).getName();
+ if (WorkspaceProfile.getModuleId(instance) != null) {
+ s[0] = WorkspaceProfile.getModuleId(instance).getName();
}
String[] instancePart = instance.split(" ");
@@ -981,7 +985,7 @@ public class FpdModuleSA extends JDialog implements ActionListener {
libInstanceTableModel.getValueAt(row, 2) + " " +
libInstanceTableModel.getValueAt(row, 3) + " " +
libInstanceTableModel.getValueAt(row, 4);
- ModuleIdentification libMi = GlobalData.getModuleId(instanceValue);
+ ModuleIdentification libMi = WorkspaceProfile.getModuleId(instanceValue);
ffc.genLibraryInstance(libMi, moduleKey);
//
// Add pcd information of selected instance to current moduleSA
@@ -1438,6 +1442,10 @@ private JComboBox getJComboBoxItemType() {
if (jComboBoxItemType.getItemCount() == 3) {
if (!jComboBoxItemType.getSelectedItem().equals("DYNAMIC")) {
pcdDynamicToNonDynamic(jTablePcd.getValueAt(row, 0)+"", jTablePcd.getValueAt(row, 1)+"");
+ if (jComboBoxItemType.getSelectedItem().equals("FIXED_AT_BUILD")) {
+ jTextFieldPcdDefault.setText("");
+ jTextFieldPcdDefault.setEnabled(true);
+ }
}
else{
pcdNonDynamicToDynamic(jTablePcd.getValueAt(row, 0)+"", jTablePcd.getValueAt(row, 1)+"");
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/TableSorter.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/TableSorter.java
index d7f1f13..2453f12 100644
--- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/TableSorter.java
+++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/TableSorter.java
@@ -158,7 +158,7 @@ public class TableSorter extends AbstractTableModel {
return getViewToModel()[viewIndex].modelIndex;
}
- private int[] getModelToView() {
+ public int[] getModelToView() {
if (modelToView == null) {
int n = getViewToModel().length;
modelToView = new int[n];
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/global/Spd.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/global/Spd.java
index 914c5bf..0a8f335 100644
--- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/global/Spd.java
+++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/global/Spd.java
@@ -79,7 +79,7 @@ public class Spd {
if (!msaFile.exists()) {
continue;
}
- Map<String, XmlObject> msaDoc = GlobalData.getNativeMsa( msaFile );
+ Map<String, XmlObject> msaDoc = WorkspaceProfile.getNativeMsa( msaFile );
SurfaceAreaQuery.push(msaDoc);
ModuleIdentification moduleId = SurfaceAreaQuery.getMsaHeader();
SurfaceAreaQuery.pop();
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/global/SurfaceAreaQuery.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/global/SurfaceAreaQuery.java
index 7e70970..ac08143 100644
--- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/global/SurfaceAreaQuery.java
+++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/global/SurfaceAreaQuery.java
@@ -349,7 +349,7 @@ public class SurfaceAreaQuery {
String packageGuid = null;
String packageVersion = null;
- ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea) GlobalData.getModuleXmlObject(mi);
+ ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea) WorkspaceProfile.getModuleXmlObject(mi);
if (msa.getPackageDependencies() == null) {
return new PackageIdentification[0];
}
@@ -365,7 +365,7 @@ public class SurfaceAreaQuery {
packageGuid = item.getPackageGuid();
packageVersion = item.getPackageVersion();
- Set<PackageIdentification> spi = GlobalData.getPackageList();
+ Set<PackageIdentification> spi = WorkspaceProfile.getPackageList();
Iterator<PackageIdentification> ispi = spi.iterator();
String ver = "";
while(ispi.hasNext()) {
@@ -404,7 +404,7 @@ public class SurfaceAreaQuery {
* @returns null if nothing is there
*/
public static Vector<String> getLibraryClasses(String usage, ModuleIdentification mi) throws Exception{
- ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)GlobalData.getModuleXmlObject(mi);
+ ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)WorkspaceProfile.getModuleXmlObject(mi);
Vector<String> libraryClassName = new Vector<String>();
if (msa.getLibraryClassDefinitions() == null) {
return libraryClassName;
@@ -1018,7 +1018,7 @@ public class SurfaceAreaQuery {
if (returns == null) {
return packageIncludeMap;
}
- GlobalData.log.info("" + returns[0].getClass().getName());
+ WorkspaceProfile.log.info("" + returns[0].getClass().getName());
for (int i = 0; i < returns.length; i++) {
PackageHeadersDocument.PackageHeaders.IncludePkgHeader includeHeader = (PackageHeadersDocument.PackageHeaders.IncludePkgHeader) returns[i];
packageIncludeMap.put(includeHeader.getModuleType().toString(),
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/global/WorkspaceProfile.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/global/WorkspaceProfile.java
new file mode 100644
index 0000000..007df77
--- /dev/null
+++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/global/WorkspaceProfile.java
@@ -0,0 +1,508 @@
+/** @file
+ WorkspaceProfile class.
+
+ WorkspaceProfile provide initializing, instoring, querying and update global data.
+ It is a bridge to intercommunicate between multiple component, such as AutoGen,
+ PCD and so on.
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+**/
+package org.tianocore.frameworkwizard.platform.ui.global;
+
+import org.apache.xmlbeans.XmlObject;
+import org.tianocore.DbPathAndFilename;
+import org.tianocore.FrameworkDatabaseDocument;
+import org.tianocore.ModuleSurfaceAreaDocument;
+import org.tianocore.PcdCodedDocument;
+import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;
+import org.tianocore.frameworkwizard.platform.ui.id.FpdModuleIdentification;
+import org.tianocore.frameworkwizard.platform.ui.id.ModuleIdentification;
+import org.tianocore.frameworkwizard.platform.ui.id.PackageIdentification;
+import org.tianocore.frameworkwizard.platform.ui.id.PlatformIdentification;
+
+import java.io.File;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.Vector;
+import java.util.logging.Logger;
+
+/**
+ WorkspaceProfile provide initializing, instoring, querying and update global data.
+ It is a bridge to intercommunicate between multiple component, such as AutoGen,
+ PCD and so on.
+
+ <p>Note that all global information are initialized incrementally. All data will
+ parse and record only of necessary during build time. </p>
+
+ @since GenBuild 1.0
+**/
+public class WorkspaceProfile {
+
+
+ public static Logger log = Logger.getAnonymousLogger();
+ public static KeyComparator comparator = new KeyComparator();
+ ///
+ /// Record current WORKSPACE Directory
+ ///
+ private static String workspaceDir = "";
+
+ ///
+ /// Be used to ensure Global data will be initialized only once.
+ ///
+// private static boolean globalFlag = false;
+
+ ///
+ /// Framework Database information: package list and platform list
+ ///
+ private static Set<PackageIdentification> packageList = new HashSet<PackageIdentification>();
+
+ private static Set<PlatformIdentification> platformList = new HashSet<PlatformIdentification>();
+
+ ///
+ /// Every detail SPD informations: Module list, Library class definition,
+ /// Package header file, GUID/PPI/Protocol definitions
+ ///
+ private static final Map<PackageIdentification, Spd> spdTable = new HashMap<PackageIdentification, Spd>();
+
+ ///
+ /// Build informations are divided into three parts:
+ /// 1. From MSA 2. From FPD 3. From FPD' ModuleSA
+ ///
+ private static Map<ModuleIdentification, Map<String, XmlObject>> nativeMsa = new HashMap<ModuleIdentification, Map<String, XmlObject>>();
+
+ private static Map<FpdModuleIdentification, Map<String, XmlObject>> fpdModuleSA= new HashMap<FpdModuleIdentification, Map<String, XmlObject>>();
+
+ private static XmlObject fpdBuildOptions;
+
+ private static XmlObject fpdDynamicPcds;
+
+ ///
+ /// Parsed modules list
+ ///
+ private static Map<FpdModuleIdentification, Map<String, XmlObject>> parsedModules = new HashMap<FpdModuleIdentification, Map<String, XmlObject>>();
+
+ ///
+ /// built modules list with ARCH, TARGET, TOOLCHAIN
+ ///
+ private static Set<FpdModuleIdentification> builtModules = new HashSet<FpdModuleIdentification>();
+
+ /**
+ Parse framework database (DB) and all SPD files listed in DB to initialize
+ the environment for next build. This method will only be executed only once
+ in the whole build process.
+
+ @param workspaceDatabaseFile the file name of framework database
+ @param workspaceDir current workspace directory path
+ @throws Exception
+ Framework Dababase or SPD or MSA file is not valid
+ **/
+ public synchronized static void initInfo(String workspaceDatabaseFile, String workspaceDir) throws Exception {
+
+ //
+ // Backup workspace directory. It will be used by other method
+ //
+ WorkspaceProfile.workspaceDir = workspaceDir.replaceAll("(\\\\)", "/");
+ File dbFile = new File(workspaceDir + File.separatorChar + workspaceDatabaseFile);
+ try {
+ FrameworkDatabaseDocument db = (FrameworkDatabaseDocument) XmlObject.Factory.parse(dbFile);
+ //
+ // validate FrameworkDatabaseFile
+ //
+// if (! db.validate()) {
+// throw new Exception("Framework Database file [" + dbFile.getPath() + "] is invalid.");
+// }
+ //
+ // Get package list
+ //
+ packageList.clear();
+ List<DbPathAndFilename> packages = db.getFrameworkDatabase().getPackageList().getFilenameList();
+
+ Iterator iter = packages.iterator();
+ while (iter.hasNext()) {
+ DbPathAndFilename dbPath = (DbPathAndFilename)iter.next();
+ String fileName = dbPath.getStringValue();
+ Spd spd = new Spd(new File(workspaceDir + File.separatorChar + fileName));
+ packageList.add(spd.getPackageId());
+ spdTable.put(spd.getPackageId(), spd);
+ }
+
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new Exception("Parse workspace Database [" + dbFile.getPath() + "] Error.\n" + e.getMessage());
+ }
+ }
+
+ /**
+ Get the current WORKSPACE Directory.
+
+ @return current workspace directory
+ **/
+ public synchronized static String getWorkspacePath() {
+ return workspaceDir;
+ }
+
+
+ /**
+ Get the MSA file name with absolute path
+ */
+ public synchronized static File getMsaFile(ModuleIdentification moduleId) throws Exception {
+ File msaFile = null;
+ //
+ // TBD. Do only when package is null.
+ //
+ Iterator iter = packageList.iterator();
+ while (iter.hasNext()) {
+ PackageIdentification packageId = (PackageIdentification)iter.next();
+ Spd spd = spdTable.get(packageId);
+ msaFile = spd.getModuleFile(moduleId);
+ if (msaFile != null ) {
+ break ;
+ }
+ }
+ if (msaFile == null){
+ throw new Exception("Can't find Module [" + moduleId.getName() + "] in all packages. ");
+ }
+ else {
+ return msaFile;
+ }
+ }
+
+ public synchronized static PackageIdentification getPackageForModule(ModuleIdentification moduleId) {
+ //
+ // If package already defined in module
+ //
+ if (moduleId.getPackage() != null) {
+ return moduleId.getPackage();
+ }
+
+ PackageIdentification packageId = null;
+ Iterator iter = packageList.iterator();
+ while (iter.hasNext()) {
+ packageId = (PackageIdentification)iter.next();
+
+ Spd spd = spdTable.get(packageId);
+ if (spd.getModuleFile(moduleId) != null ) {
+ moduleId.setPackage(packageId);
+ break ;
+ }
+ }
+ if (packageId == null){
+ return null;
+ }
+ else {
+ return packageId;
+ }
+ }
+
+ /**
+ Difference between build and parse: ToolChain and Target
+ **/
+ public synchronized static boolean isModuleBuilt(FpdModuleIdentification moduleId) {
+ return builtModules.contains(moduleId);
+ }
+
+ public synchronized static void registerBuiltModule(FpdModuleIdentification fpdModuleId) {
+ builtModules.add(fpdModuleId);
+ }
+
+
+ public synchronized static void registerFpdModuleSA(FpdModuleIdentification fpdModuleId, Map<String, XmlObject> doc) throws Exception{
+ Map<String, XmlObject> result = new HashMap<String, XmlObject>();
+ Set keySet = doc.keySet();
+ Iterator iter = keySet.iterator();
+ while (iter.hasNext()){
+ String key = (String)iter.next();
+ XmlObject item = cloneXmlObject(doc.get(key), true);
+ result.put(key, item);
+ }
+ fpdModuleSA.put(fpdModuleId, result);
+ }
+
+ /**
+ Query overrided module surface area information. If current is Package
+ or Platform build, also include the information from FPD file.
+
+ <p>Note that surface area parsing is incremental. That means the method will
+ only parse the MSA and MBD files if necessary. </p>
+
+ @param moduleName the base name of the module
+ @return the overrided module surface area information
+ @throws Exception
+ MSA or MBD is not valid
+ **/
+ public synchronized static Map<String, XmlObject> getDoc(FpdModuleIdentification fpdModuleId) throws Exception {
+ if (parsedModules.containsKey(fpdModuleId)) {
+ return parsedModules.get(fpdModuleId);
+ }
+ Map<String, XmlObject> doc = new HashMap<String, XmlObject>();
+ ModuleIdentification moduleId = fpdModuleId.getModule();
+ //
+ // First part: get the MSA files info
+ //
+ doc = getNativeMsa(moduleId);
+
+ //
+ // Second part: put build options
+ //
+ doc.put("BuildOptions", fpdBuildOptions);
+
+ //
+ // Third part: get Module info from FPD, such as Library instances, PCDs
+ //
+ if (fpdModuleSA.containsKey(fpdModuleId)){
+ //
+ // merge module info in FPD to final Doc
+ // For Library Module, do nothing here
+ //
+ doc.putAll(fpdModuleSA.get(fpdModuleId));
+ }
+ parsedModules.put(fpdModuleId, doc);
+ return doc;
+ }
+
+ public synchronized static Map<String, XmlObject> getDoc(ModuleIdentification moduleId, String arch) throws Exception {
+ FpdModuleIdentification fpdModuleId = new FpdModuleIdentification(moduleId, arch);
+ return getDoc(fpdModuleId);
+ }
+ /**
+ Query the native MSA information with module base name.
+
+ <p>Note that MSA parsing is incremental. That means the method will
+ only to parse the MSA files when never parsed before. </p>
+
+ @param moduleName the base name of the module
+ @return the native MSA information
+ @throws Exception
+ MSA file is not valid
+ **/
+ public synchronized static Map<String, XmlObject> getNativeMsa(ModuleIdentification moduleId) throws Exception {
+ if (nativeMsa.containsKey(moduleId)) {
+ return nativeMsa.get(moduleId);
+ }
+ File msaFile = getMsaFile(moduleId);
+ Map<String, XmlObject> msaMap = getNativeMsa(msaFile);
+ nativeMsa.put(moduleId, msaMap);
+ return msaMap;
+ }
+
+ public synchronized static Map<String, XmlObject> getNativeMsa(File msaFile) throws Exception {
+
+ try {
+ ModuleSurfaceAreaDocument doc = (ModuleSurfaceAreaDocument)XmlObject.Factory.parse(msaFile);
+ //
+ // Validate File if they accord with XML Schema
+ //
+// if ( ! doc.validate()){
+// throw new Exception("Module Surface Area file [" + msaFile.getPath() + "] is invalid.");
+// }
+ //
+ // parse MSA file
+ //
+ ModuleSurfaceArea msa= doc.getModuleSurfaceArea();
+ Map<String, XmlObject> msaMap = new HashMap<String, XmlObject>();
+ msaMap.put("ModuleSurfaceArea", msa);
+ msaMap.put("MsaHeader", cloneXmlObject(msa.getMsaHeader(), true));
+ msaMap.put("LibraryClassDefinitions", cloneXmlObject(msa.getLibraryClassDefinitions(), true));
+ msaMap.put("SourceFiles", cloneXmlObject(msa.getSourceFiles(), true));
+ msaMap.put("PackageDependencies", cloneXmlObject(msa.getPackageDependencies(), true));
+ msaMap.put("Protocols", cloneXmlObject(msa.getProtocols(), true));
+ msaMap.put("PPIs", cloneXmlObject(msa.getPPIs(), true));
+ msaMap.put("Guids", cloneXmlObject(msa.getGuids(), true));
+ msaMap.put("Externs", cloneXmlObject(msa.getExterns(), true));
+ return msaMap;
+ }
+ catch (Exception ex){
+ throw new Exception(ex.getMessage());
+ }
+ }
+
+ public static Map<String, XmlObject> getFpdBuildOptions() {
+ Map<String, XmlObject> map = new HashMap<String, XmlObject>();
+ map.put("BuildOptions", fpdBuildOptions);
+ return map;
+ }
+
+ public static void setFpdBuildOptions(XmlObject fpdBuildOptions) throws Exception{
+ WorkspaceProfile.fpdBuildOptions = cloneXmlObject(fpdBuildOptions, true);
+ }
+
+ public static XmlObject getFpdDynamicPcds() {
+ return fpdDynamicPcds;
+ }
+
+ public static void setFpdDynamicPcds(XmlObject fpdDynamicPcds) {
+ WorkspaceProfile.fpdDynamicPcds = fpdDynamicPcds;
+ }
+
+ //////////////////////////////////////////////
+ //////////////////////////////////////////////
+
+ public static Set<ModuleIdentification> getModules(PackageIdentification packageId){
+ Spd spd = spdTable.get(packageId);
+ if (spd == null ) {
+ Set<ModuleIdentification> dummy = new HashSet<ModuleIdentification>();
+ return dummy;
+ }
+ else {
+ return spd.getModules();
+ }
+ }
+
+ public synchronized static PlatformIdentification getPlatform(String name) throws Exception {
+ Iterator iter = platformList.iterator();
+ while(iter.hasNext()){
+ PlatformIdentification platformId = (PlatformIdentification)iter.next();
+ if (platformId.getName().equalsIgnoreCase(name)) {
+ WorkspaceProfile.log.info("Platform: " + platformId + platformId.getFpdFile());
+ return platformId;
+ }
+ }
+ throw new Exception("Can't find platform [" + name + "] in current workspace. ");
+ }
+
+ public synchronized static File getPackageFile(PackageIdentification packageId) throws Exception {
+ Iterator iter = packageList.iterator();
+ while(iter.hasNext()){
+ PackageIdentification packageItem = (PackageIdentification)iter.next();
+ if (packageItem.equals(packageId)) {
+ packageId.setName(packageItem.getName());
+ return packageItem.getSpdFile();
+ }
+ }
+ throw new Exception("Can't find " + packageId + " in current workspace. ");
+ }
+
+ public synchronized static File getModuleFile(ModuleIdentification moduleId) throws Exception {
+ PackageIdentification packageId = getPackageForModule(moduleId);
+ moduleId.setPackage(packageId);
+ Spd spd = spdTable.get(packageId);
+ return spd.getModuleFile(moduleId);
+ }
+ //
+ // expanded by FrameworkWizard
+ //
+ public synchronized static XmlObject getModuleXmlObject(ModuleIdentification moduleId) throws Exception {
+ PackageIdentification packageId = getPackageForModule(moduleId);
+ moduleId.setPackage(packageId);
+ Spd spd = spdTable.get(packageId);
+ return spd.msaDocMap.get(moduleId);
+ }
+
+ public synchronized static XmlObject getPackageXmlObject(PackageIdentification packageId) {
+ Spd spd = spdTable.get(packageId);
+ if (spd != null){
+ return spd.spdDocMap.get("PackageSurfaceArea");
+ }
+ return null;
+ }
+
+ public synchronized static Set<PackageIdentification> getPackageList(){
+ return packageList;
+ }
+ ///// remove!!
+ private static XmlObject cloneXmlObject(XmlObject object, boolean deep) throws Exception {
+ if ( object == null) {
+ return null;
+ }
+ XmlObject result = null;
+ try {
+ result = XmlObject.Factory.parse(object.getDomNode()
+ .cloneNode(deep));
+ } catch (Exception ex) {
+ throw new Exception(ex.getMessage());
+ }
+ return result;
+ }
+
+ public static ModuleIdentification getModuleId(String key){
+ //
+ // Get ModuleGuid, ModuleVersion, PackageGuid, PackageVersion, Arch into string array.
+ //
+ String[] keyPart = key.split(" ");
+ Set<PackageIdentification> spi = WorkspaceProfile.getPackageList();
+ Iterator ispi = spi.iterator();
+
+ while(ispi.hasNext()) {
+ PackageIdentification pi = (PackageIdentification)ispi.next();
+ if ( !pi.getGuid().equalsIgnoreCase(keyPart[2])){
+
+ continue;
+ }
+ if (keyPart[3] != null && keyPart[3].length() > 0 && !keyPart[3].equals("null")){
+ if(!pi.getVersion().equals(keyPart[3])){
+ continue;
+ }
+ }
+ Set<ModuleIdentification> smi = WorkspaceProfile.getModules(pi);
+ Iterator ismi = smi.iterator();
+ while(ismi.hasNext()) {
+ ModuleIdentification mi = (ModuleIdentification)ismi.next();
+ if (mi.getGuid().equalsIgnoreCase(keyPart[0])){
+ if (keyPart[1] != null && keyPart[1].length() > 0 && !keyPart[1].equals("null")){
+ if(!mi.getVersion().equals(keyPart[1])){
+ continue;
+ }
+ }
+
+ return mi;
+ }
+ }
+ }
+ return null;
+ }
+
+ public static Vector<String> getModuleSupArchs(ModuleIdentification mi) throws Exception {
+ Vector<String> vArchs = null;
+ ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)getModuleXmlObject(mi);
+ if (msa.getModuleDefinitions() == null || msa.getModuleDefinitions().getSupportedArchitectures() == null) {
+ return vArchs;
+ }
+ ListIterator li = msa.getModuleDefinitions().getSupportedArchitectures().listIterator();
+ while (li.hasNext()) {
+ if (vArchs == null) {
+ vArchs = new Vector<String>();
+ }
+ vArchs.add((String)li.next());
+ }
+
+ return vArchs;
+ }
+
+ public static boolean pcdInMsa (String cName, String tsGuid, ModuleIdentification mi) throws Exception {
+ ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)getModuleXmlObject(mi);
+ if (msa.getPcdCoded() == null || msa.getPcdCoded().getPcdEntryList() == null) {
+ return false;
+ }
+ ListIterator li = msa.getPcdCoded().getPcdEntryList().listIterator();
+ while (li.hasNext()) {
+ PcdCodedDocument.PcdCoded.PcdEntry msaPcd = (PcdCodedDocument.PcdCoded.PcdEntry)li.next();
+ if (msaPcd.getCName().equals(cName) && msaPcd.getTokenSpaceGuidCName().equals(tsGuid)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+}
+
+final class KeyComparator implements Comparator<String> {
+ public int compare(String x, String y) {
+ return x.compareToIgnoreCase(y);
+ }
+
+}
+
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/id/ModuleIdentification.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/id/ModuleIdentification.java
index 7409f9a..913a65a 100644
--- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/id/ModuleIdentification.java
+++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/id/ModuleIdentification.java
@@ -2,7 +2,7 @@ package org.tianocore.frameworkwizard.platform.ui.id;
import java.io.File;
-import org.tianocore.frameworkwizard.platform.ui.global.GlobalData;
+import org.tianocore.frameworkwizard.platform.ui.global.WorkspaceProfile;
public class ModuleIdentification extends Identification {
@@ -34,7 +34,7 @@ public class ModuleIdentification extends Identification {
private void prepareMsaFile()throws Exception{
if (msaFile == null) {
- msaFile = GlobalData.getModuleFile(this);
+ msaFile = WorkspaceProfile.getModuleFile(this);
}
}
public void setMsaFile(File msaFile) {
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/id/PackageIdentification.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/id/PackageIdentification.java
index 9ba5511..2f42e6f 100644
--- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/id/PackageIdentification.java
+++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/id/PackageIdentification.java
@@ -1,7 +1,7 @@
package org.tianocore.frameworkwizard.platform.ui.id;
import java.io.File;
-import org.tianocore.frameworkwizard.platform.ui.global.GlobalData;
+import org.tianocore.frameworkwizard.platform.ui.global.WorkspaceProfile;
public class PackageIdentification extends Identification{
@@ -48,12 +48,12 @@ public class PackageIdentification extends Identification{
public String getPackageRelativeDir()throws Exception{
prepareSpdFile();
- return spdFile.getParent().substring(GlobalData.getWorkspacePath().length() + 1);
+ return spdFile.getParent().substring(WorkspaceProfile.getWorkspacePath().length() + 1);
}
private void prepareSpdFile() throws Exception{
if (spdFile == null) {
- spdFile = GlobalData.getPackageFile(this);
+ spdFile = WorkspaceProfile.getPackageFile(this);
}
}
}
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/id/PlatformIdentification.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/id/PlatformIdentification.java
index 499c669..d01c475 100644
--- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/id/PlatformIdentification.java
+++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/id/PlatformIdentification.java
@@ -1,7 +1,7 @@
package org.tianocore.frameworkwizard.platform.ui.id;
import java.io.File;
-import org.tianocore.frameworkwizard.platform.ui.global.GlobalData;
+import org.tianocore.frameworkwizard.platform.ui.global.WorkspaceProfile;
public class PlatformIdentification extends Identification{
@@ -34,6 +34,6 @@ public class PlatformIdentification extends Identification{
}
public String getPlatformRelativeDir(){
- return fpdFile.getParent().substring(GlobalData.getWorkspacePath().length());
+ return fpdFile.getParent().substring(WorkspaceProfile.getWorkspacePath().length());
}
} \ No newline at end of file