add MigrationTool

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1393 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
alfred 2006-08-28 02:28:24 +00:00
parent 2b70a6367b
commit 482407d3d6
11 changed files with 125 additions and 121 deletions

View File

@ -1,2 +1,2 @@
Manifest-Version: 1.0
Main-Class: org.tianocore.migration.ModuleInfo
Main-Class: org.tianocore.migration.MigrationTool

View File

@ -65,15 +65,15 @@ public final class FirstPanel extends JPanel implements ActionListener, ItemList
mibox = new JCheckBox("Print ModuleInfo", false);
mibox.addItemListener(this);
ModuleInfo.printModuleInfo = false;
MigrationTool.printModuleInfo = false;
criticbox = new JCheckBox("Run Critic", true);
criticbox.addItemListener(this);
ModuleInfo.doCritic = true;
MigrationTool.doCritic = true;
defaultpathbox = new JCheckBox("Use Default Output Path", true);
defaultpathbox.addItemListener(this);
ModuleInfo.defaultoutput = true;
MigrationTool.defaultoutput = true;
JPanel modulePanel = new JPanel();
modulePanel.add(moduleButton);
@ -177,7 +177,7 @@ public final class FirstPanel extends JPanel implements ActionListener, ItemList
if ( e.getSource() == goButton ) {
try {
logfile = new PrintWriter(new BufferedWriter(new FileWriter(startpath.replaceAll(Common.strseparate, "$1") + File.separator + "migration.log")));
ModuleInfo.triger(startpath);
MigrationTool.triger(startpath);
logfile.flush();
} catch (Exception en) {
println(en.getMessage());
@ -214,21 +214,21 @@ public final class FirstPanel extends JPanel implements ActionListener, ItemList
}
} else if (e.getSource() == mibox) {
if (e.getStateChange() == ItemEvent.DESELECTED) {
ModuleInfo.printModuleInfo = false;
MigrationTool.printModuleInfo = false;
} else if (e.getStateChange() == ItemEvent.SELECTED) {
ModuleInfo.printModuleInfo = true;
MigrationTool.printModuleInfo = true;
}
} else if (e.getSource() == criticbox) {
if (e.getStateChange() == ItemEvent.DESELECTED) {
ModuleInfo.doCritic = false;
MigrationTool.doCritic = false;
} else if (e.getStateChange() == ItemEvent.SELECTED) {
ModuleInfo.doCritic = true;
MigrationTool.doCritic = true;
}
} else if (e.getSource() == defaultpathbox) {
if (e.getStateChange() == ItemEvent.DESELECTED) {
ModuleInfo.defaultoutput = false;
MigrationTool.defaultoutput = false;
} else if (e.getStateChange() == ItemEvent.SELECTED) {
ModuleInfo.defaultoutput = true;
MigrationTool.defaultoutput = true;
}
}
}

View File

