X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=Tools%2FSource%2FMigrationTools%2Forg%2Ftianocore%2Fmigration%2FModuleInfo.java;h=01aa129cd53793a9b14cd2ea3936057cc72cd74a;hp=fdc6aca781fe48c3e4c54f0dfd8a3953423bca24;hb=6ef5feb50eea5d8fa0661938df0a247b0b29fdc6;hpb=cfdfbaca559ef990c82985760f33a7139e76ac3a diff --git a/Tools/Source/MigrationTools/org/tianocore/migration/ModuleInfo.java b/Tools/Source/MigrationTools/org/tianocore/migration/ModuleInfo.java index fdc6aca781..01aa129cd5 100644 --- a/Tools/Source/MigrationTools/org/tianocore/migration/ModuleInfo.java +++ b/Tools/Source/MigrationTools/org/tianocore/migration/ModuleInfo.java @@ -15,136 +15,78 @@ package org.tianocore.migration; import java.io.*; import java.util.*; +import org.tianocore.ModuleSurfaceAreaDocument; + /* - Class ModuleInfo is built for scanning the source files, it contains all the needed + Class ModuleInfo is built for scanning the source files, it contains all the needed information and all the temporary data. */ public final class ModuleInfo { - ModuleInfo(String modulepath) throws Exception { - this.modulepath = 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); - } - } - - public String modulepath = null; - - public String outputpath = null; - - public String modulename = null; - public String guidvalue = null; - public String moduletype = null; - public String entrypoint = null; - - 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 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(); - - 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(); - - public final void enroll(String filepath) throws Exception { - if (filepath.contains(".c") || filepath.contains(".C") || filepath.contains(".h") || - filepath.contains(".H") || filepath.contains(".dxs") || filepath.contains(".uni")) { - localmodulesources.add(filepath.replace(modulepath + "\\", "")); - } else if (filepath.contains(".inf") || filepath.contains(".msa")) { - msaorinf.add(filepath.replace(modulepath + "\\", "")); - } - } - - 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()) { - if (list[i].contains(".inf") || list[i].contains(".msa")) { - return true; - } - } - } - return false; - } + ModuleInfo(String modulepath) throws Exception { + this.modulepath = modulepath; + this.temppath = MigrationTool.getTempDir(this.modulepath); + } - //---------------------------------------------------------------------------// - - 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(); + public final String modulepath; + public final String temppath; + + private MsaOwner msaowner = new MsaWriter(this); + public ModuleSurfaceAreaDocument msadoc = ModuleSurfaceAreaDocument.Factory.newInstance(); + + public String modulename = null; + public String guidvalue = null; + public String moduletype = null; + public String entrypoint = null; + + 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 final Set infincludes = new HashSet(); + public final Set infsources = 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(); + public final Set hashmacro = new HashSet(); + + 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 (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 final String getModuleType() { + if (moduletype.contains("PEI")) { + return "PEIM"; + } else { + return "DXE_DRIVER"; + } + } + + public final void enroll(String filepath) throws Exception { + String temp = null; + if (filepath.contains(".c") || filepath.contains(".C") || filepath.contains(".h") || + filepath.contains(".H") || filepath.contains(".dxs") || filepath.contains(".uni")) { + localmodulesources.add(filepath.replace(modulepath + File.separator, "")); + } else if (filepath.contains(".inf") || filepath.contains(".msa")) { + temp = filepath.replace(modulepath + File.separator, ""); + if (!temp.contains(File.separator)) { // .inf in subdirectory is not regarded + msaorinf.add(temp); + } + } + } - 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(); - } + 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()) { + if (list[i].contains(".inf") || list[i].contains(".msa")) { + return true; + } + } + } + return false; + } } \ No newline at end of file