mirror of https://github.com/acidanthera/audk.git
Enhance MsaOwner.java
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1760 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
edbacf2e5c
commit
8270b34d9d
|
@ -49,7 +49,6 @@ public final class Database {
|
|||
BufferedReader rd = new BufferedReader(new FileReader(DatabasePath + File.separator + filename));
|
||||
String line;
|
||||
String[] linecontext;
|
||||
Func lf;
|
||||
|
||||
if (rd.ready()) {
|
||||
System.out.println("Found " + filename + ", Importing Package Guid Database.");
|
||||
|
|
|
@ -14,6 +14,8 @@ package org.tianocore.migration;
|
|||
|
||||
import java.util.regex.*;
|
||||
|
||||
import org.tianocore.UsageTypes;
|
||||
|
||||
public class Guid {
|
||||
Guid (String r8, String t, String n, String r9, String gv, String p) {
|
||||
r8name = r8;
|
||||
|
@ -48,11 +50,14 @@ public class Guid {
|
|||
if (MigrationTool.db.hasGuid(temp)) { // only changed guids registered, because both changed and not changed guids are included in database
|
||||
type = MigrationTool.db.getGuidType(temp);
|
||||
if (type.matches("Protocol")) {
|
||||
mi.protocols.add(temp);
|
||||
mi.addProtocol(temp, UsageTypes.ALWAYS_CONSUMED);
|
||||
//mi.protocols.add(temp);
|
||||
} else if (type.matches("Ppi")) {
|
||||
mi.ppis.add(temp);
|
||||
mi.addPpi(temp, UsageTypes.ALWAYS_CONSUMED);
|
||||
//mi.ppis.add(temp);
|
||||
} else if (type.matches("Guid")) {
|
||||
mi.guids.add(temp);
|
||||
mi.addGuid(temp, UsageTypes.ALWAYS_CONSUMED);
|
||||
//mi.guids.add(temp);
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
|
|
|
@ -51,15 +51,10 @@ public class MigrationTool {
|
|||
show(mi.hashnonlocalfunc, "nonlocal : ");
|
||||
show(mi.hashr8only, "hashr8only : ");
|
||||
}
|
||||
|
||||
new MsaWriter(mi).flush();
|
||||
|
||||
mi.addProtocol("protocol", UsageTypes.ALWAYS_CONSUMED);
|
||||
mi.addGuid("guid", UsageTypes.ALWAYS_CONSUMED);
|
||||
mi.addLibraryClass("class", UsageTypes.ALWAYS_CONSUMED);
|
||||
mi.addPpi("ppi", UsageTypes.ALWAYS_CONSUMED);
|
||||
mi.getMsaOwner().flush(MigrationTool.ModuleInfoMap.get(mi) + File.separator + "Migration_" + mi.modulename + File.separator + mi.modulename + ".___");
|
||||
|
||||
//mi.getMsaOwner().flush(MigrationTool.ModuleInfoMap.get(mi) + File.separator + "Migration_" + mi.modulename + File.separator + mi.modulename + ".___");
|
||||
|
||||
if (MigrationTool.doCritic) {
|
||||
Critic.fireAt(ModuleInfoMap.get(mi) + File.separator + "Migration_" + mi.modulename);
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ import java.io.*;
|
|||
import java.util.*;
|
||||
|
||||
import org.tianocore.UsageTypes;
|
||||
import org.tianocore.SupportedArchitectures.Enum;
|
||||
|
||||
/*
|
||||
Class ModuleInfo is built for scanning the source files, it contains all the needed
|
||||
|
@ -59,24 +60,40 @@ public final class ModuleInfo {
|
|||
|
||||
//-----------------------------------------------------------------------------------//
|
||||
|
||||
//addModuleType
|
||||
//addGuidValue
|
||||
//addModuleName
|
||||
|
||||
public final boolean addSourceFile (String filename, Enum en) {
|
||||
localmodulesources.add(filename);
|
||||
return msaowner.addSourceFile(filename, en);
|
||||
}
|
||||
|
||||
public final boolean addProtocol (String proname, UsageTypes.Enum usage) {
|
||||
//protocols.add(proname);
|
||||
protocols.add(proname);
|
||||
return msaowner.addProtocol(proname, usage);
|
||||
}
|
||||
|
||||
public final boolean addPpi (String ppiname, UsageTypes.Enum usage) {
|
||||
//ppis.add(ppiname);
|
||||
ppis.add(ppiname);
|
||||
return msaowner.addPpi(ppiname, usage);
|
||||
}
|
||||
|
||||
public final boolean addGuid (String guidname, UsageTypes.Enum usage) {
|
||||
//guids.add(guidname);
|
||||
guids.add(guidname);
|
||||
return msaowner.addGuid(guidname, usage);
|
||||
}
|
||||
|
||||
public final boolean addLibraryClass(String name, UsageTypes.Enum usage) {
|
||||
//hashrequiredr9libs.add(name);
|
||||
return msaowner.addLibraryClass(name, usage);
|
||||
//
|
||||
// This section is only for adding library classes, this functionality should be inside MsaOwner!!!
|
||||
//
|
||||
//if (!hashrequiredr9libs.contains(name)) {
|
||||
msaowner.addLibraryClass(name, usage);
|
||||
//}
|
||||
//
|
||||
hashrequiredr9libs.add(name);
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------//
|
||||
|
@ -93,7 +110,7 @@ public final class ModuleInfo {
|
|||
String temp = null;
|
||||
if (filepath.contains(".c") || filepath.contains(".C") || filepath.contains(".h") ||
|
||||
filepath.contains(".H") || filepath.contains(".dxs") || filepath.contains(".uni")) {
|
||||
localmodulesources.add(filepath.replace(modulepath + File.separator, ""));
|
||||
addSourceFile(filepath.replace(modulepath + File.separator, ""), null);
|
||||
} else if (filepath.contains(".inf") || filepath.contains(".msa")) {
|
||||
temp = filepath.replace(modulepath + File.separator, "");
|
||||
if (!temp.contains(File.separator)) { // .inf in subdirectory is not regarded
|
||||
|
|
|
@ -61,19 +61,35 @@ public class MsaOwner {
|
|||
//-----------------------------msaheader-------------------------------------//
|
||||
|
||||
public final boolean addLibraryClass (String name, UsageTypes.Enum usage) {
|
||||
Iterator<LibraryClassDocument.LibraryClass> classit = libclassdefs.getLibraryClassList().iterator();
|
||||
while (classit.hasNext()) {
|
||||
if (classit.next().getKeyword() == name) {
|
||||
MigrationTool.ui.println ("Warning: Duplicate LibraryClass");
|
||||
return false;
|
||||
/*
|
||||
if (!libclassdefs.getLibraryClassList().contains(name)) {
|
||||
LibraryClassDocument.LibraryClass classname;
|
||||
classname = libclassdefs.addNewLibraryClass();
|
||||
classname.setKeyword(name);
|
||||
classname.setUsage(usage);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
if (name == null) {
|
||||
return false;
|
||||
} else {
|
||||
Iterator<LibraryClassDocument.LibraryClass> classit = libclassdefs.getLibraryClassList().iterator();
|
||||
while (classit.hasNext()) {
|
||||
if (classit.next().getKeyword().matches(name)) {
|
||||
//MigrationTool.ui.println ("Warning: Duplicate LibraryClass");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LibraryClassDocument.LibraryClass classname;
|
||||
classname = libclassdefs.addNewLibraryClass();
|
||||
classname.setKeyword(name);
|
||||
classname.setUsage(usage);
|
||||
return true;
|
||||
|
||||
LibraryClassDocument.LibraryClass classname;
|
||||
classname = libclassdefs.addNewLibraryClass();
|
||||
classname.setKeyword(name);
|
||||
classname.setUsage(usage);
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public final boolean addGuid (String guidname, UsageTypes.Enum usage) {
|
||||
|
@ -84,7 +100,7 @@ public class MsaOwner {
|
|||
Iterator<GuidsDocument.Guids.GuidCNames> guidit = guids.getGuidCNamesList().iterator();
|
||||
while (guidit.hasNext()) {
|
||||
if (guidit.next().getGuidCName() == guidname) {
|
||||
MigrationTool.ui.println ("Warning: Duplicate Guid");
|
||||
//MigrationTool.ui.println ("Warning: Duplicate Guid");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -105,7 +121,7 @@ public class MsaOwner {
|
|||
Iterator<PPIsDocument.PPIs.Ppi> ppiit = ppis.getPpiList().iterator();
|
||||
while (ppiit.hasNext()) {
|
||||
if (ppiit.next().getPpiCName() == ppiname) {
|
||||
MigrationTool.ui.println ("Warning: Duplicate Ppi");
|
||||
//MigrationTool.ui.println ("Warning: Duplicate Ppi");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -150,7 +166,7 @@ public class MsaOwner {
|
|||
Iterator<ProtocolsDocument.Protocols.Protocol> proit = protocols.getProtocolList().iterator();
|
||||
while (proit.hasNext()) {
|
||||
if (proit.next().getProtocolCName() == proname) {
|
||||
MigrationTool.ui.println ("Warning: Duplicate Protocol");
|
||||
//MigrationTool.ui.println ("Warning: Duplicate Protocol");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -375,6 +391,15 @@ public class MsaOwner {
|
|||
}
|
||||
//-----------------------------msaheader-------------------------------------//
|
||||
|
||||
private final void fullfill () throws Exception {
|
||||
addCopyRight(null);
|
||||
addVersion(null);
|
||||
addAbstract(null);
|
||||
addDescription(null);
|
||||
addLicense(null);
|
||||
addSpecification(null);
|
||||
}
|
||||
|
||||
public final void flush(String outputpath) throws Exception {
|
||||
XmlOptions options = new XmlOptions();
|
||||
|
||||
|
@ -384,6 +409,7 @@ public class MsaOwner {
|
|||
options.setUseDefaultNamespace();
|
||||
|
||||
BufferedWriter bw = new BufferedWriter(new FileWriter(outputpath));
|
||||
fullfill();
|
||||
msadoc.save(bw, options);
|
||||
bw.flush();
|
||||
bw.close();
|
||||
|
|
|
@ -17,6 +17,8 @@ import java.util.*;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.tianocore.UsageTypes;
|
||||
|
||||
public final class SourceFileReplacer implements Common.ForDoAll {
|
||||
private static final SourceFileReplacer SFReplacer = new SourceFileReplacer();
|
||||
private ModuleInfo mi;
|
||||
|
@ -297,7 +299,8 @@ public final class SourceFileReplacer implements Common.ForDoAll {
|
|||
it = symbolSet.iterator();
|
||||
while (it.hasNext()) {
|
||||
r8thing = it.next();
|
||||
mi.hashrequiredr9libs.add(MigrationTool.db.getR9Lib(r8thing)); // add a library here
|
||||
mi.addLibraryClass(MigrationTool.db.getR9Lib(r8thing), UsageTypes.ALWAYS_CONSUMED);
|
||||
//mi.hashrequiredr9libs.add(MigrationTool.db.getR9Lib(r8thing)); // add a library here
|
||||
|
||||
r8tor9 temp;
|
||||
if ((r9thing = MigrationTool.db.getR9Func(r8thing)) != null) {
|
||||
|
|
Loading…
Reference in New Issue