X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=Tools%2FSource%2FMigrationTools%2Forg%2Ftianocore%2Fmigration%2FSourceFileReplacer.java;h=361036251eaeb38e5ac4401c6156d4c0756a9a66;hp=67e5bc25677ee4fdd9067039a14e41f5aaad6d2c;hb=71874f9369fbefdd1a64619bd9b4cc52946e430d;hpb=4a484c5ff84ef620419f5b58ba71dd6e51af0e0d diff --git a/Tools/Source/MigrationTools/org/tianocore/migration/SourceFileReplacer.java b/Tools/Source/MigrationTools/org/tianocore/migration/SourceFileReplacer.java index 67e5bc2567..361036251e 100644 --- a/Tools/Source/MigrationTools/org/tianocore/migration/SourceFileReplacer.java +++ b/Tools/Source/MigrationTools/org/tianocore/migration/SourceFileReplacer.java @@ -20,7 +20,7 @@ import java.util.regex.Pattern; public final class SourceFileReplacer implements Common.ForDoAll { private static final SourceFileReplacer SFReplacer = new SourceFileReplacer(); private ModuleInfo mi; - private static boolean showdetails = true; // set this as default now, may be changed in the future + //private static boolean showdetails = true; // set this as default now, may be changed in the future private static class r8tor9 { r8tor9(String r8, String r9) { @@ -39,49 +39,6 @@ public final class SourceFileReplacer implements Common.ForDoAll { private static final Set fileprotocol = new HashSet(); private static final Set filer8only = new HashSet(); - private static final String addincludefile(String wholeline, String hfile) { - return wholeline.replaceFirst("(\\*/\\s)", "$1\n#include " + hfile + "\n"); - } - - private final String convertdxs(String wholeline) { - if (mi.getModuleType().equals("PEIM")) { - return addincludefile(wholeline, "\\"); - } else { - return addincludefile(wholeline, "\\"); - } - } - - private final void addr8only() throws Exception { - String paragraph = null; - String line = Common.file2string(MigrationTool.db.DatabasePath + File.separator + "R8Lib.c"); - PrintWriter outfile1 = new PrintWriter(new BufferedWriter(new FileWriter(MigrationTool.ModuleInfoMap.get(mi) + File.separator + "Migration_" + mi.modulename + File.separator + "R8Lib.c"))); - PrintWriter outfile2 = new PrintWriter(new BufferedWriter(new FileWriter(MigrationTool.ModuleInfoMap.get(mi) + File.separator + "Migration_" + mi.modulename + File.separator + "R8Lib.h"))); - Pattern ptnr8only = Pattern.compile("////#?(\\w*)?.*?R8_(\\w*).*?////~", Pattern.DOTALL); - Matcher mtrr8only = ptnr8only.matcher(line); - Matcher mtrr8onlyhead; - while (mtrr8only.find()) { - if (mi.hashr8only.contains(mtrr8only.group(2))) { - paragraph = mtrr8only.group(); - outfile1.append(paragraph + "\n\n"); - if (mtrr8only.group(1).length() != 0) { - mi.hashrequiredr9libs.add(mtrr8only.group(1)); - } - //generate R8lib.h - while ((mtrr8onlyhead = Func.ptnbrace.matcher(paragraph)).find()) { - paragraph = mtrr8onlyhead.replaceAll(";"); - } - outfile2.append(paragraph + "\n\n"); - } - } - outfile1.flush(); - outfile1.close(); - outfile2.flush(); - outfile2.close(); - - mi.localmodulesources.add("R8Lib.h"); - mi.localmodulesources.add("R8Lib.c"); - } - // Caution : if there is @ in file , it will be replaced with \n , so is you use Doxygen ... God Bless you! private final String sourcefilereplace(String wholeline) throws Exception { boolean addr8 = false; @@ -233,22 +190,32 @@ public final class SourceFileReplacer implements Common.ForDoAll { return wholeline; } + + private static final String addincludefile(String wholeline, String hfile) { + return wholeline.replaceFirst("(\\*/\\s)", "$1\n#include " + hfile + "\n"); + } + private final String convertdxs(String wholeline) { + if (mi.getModuleType().equals("PEIM")) { + return addincludefile(wholeline, "\\"); + } else { + return addincludefile(wholeline, "\\"); + } + } + private static final void show(Set hash, String sh) { Iterator it = hash.iterator(); r8tor9 temp; - if (showdetails) { - if (!hash.isEmpty()) { - MigrationTool.ui.print("Converting " + sh + " : "); - while (it.hasNext()) { - temp = it.next(); - MigrationTool.ui.print("[" + temp.r8thing + "->" + temp.r9thing + "] "); - } - MigrationTool.ui.println(""); + if (!hash.isEmpty()) { + MigrationTool.ui.print("Converting " + sh + " : "); + while (it.hasNext()) { + temp = it.next(); + MigrationTool.ui.print("[" + temp.r8thing + "->" + temp.r9thing + "] "); } + MigrationTool.ui.println(""); } } - + private static final void replaceGuid(String line, Set hash, String kind, Set filehash) { Iterator it; String r8thing; @@ -266,6 +233,37 @@ public final class SourceFileReplacer implements Common.ForDoAll { } } } + + private final void addr8only() throws Exception { + String paragraph = null; + String line = Common.file2string(MigrationTool.db.DatabasePath + File.separator + "R8Lib.c"); + PrintWriter outfile1 = new PrintWriter(new BufferedWriter(new FileWriter(MigrationTool.ModuleInfoMap.get(mi) + File.separator + "Migration_" + mi.modulename + File.separator + "R8Lib.c"))); + PrintWriter outfile2 = new PrintWriter(new BufferedWriter(new FileWriter(MigrationTool.ModuleInfoMap.get(mi) + File.separator + "Migration_" + mi.modulename + File.separator + "R8Lib.h"))); + Pattern ptnr8only = Pattern.compile("////#?(\\w*)?.*?R8_(\\w*).*?////~", Pattern.DOTALL); + Matcher mtrr8only = ptnr8only.matcher(line); + Matcher mtrr8onlyhead; + while (mtrr8only.find()) { + if (mi.hashr8only.contains(mtrr8only.group(2))) { + paragraph = mtrr8only.group(); + outfile1.append(paragraph + "\n\n"); + if (mtrr8only.group(1).length() != 0) { + mi.hashrequiredr9libs.add(mtrr8only.group(1)); + } + //generate R8lib.h + while ((mtrr8onlyhead = Func.ptnbrace.matcher(paragraph)).find()) { + paragraph = mtrr8onlyhead.replaceAll(";"); + } + outfile2.append(paragraph + "\n\n"); + } + } + outfile1.flush(); + outfile1.close(); + outfile2.flush(); + outfile2.close(); + + mi.localmodulesources.add("R8Lib.h"); + mi.localmodulesources.add("R8Lib.c"); + } //-----------------------------------ForDoAll-----------------------------------// public void run(String filepath) throws Exception { @@ -297,11 +295,7 @@ public final class SourceFileReplacer implements Common.ForDoAll { } } - public boolean dirFilter(String filepath) { - return true; - } - - public boolean fileFilter(String filepath) { + public boolean filter(File dir) { return true; } //-----------------------------------ForDoAll-----------------------------------//