4 ModifyInfTask is used to call Modify.exe to generate inf file.
7 Copyright (c) 2006, Intel Corporation
8 All rights reserved. This program and the accompanying materials
9 are licensed and made available under the terms and conditions of the BSD License
10 which accompanies this distribution. The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 package org
.tianocore
.framework
.tasks
;
21 import org
.apache
.tools
.ant
.Task
;
22 import org
.apache
.tools
.ant
.Project
;
23 import org
.apache
.tools
.ant
.BuildException
;
24 import org
.apache
.tools
.ant
.taskdefs
.Execute
;
25 import org
.apache
.tools
.ant
.taskdefs
.LogStreamHandler
;
26 import org
.apache
.tools
.ant
.types
.Commandline
;
27 import org
.tianocore
.logger
.EdkLog
;
32 ModifyInfTask is used to call Modify.exe to generate inf file.
34 public class ModifyInfTask
extends Task
implements EfiDefine
{
38 private String toolName
= "ModifyInf";
43 private String inputFVInfFileName
= "";
46 /// output FV inf file
48 private String outputFVInfFileName
= "";
53 private String patternStr
= "";
58 private String outputDir
= "";
63 * ModifyInfTask execute function is to assemble tool command line & execute
66 * @throws BuidException
68 public void execute() throws BuildException
{
70 Project project
= this.getOwningTarget().getProject();
74 FrameworkLogger logger
= new FrameworkLogger(project
, "modifytask");
75 EdkLog
.setLogLevel(project
.getProperty("env.LOGLEVEL"));
76 EdkLog
.setLogger(logger
);
78 // absolute path of efi tools
80 String path
= project
.getProperty("env.FRAMEWORK_TOOLS_PATH");
86 command
= path
+ File
.separatorChar
+ toolName
;
91 File file
= new File(outputFVInfFileName
);
92 if (!file
.isAbsolute() && (!this.outputDir
.equalsIgnoreCase(""))) {
93 argument
= this.inputFVInfFileName
+
96 this.outputFVInfFileName
+
99 argument
= this.inputFVInfFileName
+
100 this.outputFVInfFileName
+
104 // return value of fwimage execution
109 Commandline cmdline
= new Commandline();
110 cmdline
.setExecutable(command
);
111 cmdline
.createArgument().setLine(argument
);
113 LogStreamHandler streamHandler
= new LogStreamHandler(this,
114 Project
.MSG_INFO
, Project
.MSG_WARN
);
115 Execute runner
= new Execute(streamHandler
, null);
117 runner
.setAntRun(project
);
118 runner
.setCommandline(cmdline
.getCommandline());
120 // Set debug log information.
122 EdkLog
.log(EdkLog
.EDK_VERBOSE
, Commandline
.toString(cmdline
.getCommandline()));
123 EdkLog
.log(EdkLog
.EDK_INFO
, (new File(this.inputFVInfFileName
)).getName());
124 revl
= runner
.execute();
126 if (EFI_SUCCESS
== revl
) {
128 // command execution success
130 EdkLog
.log(EdkLog
.EDK_VERBOSE
, "ModifyInfTask succeeded!");
133 // command execution fail
135 EdkLog
.log(EdkLog
.EDK_INFO
, "ERROR = " + Integer
.toHexString(revl
));
136 throw new BuildException("ModifyInfTask failed!");
138 } catch (Exception e
) {
139 throw new BuildException(e
.getMessage());
144 * getinputFVInfFileName
146 * This function is to get class member "inputFVInfFileName".
148 * @return string of input inf file name.
150 public String
getinputFVInfFileName() {
151 return this.inputFVInfFileName
;
155 * setinputFVInfFileName
157 * This function is to set class member "inputFVInfFileName".
160 * string of input inf file name.
162 public void setinputFVInfFileName(String inputFVInfFileName
) {
163 this.inputFVInfFileName
= inputFVInfFileName
+ " ";
167 * getoutputFVInfFileName
169 * This function is to get class member "outputFVInfFileName"
171 * @return outputFVInfFileName string of output inf file name.
173 public String
getoutputFVInfFileName() {
174 return this.outputFVInfFileName
;
178 * setoutputFVInfFileName
180 * This function is to set class member "outputFVInfFileName"
182 * @param outputFVInfFileName
183 * string of output inf file name.
185 public void setoutputFVInfFileName(String outputFVInfFileName
) {
186 this.outputFVInfFileName
= outputFVInfFileName
+ " ";
192 * This function is to get class member "patternStr"
194 * @return patternStr string of pattern.
196 public String
getpatternStr() {
197 return this.patternStr
;
203 * This function is to set class member "patternStr"
206 * string of patternStr.
208 public void setpatternStr(String patternStr
) {
209 this.patternStr
= patternStr
;
215 * This function is to get class member "outputDir"
217 * @return outputDir string of output directory.
219 public String
getoutputDir() {
220 return this.outputDir
;
226 * This function is to set class member "outputDir"
229 * string of output directory.
231 public void setoutputDir(String outputDir
) {
232 this.outputDir
= outputDir
;