X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=Tools%2FSource%2FMigrationTools%2Forg%2Ftianocore%2Fmigration%2FModuleInfo.java;h=49dde8b67a84e892822a4f022c2f8281a8941ea3;hp=aa6e7a2ba0bac74ca5ade28c5768e760e49c5199;hb=1eac75f911034feed279a69fbe6b84853682dca3;hpb=446e26ee9238d189475baa37eb7658a6612f9a29 diff --git a/Tools/Source/MigrationTools/org/tianocore/migration/ModuleInfo.java b/Tools/Source/MigrationTools/org/tianocore/migration/ModuleInfo.java index aa6e7a2ba0..49dde8b67a 100644 --- a/Tools/Source/MigrationTools/org/tianocore/migration/ModuleInfo.java +++ b/Tools/Source/MigrationTools/org/tianocore/migration/ModuleInfo.java @@ -19,17 +19,19 @@ import java.util.*; Class ModuleInfo is built for scanning the source files, it contains all the needed information and all the temporary data. */ -public class ModuleInfo { +public final class ModuleInfo { ModuleInfo(String modulepath) throws Exception { this.modulepath = modulepath; - MigrationTool.ui.println("Choose where to place the result"); - if ((outputpath = MigrationTool.ui.getFilepath()) == null) { - outputpath = modulepath; + if (ModuleInfo.defaultoutput) { + this.outputpath = this.modulepath.replaceAll(Common.strseparate, "$1"); + } else { + ModuleInfo.ui.println("Choose where to place the result"); + if ((outputpath = ModuleInfo.ui.getFilepath()) == null) { + outputpath = modulepath; + } + ModuleInfo.ui.println("Output to: " + outputpath); } - MigrationTool.ui.println(outputpath); - - mainFlow(); } public String modulepath = null; @@ -41,62 +43,22 @@ public class ModuleInfo { public String moduletype = null; public String entrypoint = null; - public Set localmodulesources = new HashSet(); //contains both .c and .h - public Set preprocessedccodes = new HashSet(); - public Set msaorinf = new HashSet(); //only a little, hash may be too big for this - - public Set hashfuncc = new HashSet(); - public Set hashfuncd = new HashSet(); - public Set hashnonlocalfunc = new HashSet(); - public Set hashnonlocalmacro = new HashSet(); - public Set hashEFIcall = new HashSet(); - public Set hashr8only = new HashSet(); + public final Set localmodulesources = new HashSet(); //contains both .c and .h + public final Set preprocessedccodes = new HashSet(); + public final Set msaorinf = new HashSet(); //only a little, hash may be too big for this - public Set hashrequiredr9libs = new HashSet(); // hashrequiredr9libs is now all added in SourceFileReplacer - public Set guid = new HashSet(); - public Set protocol = new HashSet(); - public Set ppi = new HashSet(); + public final Set hashfuncc = new HashSet(); + public final Set hashfuncd = new HashSet(); + public final Set hashnonlocalfunc = new HashSet(); + public final Set hashnonlocalmacro = new HashSet(); + public final Set hashEFIcall = new HashSet(); + public final Set hashr8only = new HashSet(); - private void mainFlow() throws Exception { - - ModuleReader.ModuleScan(this); - - SourceFileReplacer.flush(this); // some adding library actions are taken here,so it must be put before "MsaWriter" - - // show result - if (MigrationTool.printModuleInfo) { - MigrationTool.ui.println("\nModule Information : "); - MigrationTool.ui.println("Entrypoint : " + entrypoint); - show(protocol, "Protocol : "); - show(ppi, "Ppi : "); - show(guid, "Guid : "); - show(hashfuncc, "call : "); - show(hashfuncd, "def : "); - show(hashEFIcall, "EFIcall : "); - show(hashnonlocalmacro, "macro : "); - show(hashnonlocalfunc, "nonlocal : "); - show(hashr8only, "hashr8only : "); - } - - new MsaWriter(this).flush(); + public final Set hashrequiredr9libs = new HashSet(); // hashrequiredr9libs is now all added in SourceFileReplacer + public final Set guid = new HashSet(); + public final Set protocol = new HashSet(); + public final Set ppi = new HashSet(); - if (MigrationTool.doCritic) { - Critic.fireAt(outputpath + File.separator + "Migration_" + modulename); - } - - Common.deleteDir(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: " + modulepath + File.separator + "result"); - MigrationTool.ui.println("Your logfile was placed here: " + modulepath); - } - - private void show(Set hash, String show) { - MigrationTool.ui.println(show + hash.size()); - MigrationTool.ui.println(hash); - } - public final void enroll(String filepath) throws Exception { String[] temp; if (filepath.contains(".c") || filepath.contains(".C") || filepath.contains(".h") || @@ -109,13 +71,7 @@ public class ModuleInfo { } } - public static final void seekModule(String filepath) throws Exception { - if (isModule(filepath)) { - new ModuleInfo(filepath); - } - } - - private static final boolean isModule(String path) { + public static final boolean isModule(String path) { String[] list = new File(path).list(); for (int i = 0 ; i < list.length ; i++) { if (!new File(list[i]).isDirectory()) { @@ -127,9 +83,71 @@ public class ModuleInfo { return false; } + //---------------------------------------------------------------------------// + + private static final void manipulate(ModuleInfo mi) throws Exception { + + ModuleReader.ModuleScan(mi); + + SourceFileReplacer.flush(mi); // some adding library actions are taken here,so it must be put before "MsaWriter" + + // 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 : "); + } + + new MsaWriter(mi).flush(); + + if (ModuleInfo.doCritic) { + Critic.fireAt(mi.outputpath + File.separator + "Migration_" + mi.modulename); + } + + 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 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 { - MigrationTool.ui.println("Project Migration"); - MigrationTool.ui.println("Copyright (c) 2006, Intel Corporation"); + 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(); + } } \ No newline at end of file