import org.apache.tools.ant.taskdefs.Execute;\r
import org.apache.tools.ant.taskdefs.LogStreamHandler;\r
import org.apache.tools.ant.types.Commandline;\r
+import org.tianocore.common.logger.EdkLog;\r
\r
/**\r
StrGather Task Class\r
///\r
/// common options\r
///\r
- private String commandType = "";\r
+ private ToolArg commandType = new ToolArg();\r
\r
- private String baseName = "";\r
+ private ToolArg baseName = new ToolArg();\r
\r
///\r
/// "all/read/write"\r
///\r
- private String verbose = "";\r
+ private ToolArg verbose = new ToolArg();\r
\r
- private String outputDatabase = "";\r
+ private FileArg outputDatabase = new FileArg();\r
\r
- private List<Database> databaseList = new ArrayList<Database>();\r
+ private Database databaseList = new Database();\r
\r
- private List<InputFile> inputFileList = new ArrayList<InputFile>();\r
+ private InputFile inputFileList = new InputFile();\r
\r
///\r
/// parse options newDatabase -- "ture/false" unquoteString -- "ture/false"\r
///\r
- private String newDatabase = "";\r
+ private ToolArg newDatabase = new ToolArg();\r
\r
- private String unquotedString = "";\r
+ private ToolArg unquotedString = new ToolArg();\r
\r
- private List<IncludePath> includePathList = new ArrayList<IncludePath>();\r
+ private IncludePath includePathList = new IncludePath();\r
\r
///\r
/// scan options ignoreNotFound -- "ture/false"\r
///\r
- private String ignoreNotFound = "";\r
+ private ToolArg ignoreNotFound = new ToolArg();\r
\r
- private List<SkipExt> skipExtList = new ArrayList<SkipExt>();\r
+ private SkipExt skipExtList = new SkipExt();\r
\r
///\r
/// dump options\r
///\r
- private String outputString = "";\r
+ private ToolArg outputString = new ToolArg();\r
\r
- private String outputDefines = "";\r
+ private ToolArg outputDefines = new ToolArg();\r
\r
- private String outputUnicode = "";\r
+ private ToolArg outputUnicode = new ToolArg();\r
\r
- private String lang = "";\r
+ private ToolArg lang = new ToolArg();\r
\r
- private String indirectionFile = "";\r
+ private FileArg indirectionFile = new FileArg();\r
\r
- private String outputHpk = "";\r
+ private FileArg outputHpk = new FileArg();\r
\r
///\r
/// global variable\r
command = path + File.separator + "StrGather";\r
}\r
\r
- ///\r
- /// transfer nested elements into string\r
- ///\r
- String databases = list2Str(databaseList);\r
- String skipExts = list2Str(skipExtList);\r
- String includePaths = list2Str(includePathList);\r
- String inputFiles = list2Str(inputFileList);\r
-\r
///\r
/// assemble argument\r
///\r
- String argument = commandType + verbose + databases + baseName\r
- + outputDatabase + includePaths + newDatabase + unquotedString\r
- + skipExts + ignoreNotFound + outputString + outputDefines\r
+ String argument = "" + commandType + verbose + databaseList + baseName\r
+ + outputDatabase + includePathList + newDatabase + unquotedString\r
+ + skipExtList + ignoreNotFound + outputString + outputDefines\r
+ outputUnicode + lang + indirectionFile + outputHpk\r
- + inputFiles;\r
+ + inputFileList;\r
///\r
/// return value of fwimage execution\r
///\r
runner.setAntRun(project);\r
runner.setCommandline(cmdline.getCommandline());\r
\r
- log(Commandline.toString(cmdline.getCommandline()), Project.MSG_VERBOSE);\r
- log(this.commandType.substring(2));\r
+ String cmdType = getCommandType();\r
+ if (cmdType.equalsIgnoreCase("parse")) {\r
+ EdkLog.log(this, "(parse) " + inputFileList.toFileList() + " => " \r
+ + databaseList.toFileList());\r
+ } else if (cmdType.equalsIgnoreCase("scan")) {\r
+ EdkLog.log(this, "(scan) " + databaseList.toFileList() + " => " \r
+ + outputDatabase.toFileList());\r
+ } else {\r
+ EdkLog.log(this, "(dump) " + databaseList.toFileList() + " => " \r
+ + outputDefines.toFileList() + outputString.toFileList() + outputHpk.toFileList());\r
+ }\r
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));\r
+\r
revl = runner.execute();\r
if (EFI_SUCCESS == revl) {\r
- log("StrGather succeeded!", Project.MSG_VERBOSE);\r
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, "StrGather succeeded!");\r
} else {\r
///\r
/// command execution fail\r
///\r
- log("ERROR = " + Integer.toHexString(revl));\r
+ EdkLog.log(this, "ERROR = " + Integer.toHexString(revl));\r
throw new BuildException("StrGather failed!");\r
}\r
} catch (Exception e) {\r
@returns commandType parameter\r
**/\r
public String getCommandType() {\r
- return this.commandType;\r
+ return this.commandType.getValue();\r
}\r
\r
/**\r
@param commandType type of strgather command [parse/scan/dump]\r
**/\r
public void setCommandType(String commandType) {\r
- this.commandType = " -" + commandType;\r
+ this.commandType.setArg(" -", commandType);\r
}\r
\r
/**\r
@returns verbose parameter\r
**/\r
public String getVerbose() {\r
- return this.verbose;\r
+ return this.verbose.getValue();\r
}\r
\r
/**\r
///\r
/// for verbose output\r
///\r
- this.verbose = " -v ";\r
+ this.verbose.setArg(" -", "v");\r
} else if (verbose.equals("read")) {\r
///\r
/// for verbose output when reading database\r
///\r
- this.verbose = " -vdbr ";\r
+ this.verbose.setArg(" -", "vdbr");\r
} else if (verbose.equals("write")) {\r
///\r
/// for verbose output when writing database\r
///\r
- this.verbose = " -vdbw ";\r
+ this.verbose.setArg(" -", "vdbw");\r
}\r
}\r
\r
@returns baseName parameter\r
**/\r
public String getBaseName() {\r
- return this.baseName;\r
+ return this.baseName.getValue();\r
}\r
\r
/**\r
@param baseName name of the output files of .c and .h\r
**/\r
public void setBaseName(String baseName) {\r
- this.baseName = " -bn " + baseName;\r
+ this.baseName.setArg(" -bn ", baseName);\r
}\r
\r
/**\r
@returns outputDatabase parameter\r
**/\r
public String getOutputDatabase() {\r
- return this.outputDatabase;\r
+ return this.outputDatabase.getValue();\r
}\r
\r
/**\r
@param outputDatabase filename of output database file\r
**/\r
public void setOutputDatabase(String outputDatabase) {\r
- this.outputDatabase = " -od " + outputDatabase;\r
+ this.outputDatabase.setArg(" -od ", outputDatabase);\r
}\r
\r
/**\r
\r
@returns newDatabase parameter\r
**/\r
- public String getNewDatabse() {\r
- return this.newDatabase;\r
+ public boolean getNewDatabse() {\r
+ return this.newDatabase.getPrefix().length() > 0;\r
}\r
\r
/**\r
\r
@param newDatabase whether to not read in existing database file\r
**/\r
- public void setNewDatabase(String newDatabase) {\r
- if (newDatabase.equals("true")) {\r
- this.newDatabase = " -newdb ";\r
+ public void setNewDatabase(boolean newDatabase) {\r
+ if (newDatabase) {\r
+ this.newDatabase.setArg(" -", "newdb");\r
}\r
}\r
\r
\r
@returns unquotedString parameter\r
**/\r
- public String getUnquotedString() {\r
- return this.unquotedString;\r
+ public boolean getUnquotedString() {\r
+ return this.unquotedString.getValue().length() > 0;\r
}\r
\r
/**\r
@param unquotedString :\r
whether to indicate that unquoted strings are used\r
**/\r
- public void setUnquotedString(String unquotedString) {\r
- if (unquotedString.equals("true")) {\r
- this.unquotedString = " -uqs ";\r
+ public void setUnquotedString(boolean unquotedString) {\r
+ if (unquotedString) {\r
+ this.unquotedString.setArg(" -", "uqs");\r
}\r
}\r
\r
\r
@returns ignoreNotFound parameter\r
**/\r
- public String getIgnoreNotFound() {\r
- return this.ignoreNotFound;\r
+ public boolean getIgnoreNotFound() {\r
+ return this.ignoreNotFound.getValue().length() > 0;\r
}\r
\r
/**\r
@param ignoreNotFound whether to ignore if a given STRING_TOKEN(STR) \r
is not found in the database\r
**/\r
- public void setIgnoreNotFound(String ignoreNotFound) {\r
- if (ignoreNotFound.equals("true")) {\r
- this.ignoreNotFound = " -ignorenotfound ";\r
+ public void setIgnoreNotFound(boolean ignoreNotFound) {\r
+ if (ignoreNotFound) {\r
+ this.ignoreNotFound.setArg(" -", "ignorenotfound");\r
}\r
}\r
\r
@returns outputString parameter\r
**/\r
public String getOutputString() {\r
- return this.outputString;\r
+ return this.outputString.getValue();\r
}\r
\r
/**\r
@param outputString filename of string data file\r
**/\r
public void setOutputString(String outputString) {\r
- this.outputString = " -oc " + outputString;\r
+ this.outputString.setArg(" -oc ", outputString);\r
}\r
\r
/**\r
@returns outputDefines parameter\r
**/\r
public String getOutputDefines() {\r
- return this.outputDefines;\r
+ return this.outputDefines.getValue();\r
}\r
\r
/**\r
@param outputDefines filename of string defines file\r
**/\r
public void setOutputDefines(String outputDefines) {\r
- this.outputDefines = " -oh " + outputDefines;\r
+ this.outputDefines.setArg(" -oh ", outputDefines);\r
}\r
\r
/**\r
@returns outputUnicode parameter\r
**/\r
public String getOutputUnicode() {\r
- return this.outputUnicode;\r
+ return this.outputUnicode.getValue();\r
}\r
\r
/**\r
@param outputUnicode filename of unicode file to be dumped database\r
**/\r
public void setOutputUnicode(String outputUnicode) {\r
- this.outputUnicode = " -ou " + outputUnicode;\r
+ this.outputUnicode.setArg(" -ou ", outputUnicode);\r
}\r
\r
/**\r
@returns lang parameter\r
**/\r
public String getLang() {\r
- return this.lang;\r
+ return this.lang.getValue();\r
}\r
\r
/**\r
@param lang language of dump\r
**/\r
public void setLang(String lang) {\r
- this.lang = " -lang " + lang;\r
+ this.lang.setArg(" -lang ", lang);\r
}\r
\r
/**\r
@returns indirectionFile parameter\r
**/\r
public String getIndirectionFile() {\r
- return this.indirectionFile;\r
+ return this.indirectionFile.getValue();\r
}\r
\r
/**\r
@param indirectionFile filename of indirection file\r
**/\r
public void setIndirectionFile(String indirectionFile) {\r
- this.indirectionFile = " -if " + indirectionFile;\r
+ this.indirectionFile.setArg(" -if ", indirectionFile);\r
}\r
\r
/**\r
@returns outputHpk parameter\r
**/\r
public String getOutputHpk() {\r
- return this.outputHpk;\r
+ return this.outputHpk.getValue();\r
}\r
\r
/**\r
@param outputHpk filename of output HII export pack of the strings\r
**/\r
public void setOutputHpk(String outputHpk) {\r
- this.outputHpk = " -hpk " + outputHpk;\r
+ this.outputHpk.setArg(" -hpk ", outputHpk);\r
}\r
\r
/**\r
\r
@param skipExt skipExt element\r
**/\r
- public void addSkipext(SkipExt skipExt) {\r
- skipExtList.add(skipExt);\r
+ public void addConfiguredSkipext(SkipExt skipExt) {\r
+ this.skipExtList.insert(skipExt);\r
};\r
\r
/**\r
\r
@param includePath includePath element\r
**/\r
- public void addIncludepath(IncludePath includePath) {\r
- includePathList.add(includePath);\r
+ public void addConfiguredIncludepath(IncludePath includePath) {\r
+ this.includePathList.insert(includePath);\r
};\r
\r
/**\r
\r
@param inputFile inputFile element\r
**/\r
- public void addInputfile(InputFile inputFile) {\r
- inputFileList.add(inputFile);\r
+ public void addConfiguredInputfile(InputFile inputFile) {\r
+ this.inputFileList.insert(inputFile);\r
};\r
\r
/**\r
@param database :\r
database element\r
**/\r
- public void addDatabase(Database database) {\r
- databaseList.add(database);\r
- }\r
-\r
- /**\r
- Compose the content in each NestElement into a single string.\r
-\r
- @param list The NestElement list\r
- \r
- @return String\r
- **/\r
- private String list2Str(List list) {\r
- int listLength = list.size();\r
- String str = "";\r
- for (int i = 0; i < listLength; ++i) {\r
- NestElement e = (NestElement)list.get(i);\r
- str += e.toString();\r
- }\r
-\r
- return str;\r
+ public void addConfiguredDatabase(Database database) {\r
+ this.databaseList.insert(database);\r
}\r
}\r