From 06d1ff5b981e7808c5499b74cea4857cd8e5f957 Mon Sep 17 00:00:00 2001 From: qhuang8 Date: Mon, 11 Sep 2006 09:53:28 +0000 Subject: [PATCH] Remove the special case handling of EfiInitializeDriverLib & DxeIntializeDriverLib git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1511 6f19259b-4bc3-4df7-8a09-765794883524 --- Tools/Conf/Migration/Library.csv | 2 - .../org/tianocore/migration/Common.java | 5 +++ .../migration/SourceFileReplacer.java | 44 ++++++------------- 3 files changed, 19 insertions(+), 32 deletions(-) diff --git a/Tools/Conf/Migration/Library.csv b/Tools/Conf/Migration/Library.csv index 2e3195af96..045a3cfad0 100644 --- a/Tools/Conf/Migration/Library.csv +++ b/Tools/Conf/Migration/Library.csv @@ -2,8 +2,6 @@ R8.5LibClass,R8.5Lib,R9Lib,R9LibClass,Package EfiDriverLib,EfiCopyMem,CopyMem,BaseMemoryLib,MdePkg EfiDriverLib,EfiSetMem,SetMem,BaseMemoryLib,MdePkg EfiDriverLib,EfiZeroMem,ZeroMem,BaseMemoryLib,MdePkg -EfiDriverLib,EfiInitializeDriverLib,//EfiInitializeDriverLib,UefiBootServicesTableLib; UefiRuntimeServicesTableLib,MdePkg -EfiDriverLib,DxeInitializeDriverLib,//DxeInitializeDriverLib,UefiBootServicesTableLib; UefiRuntimeServicesTableLib; DxeServicesTableLib,MdePkg EfiDriverLib,EfiLibInstallDriverBinding,R8_EfiLibInstallDriverBinding,%,MdePkg EfiDriverLib,EfiLibInstallAllDriverProtocols,R8_EfiLibInstallAllDriverProtocols,%,MdePkg EfiDriverLib,EfiLibCompareLanguage,R8_EfiLibCompareLanguage,%,MdePkg diff --git a/Tools/Source/MigrationTools/org/tianocore/migration/Common.java b/Tools/Source/MigrationTools/org/tianocore/migration/Common.java index 23e2319dcf..2f10521238 100644 --- a/Tools/Source/MigrationTools/org/tianocore/migration/Common.java +++ b/Tools/Source/MigrationTools/org/tianocore/migration/Common.java @@ -37,6 +37,11 @@ public final class Common { return line; } + public static final boolean find (String line, String regex) { + Pattern ptn = Pattern.compile(regex); + + return ptn.matcher (line).find (); + } //-------------------------------------regex------------------------------------------// //-----------------------------------file&string---------------------------------------// diff --git a/Tools/Source/MigrationTools/org/tianocore/migration/SourceFileReplacer.java b/Tools/Source/MigrationTools/org/tianocore/migration/SourceFileReplacer.java index 3238e29df9..446c5e4426 100644 --- a/Tools/Source/MigrationTools/org/tianocore/migration/SourceFileReplacer.java +++ b/Tools/Source/MigrationTools/org/tianocore/migration/SourceFileReplacer.java @@ -89,27 +89,20 @@ public final class SourceFileReplacer implements Common.ForDoAll { public String operation(String wholeline) { boolean addr8 = false; - Pattern pat = Pattern.compile("g?(BS|RT)(\\s*->\\s*)([a-zA-Z_]\\w*)", Pattern.MULTILINE); // ! only two level () bracket allowed ! - //Pattern ptnpei = Pattern.compile("\\(\\*\\*?PeiServices\\)[.-][>]?\\s*(\\w*[#$]*)(\\s*\\(([^\\(\\)]*(\\([^\\(\\)]*\\))?[^\\(\\)]*)*\\))", Pattern.MULTILINE); - - // replace BS -> gBS , RT -> gRT - Matcher mat = pat.matcher(wholeline); - if (mat.find()) { // add a library here - MigrationTool.ui.println("Converting all BS->gBS, RT->gRT"); - wholeline = mat.replaceAll("g$1$2$3"); //unknown correctiveness - } - mat.reset(); - while (mat.find()) { - if (mat.group(1).matches("BS")) { - mi.hashrequiredr9libs.add("UefiBootServicesTableLib"); - } - if (mat.group(1).matches("RT")) { - mi.hashrequiredr9libs.add("UefiRuntimeServicesTableLib"); - } - } // remove EFI_DRIVER_ENTRY_POINT wholeline = wholeline.replaceAll("(EFI_\\w+_ENTRY_POINT)", MigrationTool.MIGRATIONCOMMENT + " $1"); - + // remove R8 library contractor + wholeline = wholeline.replaceAll ("(\\b(?:Efi|Dxe)InitializeDriverLib\\b)", MigrationTool.MIGRATIONCOMMENT + " $1"); + // Add Library Class for potential reference of gBS, gRT & gDS. + if (Common.find (wholeline, "\\bg?BS\\b")) { + mi.hashrequiredr9libs.add("UefiBootServicesTableLib"); + } + if (Common.find (wholeline, "\\bg?RT\\b")) { + mi.hashrequiredr9libs.add ("UefiRuntimeServicesTableLib"); + } + if (Common.find (wholeline, "\\bgDS\\b")) { + mi.hashrequiredr9libs.add ("DxeServicesTableLib"); + } // start replacing names String r8thing; String r9thing; @@ -118,17 +111,8 @@ public final class SourceFileReplacer implements Common.ForDoAll { it = mi.hashnonlocalfunc.iterator(); while (it.hasNext()) { r8thing = it.next(); - if (r8thing.matches("EfiInitializeDriverLib")) { //s - mi.hashrequiredr9libs.add("UefiBootServicesTableLib"); //p - mi.hashrequiredr9libs.add("UefiRuntimeServicesTableLib"); //e - } else if (r8thing.matches("DxeInitializeDriverLib")) { //c - mi.hashrequiredr9libs.add("UefiBootServicesTableLib"); //i - mi.hashrequiredr9libs.add("UefiRuntimeServicesTableLib"); //a - mi.hashrequiredr9libs.add("DxeServicesTableLib"); //l - } else { // - mi.hashrequiredr9libs.add(MigrationTool.db.getR9Lib(r8thing)); // add a library here - } - + mi.hashrequiredr9libs.add(MigrationTool.db.getR9Lib(r8thing)); // add a library here + r8tor9 temp; if ((r9thing = MigrationTool.db.getR9Func(r8thing)) != null) { if (!r8thing.equals(r9thing)) {