@ -45,8 +45,8 @@ public class Guid {
String temp = null;
temp = mtr.group();
if (ModuleInfo.db.hasGuid(temp)) { // only changed guids registered, because both changed and not changed guids are included in database
type = ModuleInfo.db.getGuidType(temp);
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.protocol.add(temp);
} else if (type.matches("Ppi")) {

View File

@ -35,7 +35,7 @@ public class Macro {
String temp = null;
temp = mtr.group();
if (ModuleInfo.db.hasMacro(temp)) { // only changed macros registered, because the database of macro has only changed ones
if (MigrationTool.db.hasMacro(temp)) { // only changed macros registered, because the database of macro has only changed ones
if (!unmacro.contains(temp)) {
mi.hashnonlocalmacro.add(temp);
}

View File

@ -0,0 +1,76 @@
package org.tianocore.migration;
import java.io.File;
import java.util.Set;
public class MigrationTool {
private static final void manipulate(ModuleInfo mi) throws Exception {
ModuleReader.ModuleScan(mi);
//MigrationTool.ui.yesOrNo("go on replace?");
SourceFileReplacer.flush(mi); // some adding library actions are taken here,so it must be put before "MsaWriter"
//MigrationTool.ui.yesOrNo("go on show?");
// show result
if (MigrationTool.printModuleInfo) {
MigrationTool.ui.println("\nModule Information : ");
MigrationTool.ui.println("Entrypoint : " + mi.entrypoint);
show(mi.protocol, "Protocol : ");
show(mi.ppi, "Ppi : ");
show(mi.guid, "Guid : ");
show(mi.hashfuncc, "call : ");
show(mi.hashfuncd, "def : ");
show(mi.hashEFIcall, "EFIcall : ");
show(mi.hashnonlocalmacro, "macro : ");
show(mi.hashnonlocalfunc, "nonlocal : ");
show(mi.hashr8only, "hashr8only : ");
}
//MigrationTool.ui.yesOrNo("go on msawrite?");
new MsaWriter(mi).flush();
//MigrationTool.ui.yesOrNo("go on critic?");
if (MigrationTool.doCritic) {
Critic.fireAt(mi.outputpath + File.separator + "Migration_" + mi.modulename);
}
//MigrationTool.ui.yesOrNo("go on delete?");
Common.deleteDir(mi.modulepath + File.separator + "temp");
MigrationTool.ui.println("Errors Left : " + MigrationTool.db.error);
MigrationTool.ui.println("Complete!");
//MigrationTool.ui.println("Your R9 module was placed here: " + mi.modulepath + File.separator + "result");
//MigrationTool.ui.println("Your logfile was placed here: " + mi.modulepath);
}
private static final void show(Set<String> hash, String show) {
MigrationTool.ui.println(show + hash.size());
MigrationTool.ui.println(hash);
}
public static final void seekModule(String filepath) throws Exception {
if (ModuleInfo.isModule(filepath)) {
manipulate(new ModuleInfo(filepath));
}
}
public static final void triger(String path) throws Exception {
MigrationTool.ui.println("Project Migration");
MigrationTool.ui.println("Copyright (c) 2006, Intel Corporation");
Common.toDoAll(path, MigrationTool.class.getMethod("seekModule", String.class), null, null, Common.DIR);
}
public static UI ui = null;
public static Database db = null;
public static final String MIGRATIONCOMMENT = "//%$//";
public static boolean printModuleInfo = false;
public static boolean doCritic = false;
public static boolean defaultoutput = false;
public static void main(String[] args) throws Exception {
ui = FirstPanel.init();
db = Database.init();
}
}

View File

@ -23,14 +23,14 @@ public final class ModuleInfo {
ModuleInfo(String modulepath) throws Exception {
this.modulepath = modulepath;
if (ModuleInfo.defaultoutput) {
if (MigrationTool.defaultoutput) {
this.outputpath = this.modulepath.replaceAll(Common.strseparate, "$1");
} else {
ModuleInfo.ui.println("Choose where to place the result");
if ((outputpath = ModuleInfo.ui.getFilepath("Please choose where to place the output module")) == null) {
MigrationTool.ui.println("Choose where to place the result");
if ((outputpath = MigrationTool.ui.getFilepath("Please choose where to place the output module")) == null) {
outputpath = modulepath;
}
ModuleInfo.ui.println("Output to: " + outputpath);
MigrationTool.ui.println("Output to: " + outputpath);
}
}
@ -79,76 +79,4 @@ public final class ModuleInfo {
}
return false;
}
//---------------------------------------------------------------------------//
private static final void manipulate(ModuleInfo mi) throws Exception {
ModuleReader.ModuleScan(mi);
//ModuleInfo.ui.yesOrNo("go on replace?");
SourceFileReplacer.flush(mi); // some adding library actions are taken here,so it must be put before "MsaWriter"
//ModuleInfo.ui.yesOrNo("go on show?");
// show result
if (ModuleInfo.printModuleInfo) {
ModuleInfo.ui.println("\nModule Information : ");
ModuleInfo.ui.println("Entrypoint : " + mi.entrypoint);
show(mi.protocol, "Protocol : ");
show(mi.ppi, "Ppi : ");
show(mi.guid, "Guid : ");
show(mi.hashfuncc, "call : ");
show(mi.hashfuncd, "def : ");
show(mi.hashEFIcall, "EFIcall : ");
show(mi.hashnonlocalmacro, "macro : ");
show(mi.hashnonlocalfunc, "nonlocal : ");
show(mi.hashr8only, "hashr8only : ");
}
//ModuleInfo.ui.yesOrNo("go on msawrite?");
new MsaWriter(mi).flush();
//ModuleInfo.ui.yesOrNo("go on critic?");
if (ModuleInfo.doCritic) {
Critic.fireAt(mi.outputpath + File.separator + "Migration_" + mi.modulename);
}
//ModuleInfo.ui.yesOrNo("go on delete?");
Common.deleteDir(mi.modulepath + File.separator + "temp");
ModuleInfo.ui.println("Errors Left : " + ModuleInfo.db.error);
ModuleInfo.ui.println("Complete!");
//ModuleInfo.ui.println("Your R9 module was placed here: " + mi.modulepath + File.separator + "result");
//ModuleInfo.ui.println("Your logfile was placed here: " + mi.modulepath);
}
private static final void show(Set<String> hash, String show) {
ModuleInfo.ui.println(show + hash.size());
ModuleInfo.ui.println(hash);
}
public static final void seekModule(String filepath) throws Exception {
if (ModuleInfo.isModule(filepath)) {
manipulate(new ModuleInfo(filepath));
}
}
public static final void triger(String path) throws Exception {
ModuleInfo.ui.println("Project Migration");
ModuleInfo.ui.println("Copyright (c) 2006, Intel Corporation");
Common.toDoAll(path, ModuleInfo.class.getMethod("seekModule", String.class), null, null, Common.DIR);
}
public static UI ui = null;
public static Database db = null;
public static final String migrationcomment = "//%$//";
public static boolean printModuleInfo = false;
public static boolean doCritic = false;
public static boolean defaultoutput = false;
public static void main(String[] args) throws Exception {
ui = FirstPanel.init();
db = Database.init();
}
}

View File

@ -32,13 +32,13 @@ public final class ModuleReader {
String filename = null;
if (mi.msaorinf.isEmpty()) {
ModuleInfo.ui.println("No INF nor MSA file found!");
MigrationTool.ui.println("No INF nor MSA file found!");
System.exit(0);
} else {
if (mi.msaorinf.size() == 1) {
filename = (String)mi.msaorinf.toArray()[0];
} else {
filename = ModuleInfo.ui.choose("Found .inf or .msa file for module\n" + mi.modulepath + "\nChoose one Please", mi.msaorinf.toArray());
filename = MigrationTool.ui.choose("Found .inf or .msa file for module\n" + mi.modulepath + "\nChoose one Please", mi.msaorinf.toArray());
}
}
if (filename.contains(".inf")) {
@ -104,7 +104,7 @@ public final class ModuleReader {
}
if (mtrinfequation.group(1).matches("DPX_SOURCE")) {
if (!mi.localmodulesources.contains(mtrinfequation.group(2))) {
ModuleInfo.ui.println("DPX File Missing! : " + mtrinfequation.group(2));
MigrationTool.ui.println("DPX File Missing! : " + mtrinfequation.group(2));
}
}
}
@ -113,7 +113,7 @@ public final class ModuleReader {
mtrfilename = ptnfilename.matcher(mtrsection.group(2));
while (mtrfilename.find()) {
if (!mi.localmodulesources.contains(mtrfilename.group())) {
ModuleInfo.ui.println("Source File Missing! : " + mtrfilename.group());
MigrationTool.ui.println("Source File Missing! : " + mtrfilename.group());
}
}
}
@ -141,7 +141,7 @@ public final class ModuleReader {
mtrinclude = ptninclude.matcher(line);
if (mtrinclude.find() && mi.localmodulesources.contains(mtrinclude.group(1))) {
} else {
line = ModuleInfo.migrationcomment + line;
line = MigrationTool.MIGRATIONCOMMENT + line;
}
}
outfile.append(line + '\n');
@ -207,8 +207,8 @@ public final class ModuleReader {
// find guid
matguid = Guid.ptnguid.matcher(line); // several ways to implement this , which one is faster ? :
while (matguid.find()) { // 1.currently , find once , then call to identify which is it
if ((temp = Guid.register(matguid, mi, ModuleInfo.db)) != null) { // 2.use 3 different matchers , search 3 times to find each
//matguid.appendReplacement(result, ModuleInfo.db.getR9Guidname(temp)); // search the database for all 3 kinds of guids , high cost
if ((temp = Guid.register(matguid, mi, MigrationTool.db)) != null) { // 2.use 3 different matchers , search 3 times to find each
//matguid.appendReplacement(result, MigrationTool.db.getR9Guidname(temp)); // search the database for all 3 kinds of guids , high cost
}
}
//matguid.appendTail(result);
@ -224,9 +224,9 @@ public final class ModuleReader {
// find function call
matfuncc = Func.ptnfuncc.matcher(line);
while (matfuncc.find()) {
if ((temp = Func.register(matfuncc, mi, ModuleInfo.db)) != null) {
//ModuleInfo.ui.println(ifile + " dofunc " + temp);
//matfuncc.appendReplacement(result, ModuleInfo.db.getR9Func(temp));
if ((temp = Func.register(matfuncc, mi, MigrationTool.db)) != null) {
//MigrationTool.ui.println(ifile + " dofunc " + temp);
//matfuncc.appendReplacement(result, MigrationTool.db.getR9Func(temp));
}
}
//matfuncc.appendTail(result);
@ -235,7 +235,7 @@ public final class ModuleReader {
// find macro
matmacro = Macro.ptntmacro.matcher(line);
while (matmacro.find()) {
if ((temp = Macro.register(matmacro, mi, ModuleInfo.db)) != null) {
if ((temp = Macro.register(matmacro, mi, MigrationTool.db)) != null) {
}
}
@ -247,7 +247,7 @@ public final class ModuleReader {
matfuncd = Func.ptnfuncd.matcher(line);
while (matfuncd.find()) {
if ((temp = Func.register(matfuncd, mi, ModuleInfo.db)) != null) {
if ((temp = Func.register(matfuncd, mi, MigrationTool.db)) != null) {
}
}
}

View File

@ -102,7 +102,7 @@ public class MsaTreeEditor extends JPanel {
}
private void addNode() {
addNode((DefaultMutableTreeNode)(tree.getSelectionPath().getLastPathComponent()), ModuleInfo.ui.getInput("Input Node Name"));
addNode((DefaultMutableTreeNode)(tree.getSelectionPath().getLastPathComponent()), MigrationTool.ui.getInput("Input Node Name"));
}
private void addNode(DefaultMutableTreeNode parentNode, Object child) {

View File

@ -45,7 +45,7 @@ public final class SourceFileReplacer {
String outname = null;
String inname = null;
/*
if (ModuleInfo.ui.yesOrNo("Changes will be made to the Source Code. View details?")) {
if (MigrationTool.ui.yesOrNo("Changes will be made to the Source Code. View details?")) {
showdetails = true;
}
*/
@ -60,7 +60,7 @@ public final class SourceFileReplacer {
} else {
outname = inname;
}
ModuleInfo.ui.println("\nModifying file: " + inname);
MigrationTool.ui.println("\nModifying file: " + inname);
Common.string2file(sourcefilereplace(mi.modulepath + File.separator + "temp" + File.separator + inname), mi.outputpath + File.separator + "Migration_" + mi.modulename + File.separator + outname);
} else if (inname.contains(".h") || inname.contains(".H") || inname.contains(".dxs") || inname.contains(".uni")) {
if (inname.contains(".H")) {
@ -68,7 +68,7 @@ public final class SourceFileReplacer {
} else {
outname = inname;
}
ModuleInfo.ui.println("\nCopying file: " + inname);
MigrationTool.ui.println("\nCopying file: " + inname);
Common.string2file(Common.file2string(mi.modulepath + File.separator + "temp" + File.separator + inname), mi.outputpath + File.separator + "Migration_" + mi.modulename + File.separator + outname);
}
}
@ -80,7 +80,7 @@ public final class SourceFileReplacer {
private static final void addr8only() throws Exception {
String paragraph = null;
String line = Common.file2string(ModuleInfo.db.DatabasePath + File.separator + "R8Lib.c");
String line = Common.file2string(MigrationTool.db.DatabasePath + File.separator + "R8Lib.c");
//Common.ensureDir(mi.modulepath + File.separator + "Migration_" + mi.modulename + File.separator + "R8Lib.c");
PrintWriter outfile1 = new PrintWriter(new BufferedWriter(new FileWriter(mi.outputpath + File.separator + "Migration_" + mi.modulename + File.separator + "R8Lib.c")));
PrintWriter outfile2 = new PrintWriter(new BufferedWriter(new FileWriter(mi.outputpath + File.separator + "Migration_" + mi.modulename + File.separator + "R8Lib.h")));
@ -131,7 +131,7 @@ public final class SourceFileReplacer {
// replace BS -> gBS , RT -> gRT
Matcher mat = pat.matcher(line);
if (mat.find()) { // add a library here
ModuleInfo.ui.println("Converting all BS->gBS, RT->gRT");
MigrationTool.ui.println("Converting all BS->gBS, RT->gRT");
line = mat.replaceAll("g$1$2$3"); //unknown correctiveness
}
mat.reset();
@ -148,7 +148,7 @@ public final class SourceFileReplacer {
Pattern patentrypoint = Pattern.compile("EFI_DRIVER_ENTRY_POINT[^\\}]*\\}");
Matcher matentrypoint = patentrypoint.matcher(line);
if (matentrypoint.find()) {
ModuleInfo.ui.println("Deleting Entry_Point");
MigrationTool.ui.println("Deleting Entry_Point");
line = matentrypoint.replaceAll("");
}
*/
@ -166,10 +166,10 @@ public final class SourceFileReplacer {
mi.hashrequiredr9libs.add("UefiRuntimeServicesTableLib"); //a
mi.hashrequiredr9libs.add("DxeServicesTableLib"); //l
} else { //
mi.hashrequiredr9libs.add(ModuleInfo.db.getR9Lib(r8thing)); // add a library here
mi.hashrequiredr9libs.add(MigrationTool.db.getR9Lib(r8thing)); // add a library here
}
if ((r9thing = ModuleInfo.db.getR9Func(r8thing)) != null) {
if ((r9thing = MigrationTool.db.getR9Func(r8thing)) != null) {
if (!r8thing.equals(r9thing)) {
if (line.contains(r8thing)) {
line = line.replaceAll(r8thing, r9thing);
@ -177,7 +177,7 @@ public final class SourceFileReplacer {
Iterator<r8tor9> rt = filefunc.iterator();
while (rt.hasNext()) {
temp = rt.next();
if (ModuleInfo.db.r8only.contains(temp.r8thing)) {
if (MigrationTool.db.r8only.contains(temp.r8thing)) {
filer8only.add(r8thing);
mi.hashr8only.add(r8thing);
addr8 = true;
@ -195,8 +195,8 @@ public final class SourceFileReplacer {
it = mi.hashnonlocalmacro.iterator();
while (it.hasNext()) { //macros are all assumed MdePkg currently
r8thing = it.next();
//mi.hashrequiredr9libs.add(ModuleInfo.db.getR9Lib(r8thing));
if ((r9thing = ModuleInfo.db.getR9Macro(r8thing)) != null) {
//mi.hashrequiredr9libs.add(MigrationTool.db.getR9Lib(r8thing));
if ((r9thing = MigrationTool.db.getR9Macro(r8thing)) != null) {
if (line.contains(r8thing)) {
line = line.replaceAll(r8thing, r9thing);
filemacro.add(new r8tor9(r8thing, r9thing));
@ -263,7 +263,7 @@ public final class SourceFileReplacer {
show(fileppi, "ppi");
show(fileprotocol, "protocol");
if (!filer8only.isEmpty()) {
ModuleInfo.ui.println("Converting r8only : " + filer8only);
MigrationTool.ui.println("Converting r8only : " + filer8only);
}
filefunc.clear();
@ -281,12 +281,12 @@ public final class SourceFileReplacer {
r8tor9 temp;
if (showdetails) {
if (!hash.isEmpty()) {
ModuleInfo.ui.print("Converting " + sh + " : ");
MigrationTool.ui.print("Converting " + sh + " : ");
while (it.hasNext()) {
temp = it.next();
ModuleInfo.ui.print("[" + temp.r8thing + "->" + temp.r9thing + "] ");
MigrationTool.ui.print("[" + temp.r8thing + "->" + temp.r9thing + "] ");
}
ModuleInfo.ui.println("");
MigrationTool.ui.println("");
}
}
}
@ -298,7 +298,7 @@ public final class SourceFileReplacer {
it = hash.iterator();
while (it.hasNext()) {
r8thing = it.next();
if ((r9thing = ModuleInfo.db.getR9Guidname(r8thing)) != null) {
if ((r9thing = MigrationTool.db.getR9Guidname(r8thing)) != null) {
if (!r8thing.equals(r9thing)) {
if (line.contains(r8thing)) {
line = line.replaceAll(r8thing, r9thing);

View File

@ -12,4 +12,4 @@
export CLASSPATH=$CLASSPATH:$WORKSPACE/Tools/bin/MigrationTools.jar
# Run Migration Tool
java org.tianocore.migration.ModuleInfo
java org.tianocore.migration.MigrationTool

View File

@ -29,7 +29,7 @@ if not exist %WORKSPACE%\Tools\bin\MigrationTools.jar (
)
@REM Run Migration
call "java" org.tianocore.migration.ModuleInfo
call "java" org.tianocore.migration.MigrationTool
goto end