1. Refresh applicable library instances after one illegal library instance is removed.

2.Remove library instances that is only consumed by one library instance when deleting this library instance from a module in platform.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2350 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
jlin16 2007-02-02 10:11:03 +00:00
parent 8d92e94ff5
commit e64872fa8b
3 changed files with 113 additions and 28 deletions

View File

@ -58,6 +58,7 @@ import org.tianocore.PlatformHeaderDocument;
import org.tianocore.SkuInfoDocument; import org.tianocore.SkuInfoDocument;
import org.tianocore.UserDefinedAntTasksDocument; import org.tianocore.UserDefinedAntTasksDocument;
import org.tianocore.UserExtensionsDocument; import org.tianocore.UserExtensionsDocument;
import org.tianocore.LibrariesDocument.Libraries.Instance;
import org.tianocore.frameworkwizard.platform.ui.global.WorkspaceProfile; import org.tianocore.frameworkwizard.platform.ui.global.WorkspaceProfile;
import org.tianocore.frameworkwizard.platform.ui.global.SurfaceAreaQuery; import org.tianocore.frameworkwizard.platform.ui.global.SurfaceAreaQuery;
import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification; import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification;
@ -384,7 +385,7 @@ public class FpdFileContents {
cursor.dispose(); cursor.dispose();
} }
public boolean adjustPcd (int seqModuleSa, Vector<String> vExceptions) throws Exception { public boolean adjustPcd (String seqModuleSa, Vector<String> vExceptions) throws Exception {
boolean dataModified = false; boolean dataModified = false;
ModuleSADocument.ModuleSA moduleSa = getModuleSA(seqModuleSa); ModuleSADocument.ModuleSA moduleSa = getModuleSA(seqModuleSa);
int pcdCount = getPcdDataCount(seqModuleSa); int pcdCount = getPcdDataCount(seqModuleSa);
@ -523,8 +524,8 @@ public class FpdFileContents {
// //
// key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer Arch" // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer Arch"
// //
public int getPcdDataCount (int i){ public int getPcdDataCount (String key){
ModuleSADocument.ModuleSA msa = getModuleSA(i); ModuleSADocument.ModuleSA msa = getModuleSA(key);
if (msa == null || msa.getPcdBuildDefinition() == null || msa.getPcdBuildDefinition().getPcdDataList() == null){ if (msa == null || msa.getPcdBuildDefinition() == null || msa.getPcdBuildDefinition().getPcdDataList() == null){
return 0; return 0;
@ -533,8 +534,8 @@ public class FpdFileContents {
} }
public void getPcdData (int i, String[][] saa) { public void getPcdData (String key, String[][] saa) {
ModuleSADocument.ModuleSA msa = getModuleSA(i); ModuleSADocument.ModuleSA msa = getModuleSA(key);
if (msa == null || msa.getPcdBuildDefinition() == null || msa.getPcdBuildDefinition().getPcdDataList() == null){ if (msa == null || msa.getPcdBuildDefinition() == null || msa.getPcdBuildDefinition().getPcdDataList() == null){
return; return;
@ -553,8 +554,8 @@ public class FpdFileContents {
} }
} }
public void removePcdData (int seqModuleSa, String cName, String tsGuid) { public void removePcdData (String key, String cName, String tsGuid) {
ModuleSADocument.ModuleSA moduleSa = getModuleSA(seqModuleSa); ModuleSADocument.ModuleSA moduleSa = getModuleSA(key);
if (moduleSa == null || moduleSa.getPcdBuildDefinition() == null){ if (moduleSa == null || moduleSa.getPcdBuildDefinition() == null){
return; return;
} }
@ -573,7 +574,7 @@ public class FpdFileContents {
PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData)cursor.getObject(); PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData)cursor.getObject();
if (pcdData.getCName().equals(cName) && pcdData.getTokenSpaceGuidCName().equals(tsGuid)) { if (pcdData.getCName().equals(cName) && pcdData.getTokenSpaceGuidCName().equals(tsGuid)) {
maintainDynPcdMap(cName + " " + tsGuid, moduleKey); maintainDynPcdMap(cName + " " + tsGuid, moduleKey);
if (getPcdDataCount(seqModuleSa) == 1) { if (getPcdDataCount(key) == 1) {
cursor.toParent(); cursor.toParent();
} }
cursor.removeXml(); cursor.removeXml();
@ -809,17 +810,21 @@ public class FpdFileContents {
return false; return false;
} }
public void removeLibraryInstance(String key, int i) { public void removeLibraryInstance(String key, String instanceKey) {
ModuleSADocument.ModuleSA msa = getModuleSA(key); ModuleSADocument.ModuleSA msa = getModuleSA(key);
if (msa == null || msa.getLibraries() == null){ if (msa == null || msa.getLibraries() == null){
return ; return ;
} }
String[] instanceInfo = instanceKey.split(" ");
XmlCursor cursor = msa.getLibraries().newCursor(); XmlCursor cursor = msa.getLibraries().newCursor();
if (cursor.toFirstChild()) { if (cursor.toFirstChild()) {
for (int j = 0; j < i; ++j) { do {
cursor.toNextSibling(); Instance libIns = (Instance)cursor.getObject();
if (libIns.getModuleGuid().equalsIgnoreCase(instanceInfo[0]) && libIns.getPackageGuid().equalsIgnoreCase(instanceInfo[2])) {
break;
} }
}while (cursor.toNextSibling());
cursor.push(); cursor.push();
while (cursor.hasPrevToken()) { while (cursor.hasPrevToken()) {
cursor.toPrevToken(); cursor.toPrevToken();

View File

@ -928,9 +928,17 @@ public class FpdFrameworkModules extends IInternalFrame {
private boolean pcdSync(Vector<String> v) { private boolean pcdSync(Vector<String> v) {
boolean synced = false; boolean synced = false;
String[] sa = new String[5];
for (int i = 0; i < jTableFpdModules.getRowCount(); ++i) { for (int i = 0; i < jTableFpdModules.getRowCount(); ++i) {
try { try {
if (ffc.adjustPcd(i, v)) { ffc.getFrameworkModuleInfo(i, sa);
String mg = sa[ffcModGuid];
String mv = sa[ffcModVer];
String pg = sa[ffcPkgGuid];
String pv = sa[ffcPkgVer];
String arch = sa[ffcModArch];
String key = mg + " " + mv + " " + pg + " " + pv + " " + arch;
if (ffc.adjustPcd(key, v)) {
synced = true; synced = true;
} }
} }

View File

@ -96,7 +96,6 @@ public class FpdModuleSA extends JDialog implements ActionListener {
private FpdFileContents ffc = null; private FpdFileContents ffc = null;
private String moduleKey = null; private String moduleKey = null;
private ModuleIdentification moduleId = null; private ModuleIdentification moduleId = null;
private int moduleSaNum = -1;
private HashMap<LibraryClassDescriptor, ArrayList<String>> classInstanceMap = null; private HashMap<LibraryClassDescriptor, ArrayList<String>> classInstanceMap = null;
// //
// map of <{libName, supArch, supMod}, list of Module information> // map of <{libName, supArch, supMod}, list of Module information>
@ -154,13 +153,12 @@ public class FpdModuleSA extends JDialog implements ActionListener {
public void setKey(String k, int i, OpeningPlatformType dc){ public void setKey(String k, int i, OpeningPlatformType dc){
this.moduleKey = k; this.moduleKey = k;
moduleSaNum = i;
this.docConsole = dc; this.docConsole = dc;
classInstanceMap = null; classInstanceMap = null;
classProduced = null; classProduced = null;
classConsumed = null; classConsumed = null;
jTabbedPane.setSelectedIndex(0); jTabbedPane.setSelectedIndex(0);
initPcdBuildDefinition(i); initPcdBuildDefinition(moduleKey);
moduleId = WorkspaceProfile.getModuleId(moduleKey); moduleId = WorkspaceProfile.getModuleId(moduleKey);
if (moduleId == null) { if (moduleId == null) {
return; return;
@ -178,7 +176,7 @@ public class FpdModuleSA extends JDialog implements ActionListener {
init will be called each time FpdModuleSA object is to be shown. init will be called each time FpdModuleSA object is to be shown.
@param key Module information. @param key Module information.
**/ **/
public void initPcdBuildDefinition(int i) { public void initPcdBuildDefinition(String key) {
// //
// display pcd for key. // display pcd for key.
// //
@ -187,10 +185,10 @@ public class FpdModuleSA extends JDialog implements ActionListener {
jComboBoxItemType.setSelectedIndex(-1); jComboBoxItemType.setSelectedIndex(-1);
jTextFieldMaxDatumSize.setText(""); jTextFieldMaxDatumSize.setText("");
jTextFieldPcdDefault.setText(""); jTextFieldPcdDefault.setText("");
int pcdCount = ffc.getPcdDataCount(i); int pcdCount = ffc.getPcdDataCount(key);
if (pcdCount != 0) { if (pcdCount != 0) {
String[][] saa = new String[pcdCount][7]; String[][] saa = new String[pcdCount][7];
ffc.getPcdData(i, saa); ffc.getPcdData(key, saa);
for (int j = 0; j < saa.length; ++j) { for (int j = 0; j < saa.length; ++j) {
model.addRow(saa[j]); model.addRow(saa[j]);
} }
@ -236,6 +234,9 @@ public class FpdModuleSA extends JDialog implements ActionListener {
Stack<LibraryClassDescriptor> lcdStack = new Stack<LibraryClassDescriptor>(); Stack<LibraryClassDescriptor> lcdStack = new Stack<LibraryClassDescriptor>();
while (iter.hasNext()) { while (iter.hasNext()) {
LibraryClassDescriptor lcd = iter.next(); LibraryClassDescriptor lcd = iter.next();
if (this.classConsumed.get(lcd) == null || this.classConsumed.get(lcd).size() == 0) {
continue;
}
if (isBoundedClass(lcd, errorMsg)) { if (isBoundedClass(lcd, errorMsg)) {
continue; continue;
} }
@ -575,12 +576,41 @@ public class FpdModuleSA extends JDialog implements ActionListener {
return null; return null;
} }
private ArrayList<String> getProducedBy (String className) {
Iterator<LibraryClassDescriptor> lcdi = this.classProduced.keySet().iterator();
while (lcdi.hasNext()) {
LibraryClassDescriptor lcd = lcdi.next();
if ((lcd.className != null) && lcd.className.equals(className)) {
return this.classProduced.get(lcd);
}
}
return null;
}
//
// Get class name list related with instanceKey from HashMap m<LibraryClass, ArrayList<instanceKey>>.
//
private ArrayList<String> getLibraryClassList (String instanceKey, HashMap<LibraryClassDescriptor, ArrayList<String>> m) {
ArrayList<String> libraryClass = new ArrayList<String>();
Iterator<LibraryClassDescriptor> lcdi = m.keySet().iterator();
while (lcdi.hasNext()) {
LibraryClassDescriptor lcd = lcdi.next();
if ((m.get(lcd) != null) && m.get(lcd).contains(instanceKey)) {
libraryClass.add(lcd.className);
}
}
return libraryClass;
}
private void removeInstance(String key) { private void removeInstance(String key) {
ModuleIdentification mi = WorkspaceProfile.getModuleId(key); ModuleIdentification mi = WorkspaceProfile.getModuleId(key);
// //
// remove pcd information of instance from current ModuleSA // remove pcd information of instance from current ModuleSA
// Note that Pcd data SHOULD be removed prior to library instance
// because Multi-Sourced PCD could not be removed, if we remove library instance first,
// it will impact the judgement of whether a PCD entry is Multi-Sourced.
// //
ffc.removePcdData(moduleKey, mi); ffc.removePcdData(moduleKey, mi);
ffc.removeLibraryInstance(moduleKey, key);
// //
// remove class produced by this instance and add back these produced class to be bound. // remove class produced by this instance and add back these produced class to be bound.
// //
@ -600,7 +630,25 @@ public class FpdModuleSA extends JDialog implements ActionListener {
continue; continue;
} }
al.remove(key); al.remove(key);
if (al.size() == 0) {
ArrayList<String> from = getProducedBy (clsConsumed[i]);
if (from == null) {
continue;
}
boolean noUse = true;
for (int j = 0; j < from.size(); ++j) {
ArrayList<String> libClasses = getLibraryClassList(from.get(j), classProduced);
for (int k = 0; k < libClasses.size(); ++k) {
if (getConsumedBy (libClasses.get(k)) != null && getConsumedBy (libClasses.get(k)).size() > 0) {
noUse = false;
}
}
if (noUse) {
removeInstance(from.get(j));
}
noUse = true;
}
}
} }
} }
@ -738,7 +786,7 @@ public class FpdModuleSA extends JDialog implements ActionListener {
jPanelPcd.add(getJPanelPcdSouth(), java.awt.BorderLayout.SOUTH); jPanelPcd.add(getJPanelPcdSouth(), java.awt.BorderLayout.SOUTH);
jPanelPcd.addComponentListener(new java.awt.event.ComponentAdapter() { jPanelPcd.addComponentListener(new java.awt.event.ComponentAdapter() {
public void componentShown(java.awt.event.ComponentEvent e) { public void componentShown(java.awt.event.ComponentEvent e) {
initPcdBuildDefinition(moduleSaNum); initPcdBuildDefinition(moduleKey);
} }
}); });
@ -1124,9 +1172,14 @@ public class FpdModuleSA extends JDialog implements ActionListener {
String cls = libClassTableModel.getValueAt(selectedRow2, 0).toString(); String cls = libClassTableModel.getValueAt(selectedRow2, 0).toString();
String arch = libClassTableModel.getValueAt(selectedRow2, 1).toString(); String arch = libClassTableModel.getValueAt(selectedRow2, 1).toString();
String modType = libClassTableModel.getValueAt(selectedRow2, 2).toString(); String modType = libClassTableModel.getValueAt(selectedRow2, 2).toString();
ArrayList<String> al = classInstanceMap.get(new LibraryClassDescriptor(cls, arch, modType)); LibraryClassDescriptor lcd = new LibraryClassDescriptor(cls, arch, modType);
ArrayList<String> al = classInstanceMap.get(lcd);
if (al == null) { if (al == null) {
return; al = getInstancesForClass(lcd, null);
if (al.size() != 0) {
classInstanceMap.put(lcd, al);
}
} }
ListIterator<String> li = al.listIterator(); ListIterator<String> li = al.listIterator();
while(li.hasNext()) { while(li.hasNext()) {
@ -1335,12 +1388,31 @@ public class FpdModuleSA extends JDialog implements ActionListener {
return; return;
} }
docConsole.setSaved(false); docConsole.setSaved(false);
removeInstance(selectedInstancesTableModel.getValueAt(row, 1) + " " + String instanceKey = selectedInstancesTableModel.getValueAt(row, 1) + " "
selectedInstancesTableModel.getValueAt(row, 2) + " " + + selectedInstancesTableModel.getValueAt(row, 2) + " "
selectedInstancesTableModel.getValueAt(row, 3) + " " + + selectedInstancesTableModel.getValueAt(row, 3) + " "
selectedInstancesTableModel.getValueAt(row, 4)); + selectedInstancesTableModel.getValueAt(row, 4);
ffc.removeLibraryInstance(moduleKey, row); removeInstance(instanceKey);
selectedInstancesTableModel.removeRow(row);
selectedInstancesTableModel.setRowCount(0);
int instanceCount = ffc.getLibraryInstancesCount(moduleKey);
if (instanceCount != 0) {
String[][] saa = new String[instanceCount][5];
ffc.getLibraryInstances(moduleKey, saa);
for (int i = 0; i < saa.length; ++i) {
String libInstanceKey = saa[i][1] + " " + saa[i][2] + " " + saa[i][3] + " " + saa[i][4];
ModuleIdentification mi = WorkspaceProfile.getModuleId(libInstanceKey);
if (mi != null) {
//
// ToDo: verify this instance first.
//
saa[i][0] = mi.getName();
saa[i][2] = mi.getVersion();
saa[i][4] = mi.getPackageId().getVersion();
selectedInstancesTableModel.addRow(saa[i]);
}
}
}
showClassToResolved(); showClassToResolved();
} }
}); });