diff options
author | alfred <alfred@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-08-15 04:27:45 +0000 |
---|---|---|
committer | alfred <alfred@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-08-15 04:27:45 +0000 |
commit | e6a5df3bbd1d371ce18eebd0a692a50298cb31f3 (patch) | |
tree | 77f7afd5caec7f68cf3371bf5773a991072b72ec /Tools | |
parent | 535329b5c1782a324f072793abd6dc81e54ad007 (diff) | |
download | edk2-e6a5df3bbd1d371ce18eebd0a692a50298cb31f3.zip edk2-e6a5df3bbd1d371ce18eebd0a692a50298cb31f3.tar.gz edk2-e6a5df3bbd1d371ce18eebd0a692a50298cb31f3.tar.bz2 |
Add subdirectory support
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1261 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'Tools')
4 files changed, 100 insertions, 93 deletions
diff --git a/Tools/Source/MigrationTools/org/tianocore/migration/FirstPanel.java b/Tools/Source/MigrationTools/org/tianocore/migration/FirstPanel.java index 5bd9cf1..30085d4 100644 --- a/Tools/Source/MigrationTools/org/tianocore/migration/FirstPanel.java +++ b/Tools/Source/MigrationTools/org/tianocore/migration/FirstPanel.java @@ -96,6 +96,10 @@ public class FirstPanel extends JPanel implements ActionListener, UI { }
}
+ public String choose(String message, Object[] choicelist) {
+ return (String)JOptionPane.showInputDialog(this, message,"Choose",JOptionPane.PLAIN_MESSAGE,null,choicelist,choicelist[0]);
+ }
+
//---------------------------------------------------------------------------------------//
/*
diff --git a/Tools/Source/MigrationTools/org/tianocore/migration/ModuleInfo.java b/Tools/Source/MigrationTools/org/tianocore/migration/ModuleInfo.java index b238551..fa1843f 100644 --- a/Tools/Source/MigrationTools/org/tianocore/migration/ModuleInfo.java +++ b/Tools/Source/MigrationTools/org/tianocore/migration/ModuleInfo.java @@ -39,6 +39,7 @@ public class ModuleInfo { public Set<String> localmodulesources = new HashSet<String>(); //contains both .c and .h
public Set<String> preprocessedccodes = new HashSet<String>();
+ public Set<String> msaorinf = new HashSet<String>(); //only a little, hash may be too big for this
public Set<String> hashfuncc = new HashSet<String>();
public Set<String> hashfuncd = new HashSet<String>();
@@ -54,50 +55,42 @@ public class ModuleInfo { private static String migrationcomment = "//%$//";
- private void moduleScan() throws Exception {
- String[] list = new File(modulepath).list();
- boolean hasInf = false;
- String infname = null;
- boolean hasMsa = false;
- String msaname = null;
+ private void dirScan(String subpath) throws Exception {
+ String[] list = new File(modulepath + File.separator + subpath).list(); // if no sub , separator need?
+ File test;
for (int i = 0 ; i < list.length ; i++) {
- if (new File(list[i]).isDirectory()) {
- ;
+ test = new File(modulepath + File.separator + subpath + list[i]);
+ if (test.isDirectory()) {
+ if (list[i].contains("result") || list[i].contains("temp")) {
+ } else {
+ dirScan(subpath + list[i] + File.separator);
+ }
} else {
- if (list[i].contains(".c") || list[i].contains(".C")) {
- localmodulesources.add(list[i]);
- } else if (list[i].contains(".h") || list[i].contains(".H")) {
- localmodulesources.add(list[i]); //the case that several .inf or .msa found is not concerned
- } else if (list[i].contains(".dxs")) {
- localmodulesources.add(list[i]);
- } else if (list[i].contains(".uni")) {
- localmodulesources.add(list[i]);
- } else if (list[i].contains(".inf")) {
- if (ui.yesOrNo("Found .inf file : " + list[i] + "\nDo you want to use this file as this module's .inf?")) {
- hasInf = true;
- infname = list[i];
- } else {
- continue;
- }
- } else if (list[i].contains(".msa")) {
- if (ui.yesOrNo("Found .msa file : " + list[i] + "\nDo you want to use this file as this module's .msa?")) {
- hasMsa = true;
- msaname = list[i];
- } else {
- continue;
- }
+ if (list[i].contains(".c") || list[i].contains(".C") || list[i].contains(".h") ||
+ list[i].contains(".H") || list[i].contains(".dxs") || list[i].contains(".uni")) {
+ localmodulesources.add(subpath + list[i]);
+ } else if (list[i].contains(".inf") || list[i].contains(".msa")) {
+ msaorinf.add(subpath + list[i]);
}
}
}
-
- ModuleReader mr = new ModuleReader(modulepath, this, db);
- if (hasInf) { // this sequence shows using .inf as default
- mr.readInf(infname);
- } else if (hasMsa) {
- mr.readMsa(msaname);
+ }
+
+ private void moduleScan() throws Exception {
+ dirScan("");
+ String filename = null;
+ if (msaorinf.isEmpty()) {
+ ui.println("No .inf nor .msa file found! Tool Halt!");
+ System.exit(0);
} else {
- ui.println("No INF nor MSA file found!");
+ filename = ui.choose("Found .inf or .msa file in the module\nChoose one Please", msaorinf.toArray());
+ }
+ ModuleReader mr = new ModuleReader(modulepath, this, db);
+ if (filename.contains(".inf")) {
+ mr.readInf(filename);
+ } else if (filename.contains(".msa")) {
+ mr.readMsa(filename);
}
CommentOutNonLocalHFile();
@@ -106,7 +99,7 @@ public class ModuleInfo { new SourceFileReplacer(modulepath, this, db, ui).flush(); // some adding library actions are taken here,so it must be put before "MsaWriter"
// show result
- if (ui.yesOrNo("Parse of the Module Information has completed. View details?")) {
+ if (ui.yesOrNo("Parse Module Information Complete . See details ?")) {
ui.println("\nModule Information : ");
ui.println("Entrypoint : " + entrypoint);
show(protocol, "Protocol : ");
@@ -129,8 +122,8 @@ public class ModuleInfo { ui.println("Errors Left : " + db.error);
ui.println("Complete!");
- ui.println("Your R9 module was placed here: " + modulepath + File.separator + "result");
- ui.println("Your logfile was placed here: " + modulepath);
+ ui.println("Your R9 module is placed at " + modulepath + File.separator + "result");
+ ui.println("Your logfile is placed at " + modulepath);
}
private void show(Set<String> hash, String show) {
@@ -138,6 +131,19 @@ public class ModuleInfo { ui.println(hash);
}
+ public void ensureDir(String objFileWhole) {
+ Pattern ptnseparate = Pattern.compile("(.*)\\\\[^\\\\]*");
+ Matcher mtrseparate;
+ File tempdir;
+
+ mtrseparate = ptnseparate.matcher(objFileWhole);
+ if (mtrseparate.find()) {
+ tempdir = new File(mtrseparate.group(1));
+ if (!tempdir.exists()) tempdir.mkdirs();
+ }
+
+ }
+
// add '//' to all non-local include lines
private void CommentOutNonLocalHFile() throws IOException {
BufferedReader rd;
@@ -146,20 +152,18 @@ public class ModuleInfo { PrintWriter outfile;
Pattern ptninclude = Pattern.compile("[\"<](.*[.]h)[\">]");
- Matcher mtcinclude;
-
- File tempdir = new File(modulepath + File.separator + "temp" + File.separator);
- if (!tempdir.exists()) tempdir.mkdir();
+ Matcher mtrinclude;
Iterator<String> ii = localmodulesources.iterator();
while ( ii.hasNext() ) {
curFile = ii.next();
rd = new BufferedReader(new FileReader(modulepath + File.separator + curFile));
+ ensureDir(modulepath + File.separator + "temp" + File.separator + curFile);
outfile = new PrintWriter(new BufferedWriter(new FileWriter(modulepath + File.separator + "temp" + File.separator + curFile)));
while ((line = rd.readLine()) != null) {
if (line.contains("#include")) {
- mtcinclude = ptninclude.matcher(line);
- if (mtcinclude.find() && localmodulesources.contains(mtcinclude.group(1))) {
+ mtrinclude = ptninclude.matcher(line);
+ if (mtrinclude.find() && localmodulesources.contains(mtrinclude.group(1))) {
} else {
line = migrationcomment + line;
}
@@ -170,15 +174,7 @@ public class ModuleInfo { outfile.close();
}
}
- /*
- private void search(String line, Pattern ptn, Method md) {
- matmacro = Func.ptntmacro.matcher(line);
- while (matmacro.find()) {
- if ((temp = Func.registerMacro(matmacro, this, db)) != null) {
- }
- }
- }
- */
+
private void parsePreProcessedSourceCode() throws Exception {
//Cl cl = new Cl(modulepath);
//cl.execute("Fat.c");
@@ -187,19 +183,20 @@ public class ModuleInfo { //System.out.println("Note!!!! The CL is not implemented now , pls do it manually!!! RUN :");
//System.out.println("cl " + modulepath + "\\temp\\*.c" + " -P");
//String[] list = new File(modulepath + File.separator + "temp").list(); // without CL , add
- String[] list = new File(modulepath).list();
- for (int i = 0 ; i < list.length ; i++) {
- if (list[i].contains(".c")) { // without CL , change to .i
- preprocessedccodes.add(list[i]);
- }
- }
- //
- Iterator<String> ii = preprocessedccodes.iterator();
BufferedReader rd = null;
String ifile = null;
String line = null;
String temp = null;
- //StringBuffer result = new StringBuffer();
+
+ Iterator<String> ii = localmodulesources.iterator();
+ while (ii.hasNext()) {
+ temp = ii.next();
+ if (temp.contains(".c")) {
+ preprocessedccodes.add(temp);
+ }
+ }
+
+ ii = preprocessedccodes.iterator();
Pattern patefifuncc = Pattern.compile("g?(BS|RT)\\s*->\\s*([a-zA-Z_]\\w*)",Pattern.MULTILINE);
Pattern patentrypoint = Pattern.compile("EFI_([A-Z]*)_ENTRY_POINT\\s*\\(([^\\(\\)]*)\\)",Pattern.MULTILINE);
@@ -291,4 +288,4 @@ public class ModuleInfo { public static void main(String[] args) throws Exception {
FirstPanel.init();
}
-}
+}
\ No newline at end of file diff --git a/Tools/Source/MigrationTools/org/tianocore/migration/SourceFileReplacer.java b/Tools/Source/MigrationTools/org/tianocore/migration/SourceFileReplacer.java index 2df0ffd..34eb6be 100644 --- a/Tools/Source/MigrationTools/org/tianocore/migration/SourceFileReplacer.java +++ b/Tools/Source/MigrationTools/org/tianocore/migration/SourceFileReplacer.java @@ -51,7 +51,7 @@ public class SourceFileReplacer { "EfiLibInstallAllDriverProtocols " +
"EfiLibCompareLanguage " +
"BufToHexString " +
- "EfiStrTrim " +
+ "EfiStrTrim " + //is the r8only lib going to be enlarged???? Caution !!!!
"EfiValueToHexStr " +
"HexStringToBuf " +
"IsHexDigit " +
@@ -69,33 +69,37 @@ public class SourceFileReplacer { public void flush() throws Exception {
PrintWriter outfile;
- String temp = null;
- if (ui.yesOrNo("Changes will be made to the Source Code. View details?")) {
+ String outname = null;
+ String inname = null;
+ if (ui.yesOrNo("Change Source Code is to be doing . See details ?")) {
showdetails = true;
}
- File tempdir = new File(modulepath + File.separator + "result" + File.separator);
- if (!tempdir.exists()) tempdir.mkdir();
- String[] list = new File(modulepath + File.separator + "temp").list(); //what I change is the non-local .h commented-out files
- for (int i = 0 ; i < list.length ; i++) {
- if (list[i].contains(".c")) {
- ui.println("\nModifying file: " + list[i]);
- outfile = new PrintWriter(new BufferedWriter(new FileWriter(modulepath + File.separator + "result" + File.separator + list[i])));
- outfile.append(sourcefilereplace(modulepath + File.separator + "temp" + File.separator + list[i]));
+
+ Iterator<String> di = mi.localmodulesources.iterator();
+ while (di.hasNext()) {
+ inname = di.next();
+ if (inname.contains(".c") || inname.contains(".C")) {
+ if (inname.contains(".C")) {
+ outname = inname.replaceFirst(".C", ".c");
+ } else {
+ outname = inname;
+ }
+ ui.println("\nModifying file : " + inname);
+ mi.ensureDir(modulepath + File.separator + "result" + File.separator + outname);
+ outfile = new PrintWriter(new BufferedWriter(new FileWriter(modulepath + File.separator + "result" + File.separator + outname)));
+ outfile.append(sourcefilereplace(modulepath + File.separator + "temp" + File.separator + inname));
outfile.flush();
outfile.close();
- } else {
- if (list[i].contains(".h")) {
- temp = list[i];
- } else if (list[i].contains(".C")) {
- temp = list[i].replaceFirst(".C", ".c");
- } else if (list[i].contains(".H")) {
- temp = list[i].replaceFirst(".H", ".h");
+ } else if (inname.contains(".h") || inname.contains(".H") || inname.contains(".dxs") || inname.contains(".uni")) {
+ if (inname.contains(".H")) {
+ outname = inname.replaceFirst(".H", ".h");
} else {
- continue;
+ outname = inname;
}
- ui.println("\nCopying file: " + temp);
- outfile = new PrintWriter(new BufferedWriter(new FileWriter(modulepath + File.separator + "result" + File.separator + temp)));
- outfile.append(sourcefiletostring(modulepath + File.separator + "temp" + File.separator + list[i]));
+ ui.println("\nCopying file : " + inname);
+ mi.ensureDir(modulepath + File.separator + "result" + File.separator + outname);
+ outfile = new PrintWriter(new BufferedWriter(new FileWriter(modulepath + File.separator + "result" + File.separator + outname)));
+ outfile.append(sourcefiletostring(modulepath + File.separator + "temp" + File.separator + inname));
outfile.flush();
outfile.close();
}
@@ -109,10 +113,9 @@ public class SourceFileReplacer { private void addr8only() throws Exception {
String paragraph = null;
String line = sourcefiletostring(Database.defaultpath + File.separator + "R8Lib.c");
+ mi.ensureDir(modulepath + File.separator + "result" + File.separator + "R8Lib.c");
PrintWriter outfile1 = new PrintWriter(new BufferedWriter(new FileWriter(modulepath + File.separator + "result" + File.separator + "R8Lib.c")));
PrintWriter outfile2 = new PrintWriter(new BufferedWriter(new FileWriter(modulepath + File.separator + "result" + File.separator + "R8Lib.h")));
- //outfile1.append("#include \"R8Lib.h\"\n\n");
- //outfile2.append("#include \"R8Lib.h\"\n\n");
Pattern ptnr8only = Pattern.compile("////#?(\\w*)?.*?R8_(\\w*).*?////~", Pattern.DOTALL);
Matcher mtrr8only = ptnr8only.matcher(line);
Matcher mtrr8onlyhead;
@@ -134,6 +137,9 @@ public class SourceFileReplacer { outfile1.close();
outfile2.flush();
outfile2.close();
+
+ mi.localmodulesources.add("R8Lib.h");
+ mi.localmodulesources.add("R8Lib.c");
}
private String sourcefiletostring(String filename) throws Exception {
@@ -167,7 +173,7 @@ public class SourceFileReplacer { // replace BS -> gBS , RT -> gRT
Matcher mat = pat.matcher(line);
if (mat.find()) { // add a library here
- ui.println("Converting all BS->gBS, RT->gRT");
+ ui.println("Converting all BS->gBS,RT->gRT");
line = mat.replaceAll("g$1$2$3"); //unknown correctiveness
}
mat.reset();
@@ -214,8 +220,6 @@ public class SourceFileReplacer { while (rt.hasNext()) {
temp = rt.next();
if (r8only.contains(temp.r8thing)) {
- mi.localmodulesources.add("R8Lib.h");
- mi.localmodulesources.add("R8Lib.c");
filer8only.add(r8thing);
mi.hashr8only.add(r8thing);
addr8 = true;
@@ -310,7 +314,7 @@ public class SourceFileReplacer { fileppi.clear();
fileprotocol.clear();
filer8only.clear();
-
+
return line;
}
diff --git a/Tools/Source/MigrationTools/org/tianocore/migration/UI.java b/Tools/Source/MigrationTools/org/tianocore/migration/UI.java index 7552379..7f91ebe 100644 --- a/Tools/Source/MigrationTools/org/tianocore/migration/UI.java +++ b/Tools/Source/MigrationTools/org/tianocore/migration/UI.java @@ -23,4 +23,6 @@ public interface UI { public void println(String message);
public void println(Set<String> hash);
+
+ public String choose(String message, Object[] choicelist);
}
|