]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/ModifyInfTask.java
Modify ModifyInf task's attributes from "inputfvinffilename" to "inputfvinffile"...
[mirror_edk2.git] / Tools / Source / FrameworkTasks / org / tianocore / framework / tasks / ModifyInfTask.java
CommitLineData
47f2f011 1/** @file\r
2 ModifyInfTask class.\r
3\r
4 ModifyInfTask is used to call Modify.exe to generate inf file.\r
ff225cbb 5\r
6\r
47f2f011 7 Copyright (c) 2006, Intel Corporation\r
8 All rights reserved. This program and the accompanying materials\r
9 are licensed and made available under the terms and conditions of the BSD License\r
10 which accompanies this distribution. The full text of the license may be found at\r
11 http://opensource.org/licenses/bsd-license.php\r
ff225cbb 12\r
47f2f011 13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
15\r
16 **/\r
17package org.tianocore.framework.tasks;\r
18\r
19import java.io.File;\r
20\r
21import org.apache.tools.ant.Task;\r
22import org.apache.tools.ant.Project;\r
23import org.apache.tools.ant.BuildException;\r
24import org.apache.tools.ant.taskdefs.Execute;\r
25import org.apache.tools.ant.taskdefs.LogStreamHandler;\r
26import org.apache.tools.ant.types.Commandline;\r
ff225cbb 27\r
28import org.tianocore.common.logger.EdkLog;\r
47f2f011 29\r
30/**\r
31 ModifyInfTask class.\r
32\r
33 ModifyInfTask is used to call Modify.exe to generate inf file.\r
34**/\r
35public class ModifyInfTask extends Task implements EfiDefine {\r
36 ///\r
37 /// tool name\r
38 ///\r
39 private String toolName = "ModifyInf";\r
ff225cbb 40\r
47f2f011 41 ///\r
42 /// input FV inf file\r
43 ///\r
23c2f30c 44 private String inputFVInfFile = "";\r
47f2f011 45\r
46 ///\r
47 /// output FV inf file\r
48 ///\r
23c2f30c 49 private String outputFVInfFile = "";\r
47f2f011 50\r
51 ///\r
52 /// pattern string\r
53 ///\r
54 private String patternStr = "";\r
55\r
56 ///\r
57 /// Output dir\r
ff225cbb 58 ///\r
47f2f011 59 private String outputDir = "";\r
ff225cbb 60\r
47f2f011 61 /**\r
62 * execute\r
ff225cbb 63 *\r
47f2f011 64 * ModifyInfTask execute function is to assemble tool command line & execute\r
65 * tool command line\r
ff225cbb 66 *\r
47f2f011 67 * @throws BuidException\r
68 */\r
69 public void execute() throws BuildException {\r
70\r
71 Project project = this.getOwningTarget().getProject();\r
72 //\r
73 // set Logger\r
74 //\r
3f7b510e 75 FrameworkLogger logger = new FrameworkLogger(project, "modifyinftask");\r
47f2f011 76 EdkLog.setLogLevel(project.getProperty("env.LOGLEVEL"));\r
77 EdkLog.setLogger(logger);\r
78 //\r
79 // absolute path of efi tools\r
80 //\r
81 String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");\r
82 String command;\r
83 String argument;\r
84 if (path == null) {\r
85 command = toolName;\r
86 } else {\r
87 command = path + File.separatorChar + toolName;\r
88 }\r
89 //\r
90 // argument of tools\r
91 //\r
23c2f30c 92 File file = new File(outputFVInfFile);\r
47f2f011 93 if (!file.isAbsolute() && (!this.outputDir.equalsIgnoreCase(""))) {\r
23c2f30c 94 argument = this.inputFVInfFile +\r
ff225cbb 95 this.outputDir +\r
47f2f011 96 File.separatorChar +\r
23c2f30c 97 this.outputFVInfFile +\r
47f2f011 98 this.patternStr;\r
99 } else {\r
23c2f30c 100 argument = this.inputFVInfFile +\r
101 this.outputFVInfFile +\r
47f2f011 102 this.patternStr;\r
103 }\r
104 //\r
105 // return value of fwimage execution\r
106 //\r
107 int revl = -1;\r
108\r
109 try {\r
110 Commandline cmdline = new Commandline();\r
111 cmdline.setExecutable(command);\r
112 cmdline.createArgument().setLine(argument);\r
113\r
114 LogStreamHandler streamHandler = new LogStreamHandler(this,\r
115 Project.MSG_INFO, Project.MSG_WARN);\r
116 Execute runner = new Execute(streamHandler, null);\r
117\r
118 runner.setAntRun(project);\r
119 runner.setCommandline(cmdline.getCommandline());\r
120 //\r
121 // Set debug log information.\r
122 //\r
219e2247 123 EdkLog.log(EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));\r
23c2f30c 124 EdkLog.log(EdkLog.EDK_INFO, (new File(this.inputFVInfFile)).getName());\r
47f2f011 125 revl = runner.execute();\r
126\r
127 if (EFI_SUCCESS == revl) {\r
128 //\r
129 // command execution success\r
130 //\r
219e2247 131 EdkLog.log(EdkLog.EDK_VERBOSE, "ModifyInfTask succeeded!");\r
47f2f011 132 } else {\r
133 //\r
134 // command execution fail\r
135 //\r
219e2247 136 EdkLog.log(EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));\r
137 throw new BuildException("ModifyInfTask failed!");\r
47f2f011 138 }\r
139 } catch (Exception e) {\r
140 throw new BuildException(e.getMessage());\r
141 }\r
142 }\r
143\r
144 /**\r
23c2f30c 145 * getinputFVInfFile\r
ff225cbb 146 *\r
23c2f30c 147 * This function is to get class member "inputFVInfFile".\r
ff225cbb 148 *\r
47f2f011 149 * @return string of input inf file name.\r
150 */\r
23c2f30c 151 public String getinputFVInfFile() {\r
152 return this.inputFVInfFile;\r
47f2f011 153 }\r
154\r
155 /**\r
23c2f30c 156 * setinputFVInfFile\r
ff225cbb 157 *\r
23c2f30c 158 * This function is to set class member "inputFVInfFile".\r
ff225cbb 159 *\r
47f2f011 160 * @param inputFile\r
161 * string of input inf file name.\r
162 */\r
23c2f30c 163 public void setinputFVInfFile(String inputFVInfFileName) {\r
164 this.inputFVInfFile= inputFVInfFileName + " ";\r
47f2f011 165 }\r
166\r
167 /**\r
23c2f30c 168 * getoutputFVInfFile\r
ff225cbb 169 *\r
23c2f30c 170 * This function is to get class member "outputFVInfFile"\r
ff225cbb 171 *\r
23c2f30c 172 * @return outputFVInfFile string of output inf file name.\r
47f2f011 173 */\r
23c2f30c 174 public String getoutputFVInfFile() {\r
175 return this.outputFVInfFile;\r
47f2f011 176 }\r
177\r
178 /**\r
23c2f30c 179 * setoutputFVInfFile\r
ff225cbb 180 *\r
23c2f30c 181 * This function is to set class member "outputFVInfFile"\r
ff225cbb 182 *\r
23c2f30c 183 * @param outputFVInfFile\r
47f2f011 184 * string of output inf file name.\r
185 */\r
23c2f30c 186 public void setoutputFVInfFile(String outputFVInfFileName) {\r
187 this.outputFVInfFile = outputFVInfFileName + " ";\r
47f2f011 188 }\r
189\r
190 /**\r
191 * getpatternStr\r
ff225cbb 192 *\r
47f2f011 193 * This function is to get class member "patternStr"\r
ff225cbb 194 *\r
47f2f011 195 * @return patternStr string of pattern.\r
196 */\r
197 public String getpatternStr() {\r
198 return this.patternStr;\r
199 }\r
200\r
201 /**\r
202 * setpatternStr\r
ff225cbb 203 *\r
47f2f011 204 * This function is to set class member "patternStr"\r
ff225cbb 205 *\r
47f2f011 206 * @param patternStr\r
207 * string of patternStr.\r
208 */\r
209 public void setpatternStr(String patternStr) {\r
01026c70 210 this.patternStr = patternStr;\r
47f2f011 211 }\r
212\r
213 /**\r
214 * getoutputDir\r
ff225cbb 215 *\r
47f2f011 216 * This function is to get class member "outputDir"\r
ff225cbb 217 *\r
47f2f011 218 * @return outputDir string of output directory.\r
219 */\r
220 public String getoutputDir() {\r
221 return this.outputDir;\r
222 }\r
223\r
224 /**\r
225 * setoutputDir\r
ff225cbb 226 *\r
47f2f011 227 * This function is to set class member "outputDir"\r
ff225cbb 228 *\r
47f2f011 229 * @param patternStr\r
230 * string of output directory.\r
231 */\r
232 public void setoutputDir(String outputDir) {\r
233 this.outputDir = outputDir;\r
234 }\r
235}\r