X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=Tools%2FSource%2FMigrationTools%2Forg%2Ftianocore%2Fmigration%2FModuleReader.java;h=46fb4994bb39c8362308f4d70c1246ca27b912fd;hp=3f379b7256f5a822358d2e30bac50bd30ca811b1;hb=90503bad37fea5edf22531754c203f77268dfa36;hpb=9dc7af1e05a9c2fe96ce897c94b39b6385cb7966 diff --git a/Tools/Source/MigrationTools/org/tianocore/migration/ModuleReader.java b/Tools/Source/MigrationTools/org/tianocore/migration/ModuleReader.java index 3f379b7256..46fb4994bb 100644 --- a/Tools/Source/MigrationTools/org/tianocore/migration/ModuleReader.java +++ b/Tools/Source/MigrationTools/org/tianocore/migration/ModuleReader.java @@ -18,16 +18,20 @@ import java.util.regex.*; import org.tianocore.*; public class ModuleReader { - ModuleReader(String path, ModuleInfo moduleinfo, Database database) { + ModuleReader(String path, ModuleInfo moduleinfo, Database database, UI u) { modulepath = path; mi = moduleinfo; db = database; + ui = u; } private String modulepath; private ModuleInfo mi; private Database db; + private UI ui; - private static Pattern ptninfequation = Pattern.compile("([^ ]*) *= *([^ ]*)"); + private static Pattern ptninfequation = Pattern.compile("([^\\s]*)\\s*=\\s*([^\\s]*)"); + private static Pattern ptnsection = Pattern.compile("\\[([^\\[\\]]*)\\]([^\\[\\]]*)\\n", Pattern.MULTILINE); + private static Pattern ptnfilename = Pattern.compile("[^\\s]+"); public void readMsa(String name) throws Exception { ModuleSurfaceAreaDocument msadoc = ModuleSurfaceAreaDocument.Factory.parse(new File(modulepath + File.separator + name)); @@ -53,40 +57,48 @@ public class ModuleReader { System.out.println("Parsing INF file: " + name); BufferedReader rd = new BufferedReader(new FileReader(modulepath + File.separator + name)); String line; + String wholeline; String[] linecontext; boolean inSrc = false; Matcher mtrinfequation; + Matcher mtrsection; + Matcher mtrfilename; - while ((line = rd.readLine()) != null) { - if (line.length() != 0) { - if (inSrc) { - if (line.contains("[")) { - inSrc = false; - } else { - linecontext = line.split(" "); - if (linecontext[2].length() != 0) { - if (!mi.localmodulesources.contains(linecontext[2])) { - System.out.println("Source File Missing! : " + linecontext[2]); - } - } + wholeline = Common.sourcefiletostring(modulepath + File.separator + name); + mtrsection = ptnsection.matcher(wholeline); + while (mtrsection.find()) { + if (mtrsection.group(1).matches("defines")) { + mtrinfequation = ptninfequation.matcher(mtrsection.group(2)); + while (mtrinfequation.find()) { + if (mtrinfequation.group(1).matches("BASE_NAME")) { + mi.modulename = mtrinfequation.group(2); } - } else { - if ((mtrinfequation = ptninfequation.matcher(line)).find()) { - if (mtrinfequation.group(1).matches("BASE_NAME")) { - mi.modulename = mtrinfequation.group(2); - } - if (mtrinfequation.group(1).matches("FILE_GUID")) { - mi.guidvalue = mtrinfequation.group(2); - } - if (mtrinfequation.group(1).matches("COMPONENT_TYPE")) { - mi.moduletype = mtrinfequation.group(2); - } - if (mtrinfequation.group(1).matches("IMAGE_ENTRY_POINT")) { - mi.entrypoint = mtrinfequation.group(2); + if (mtrinfequation.group(1).matches("FILE_GUID")) { + mi.guidvalue = mtrinfequation.group(2); + } + if (mtrinfequation.group(1).matches("COMPONENT_TYPE")) { + mi.moduletype = mtrinfequation.group(2); + } + } + } + if (mtrsection.group(1).matches("nmake.common")) { + mtrinfequation = ptninfequation.matcher(mtrsection.group(2)); + while (mtrinfequation.find()) { + if (mtrinfequation.group(1).matches("IMAGE_ENTRY_POINT")) { + mi.entrypoint = mtrinfequation.group(2); + } + if (mtrinfequation.group(1).matches("DPX_SOURCE")) { + if (!mi.localmodulesources.contains(mtrinfequation.group(2))) { + ui.println("DPX File Missing! : " + mtrinfequation.group(2)); } } - if (line.contains("sources")) { - inSrc = true; + } + } + if (mtrsection.group(1).contains("sources.")) { + mtrfilename = ptnfilename.matcher(mtrsection.group(2)); + while (mtrfilename.find()) { + if (!mi.localmodulesources.contains(mtrfilename.group())) { + ui.println("Source File Missing! : " + mtrfilename.group()); } } }