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