X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=Tools%2FSource%2FFrameworkTasks%2Forg%2Ftianocore%2Fframework%2Ftasks%2FStrGatherTask.java;h=541e96f54f785b2b0f06d4a14c5e892138a82243;hb=76c86b3ac42df05d2116346bb95cf9462eb2729c;hp=b84adf2525d25de9ebfbb769dd7f2d0c12312dca;hpb=82810f3b0f9ba49ed2d9f96c5b53e90dd7e66d88;p=mirror_edk2.git diff --git a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/StrGatherTask.java b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/StrGatherTask.java index b84adf2525..541e96f54f 100644 --- a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/StrGatherTask.java +++ b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/StrGatherTask.java @@ -14,14 +14,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. package org.tianocore.framework.tasks; import java.io.File; -import java.util.*; - import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.ant.Task; import org.apache.tools.ant.taskdefs.Execute; import org.apache.tools.ant.taskdefs.LogStreamHandler; import org.apache.tools.ant.types.Commandline; +import org.tianocore.common.logger.EdkLog; /** StrGather Task Class @@ -45,58 +44,63 @@ import org.apache.tools.ant.types.Commandline; -outputHpk : create an HII export pack of the strings **/ public class StrGatherTask extends Task implements EfiDefine { - /// - /// common options - /// - private String commandType = ""; + // + // Tool name + // + private static String toolName = "StrGather"; + + // + // common options + // + private ToolArg commandType = new ToolArg(); - private String baseName = ""; + private ToolArg baseName = new ToolArg(); - /// - /// "all/read/write" - /// - private String verbose = ""; + // + // "all/read/write" + // + private ToolArg verbose = new ToolArg(); - private String outputDatabase = ""; + private FileArg outputDatabase = new FileArg(); - private List databaseList = new ArrayList(); + private Database databaseList = new Database(); - private List inputFileList = new ArrayList(); + private InputFile inputFileList = new InputFile(); - /// - /// parse options newDatabase -- "ture/false" unquoteString -- "ture/false" - /// - private String newDatabase = ""; + // + // parse options newDatabase -- "ture/false" unquoteString -- "ture/false" + // + private ToolArg newDatabase = new ToolArg(); - private String unquotedString = ""; + private ToolArg unquotedString = new ToolArg(); - private List includePathList = new ArrayList(); + private IncludePath includePathList = new IncludePath(); - /// - /// scan options ignoreNotFound -- "ture/false" - /// - private String ignoreNotFound = ""; + // + // scan options ignoreNotFound -- "ture/false" + // + private ToolArg ignoreNotFound = new ToolArg(); - private List skipExtList = new ArrayList(); + private SkipExt skipExtList = new SkipExt(); - /// - /// dump options - /// - private String outputString = ""; + // + // dump options + // + private ToolArg outputString = new ToolArg(); - private String outputDefines = ""; + private ToolArg outputDefines = new ToolArg(); - private String outputUnicode = ""; + private ToolArg outputUnicode = new ToolArg(); - private String lang = ""; + private ToolArg lang = new ToolArg(); - private String indirectionFile = ""; + private FileArg indirectionFile = new FileArg(); - private String outputHpk = ""; + private FileArg outputHpk = new FileArg(); - /// - /// global variable - /// + // + // global variable + // static private Project project; /** @@ -113,27 +117,19 @@ public class StrGatherTask extends Task implements EfiDefine { String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH"); String command; if (path == null) { - command = "StrGather"; + command = toolName; } else { - command = path + File.separator + "StrGather"; + command = path + File.separator + toolName; } - /// - /// transfer nested elements into string - /// - String databases = list2Str(databaseList); - String skipExts = list2Str(skipExtList); - String includePaths = list2Str(includePathList); - String inputFiles = list2Str(inputFileList); - /// /// assemble argument /// - String argument = commandType + verbose + databases + baseName - + outputDatabase + includePaths + newDatabase + unquotedString - + skipExts + ignoreNotFound + outputString + outputDefines + String argument = "" + commandType + verbose + databaseList + baseName + + outputDatabase + includePathList + newDatabase + unquotedString + + skipExtList + ignoreNotFound + outputString + outputDefines + outputUnicode + lang + indirectionFile + outputHpk - + inputFiles; + + inputFileList; /// /// return value of fwimage execution /// @@ -151,17 +147,28 @@ public class StrGatherTask extends Task implements EfiDefine { runner.setAntRun(project); runner.setCommandline(cmdline.getCommandline()); - log(Commandline.toString(cmdline.getCommandline()), Project.MSG_VERBOSE); - log(this.commandType.substring(2)); + String cmdType = getCommandType(); + if (cmdType.equalsIgnoreCase("parse")) { + EdkLog.log(this, "(parse) " + inputFileList.toFileList() + " => " + + databaseList.toFileList()); + } else if (cmdType.equalsIgnoreCase("scan")) { + EdkLog.log(this, "(scan) " + databaseList.toFileList() + " => " + + outputDatabase.toFileList()); + } else { + EdkLog.log(this, "(dump) " + databaseList.toFileList() + " => " + + outputDefines.toFileList() + outputString.toFileList() + outputHpk.toFileList()); + } + EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline())); + revl = runner.execute(); if (EFI_SUCCESS == revl) { - log("StrGather succeeded!", Project.MSG_VERBOSE); + EdkLog.log(this, EdkLog.EDK_VERBOSE, toolName + " succeeded!"); } else { /// /// command execution fail /// - log("ERROR = " + Integer.toHexString(revl)); - throw new BuildException("StrGather failed!"); + EdkLog.log(this, "ERROR = " + Integer.toHexString(revl)); + throw new BuildException(toolName + " failed!"); } } catch (Exception e) { throw new BuildException(e.getMessage()); @@ -174,7 +181,7 @@ public class StrGatherTask extends Task implements EfiDefine { @returns commandType parameter **/ public String getCommandType() { - return this.commandType; + return this.commandType.getValue(); } /** @@ -183,7 +190,7 @@ public class StrGatherTask extends Task implements EfiDefine { @param commandType type of strgather command [parse/scan/dump] **/ public void setCommandType(String commandType) { - this.commandType = " -" + commandType; + this.commandType.setArg(" -", commandType); } /** @@ -192,7 +199,7 @@ public class StrGatherTask extends Task implements EfiDefine { @returns verbose parameter **/ public String getVerbose() { - return this.verbose; + return this.verbose.getValue(); } /** @@ -205,17 +212,17 @@ public class StrGatherTask extends Task implements EfiDefine { /// /// for verbose output /// - this.verbose = " -v "; + this.verbose.setArg(" -", "v"); } else if (verbose.equals("read")) { /// /// for verbose output when reading database /// - this.verbose = " -vdbr "; + this.verbose.setArg(" -", "vdbr"); } else if (verbose.equals("write")) { /// /// for verbose output when writing database /// - this.verbose = " -vdbw "; + this.verbose.setArg(" -", "vdbw"); } } @@ -225,7 +232,7 @@ public class StrGatherTask extends Task implements EfiDefine { @returns baseName parameter **/ public String getBaseName() { - return this.baseName; + return this.baseName.getValue(); } /** @@ -234,7 +241,7 @@ public class StrGatherTask extends Task implements EfiDefine { @param baseName name of the output files of .c and .h **/ public void setBaseName(String baseName) { - this.baseName = " -bn " + baseName; + this.baseName.setArg(" -bn ", baseName); } /** @@ -243,7 +250,7 @@ public class StrGatherTask extends Task implements EfiDefine { @returns outputDatabase parameter **/ public String getOutputDatabase() { - return this.outputDatabase; + return this.outputDatabase.getValue(); } /** @@ -252,7 +259,7 @@ public class StrGatherTask extends Task implements EfiDefine { @param outputDatabase filename of output database file **/ public void setOutputDatabase(String outputDatabase) { - this.outputDatabase = " -od " + outputDatabase; + this.outputDatabase.setArg(" -od ", outputDatabase); } /** @@ -260,8 +267,8 @@ public class StrGatherTask extends Task implements EfiDefine { @returns newDatabase parameter **/ - public String getNewDatabse() { - return this.newDatabase; + public boolean getNewDatabse() { + return this.newDatabase.getPrefix().length() > 0; } /** @@ -269,9 +276,9 @@ public class StrGatherTask extends Task implements EfiDefine { @param newDatabase whether to not read in existing database file **/ - public void setNewDatabase(String newDatabase) { - if (newDatabase.equals("true")) { - this.newDatabase = " -newdb "; + public void setNewDatabase(boolean newDatabase) { + if (newDatabase) { + this.newDatabase.setArg(" -", "newdb"); } } @@ -280,8 +287,8 @@ public class StrGatherTask extends Task implements EfiDefine { @returns unquotedString parameter **/ - public String getUnquotedString() { - return this.unquotedString; + public boolean getUnquotedString() { + return this.unquotedString.getValue().length() > 0; } /** @@ -290,9 +297,9 @@ public class StrGatherTask extends Task implements EfiDefine { @param unquotedString : whether to indicate that unquoted strings are used **/ - public void setUnquotedString(String unquotedString) { - if (unquotedString.equals("true")) { - this.unquotedString = " -uqs "; + public void setUnquotedString(boolean unquotedString) { + if (unquotedString) { + this.unquotedString.setArg(" -", "uqs"); } } @@ -301,8 +308,8 @@ public class StrGatherTask extends Task implements EfiDefine { @returns ignoreNotFound parameter **/ - public String getIgnoreNotFound() { - return this.ignoreNotFound; + public boolean getIgnoreNotFound() { + return this.ignoreNotFound.getValue().length() > 0; } /** @@ -311,9 +318,9 @@ public class StrGatherTask extends Task implements EfiDefine { @param ignoreNotFound whether to ignore if a given STRING_TOKEN(STR) is not found in the database **/ - public void setIgnoreNotFound(String ignoreNotFound) { - if (ignoreNotFound.equals("true")) { - this.ignoreNotFound = " -ignorenotfound "; + public void setIgnoreNotFound(boolean ignoreNotFound) { + if (ignoreNotFound) { + this.ignoreNotFound.setArg(" -", "ignorenotfound"); } } @@ -323,7 +330,7 @@ public class StrGatherTask extends Task implements EfiDefine { @returns outputString parameter **/ public String getOutputString() { - return this.outputString; + return this.outputString.getValue(); } /** @@ -332,7 +339,7 @@ public class StrGatherTask extends Task implements EfiDefine { @param outputString filename of string data file **/ public void setOutputString(String outputString) { - this.outputString = " -oc " + outputString; + this.outputString.setArg(" -oc ", outputString); } /** @@ -341,7 +348,7 @@ public class StrGatherTask extends Task implements EfiDefine { @returns outputDefines parameter **/ public String getOutputDefines() { - return this.outputDefines; + return this.outputDefines.getValue(); } /** @@ -350,7 +357,7 @@ public class StrGatherTask extends Task implements EfiDefine { @param outputDefines filename of string defines file **/ public void setOutputDefines(String outputDefines) { - this.outputDefines = " -oh " + outputDefines; + this.outputDefines.setArg(" -oh ", outputDefines); } /** @@ -359,7 +366,7 @@ public class StrGatherTask extends Task implements EfiDefine { @returns outputUnicode parameter **/ public String getOutputUnicode() { - return this.outputUnicode; + return this.outputUnicode.getValue(); } /** @@ -368,7 +375,7 @@ public class StrGatherTask extends Task implements EfiDefine { @param outputUnicode filename of unicode file to be dumped database **/ public void setOutputUnicode(String outputUnicode) { - this.outputUnicode = " -ou " + outputUnicode; + this.outputUnicode.setArg(" -ou ", outputUnicode); } /** @@ -377,7 +384,7 @@ public class StrGatherTask extends Task implements EfiDefine { @returns lang parameter **/ public String getLang() { - return this.lang; + return this.lang.getValue(); } /** @@ -386,7 +393,7 @@ public class StrGatherTask extends Task implements EfiDefine { @param lang language of dump **/ public void setLang(String lang) { - this.lang = " -lang " + lang; + this.lang.setArg(" -lang ", lang); } /** @@ -395,7 +402,7 @@ public class StrGatherTask extends Task implements EfiDefine { @returns indirectionFile parameter **/ public String getIndirectionFile() { - return this.indirectionFile; + return this.indirectionFile.getValue(); } /** @@ -404,7 +411,7 @@ public class StrGatherTask extends Task implements EfiDefine { @param indirectionFile filename of indirection file **/ public void setIndirectionFile(String indirectionFile) { - this.indirectionFile = " -if " + indirectionFile; + this.indirectionFile.setArg(" -if ", indirectionFile); } /** @@ -413,7 +420,7 @@ public class StrGatherTask extends Task implements EfiDefine { @returns outputHpk parameter **/ public String getOutputHpk() { - return this.outputHpk; + return this.outputHpk.getValue(); } /** @@ -422,7 +429,7 @@ public class StrGatherTask extends Task implements EfiDefine { @param outputHpk filename of output HII export pack of the strings **/ public void setOutputHpk(String outputHpk) { - this.outputHpk = " -hpk " + outputHpk; + this.outputHpk.setArg(" -hpk ", outputHpk); } /** @@ -430,8 +437,8 @@ public class StrGatherTask extends Task implements EfiDefine { @param skipExt skipExt element **/ - public void addSkipext(SkipExt skipExt) { - skipExtList.add(skipExt); + public void addConfiguredSkipext(SkipExt skipExt) { + this.skipExtList.insert(skipExt); }; /** @@ -439,8 +446,8 @@ public class StrGatherTask extends Task implements EfiDefine { @param includePath includePath element **/ - public void addIncludepath(IncludePath includePath) { - includePathList.add(includePath); + public void addConfiguredIncludepath(IncludePath includePath) { + this.includePathList.insert(includePath); }; /** @@ -448,8 +455,8 @@ public class StrGatherTask extends Task implements EfiDefine { @param inputFile inputFile element **/ - public void addInputfile(InputFile inputFile) { - inputFileList.add(inputFile); + public void addConfiguredInputfile(InputFile inputFile) { + this.inputFileList.insert(inputFile); }; /** @@ -458,25 +465,7 @@ public class StrGatherTask extends Task implements EfiDefine { @param database : database element **/ - public void addDatabase(Database database) { - databaseList.add(database); - } - - /** - Compose the content in each NestElement into a single string. - - @param list The NestElement list - - @return String - **/ - private String list2Str(List list) { - int listLength = list.size(); - String str = ""; - for (int i = 0; i < listLength; ++i) { - NestElement e = (NestElement)list.get(i); - str += e.toString(); - } - - return str; + public void addConfiguredDatabase(Database database) { + this.databaseList.insert(database); } }