]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/ModifyInfTask.java
Modify GenFfsTask to make it don't create ORG file.
[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
44 private String inputFVInfFileName = "";\r
45\r
46 ///\r
47 /// output FV inf file\r
48 ///\r
49 private String outputFVInfFileName = "";\r
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
92 File file = new File(outputFVInfFileName);\r
93 if (!file.isAbsolute() && (!this.outputDir.equalsIgnoreCase(""))) {\r
94 argument = this.inputFVInfFileName +\r
ff225cbb 95 this.outputDir +\r
47f2f011 96 File.separatorChar +\r
97 this.outputFVInfFileName +\r
98 this.patternStr;\r
99 } else {\r
ff225cbb 100 argument = this.inputFVInfFileName +\r
47f2f011 101 this.outputFVInfFileName +\r
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
124 EdkLog.log(EdkLog.EDK_INFO, (new File(this.inputFVInfFileName)).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
145 * getinputFVInfFileName\r
ff225cbb 146 *\r
47f2f011 147 * This function is to get class member "inputFVInfFileName".\r
ff225cbb 148 *\r
47f2f011 149 * @return string of input inf file name.\r
150 */\r
151 public String getinputFVInfFileName() {\r
152 return this.inputFVInfFileName;\r
153 }\r
154\r
155 /**\r
156 * setinputFVInfFileName\r
ff225cbb 157 *\r
47f2f011 158 * This function is to set class member "inputFVInfFileName".\r
ff225cbb 159 *\r
47f2f011 160 * @param inputFile\r
161 * string of input inf file name.\r
162 */\r
163 public void setinputFVInfFileName(String inputFVInfFileName) {\r
164 this.inputFVInfFileName = inputFVInfFileName + " ";\r
165 }\r
166\r
167 /**\r
168 * getoutputFVInfFileName\r
ff225cbb 169 *\r
47f2f011 170 * This function is to get class member "outputFVInfFileName"\r
ff225cbb 171 *\r
47f2f011 172 * @return outputFVInfFileName string of output inf file name.\r
173 */\r
174 public String getoutputFVInfFileName() {\r
175 return this.outputFVInfFileName;\r
176 }\r
177\r
178 /**\r
179 * setoutputFVInfFileName\r
ff225cbb 180 *\r
47f2f011 181 * This function is to set class member "outputFVInfFileName"\r
ff225cbb 182 *\r
47f2f011 183 * @param outputFVInfFileName\r
184 * string of output inf file name.\r
185 */\r
186 public void setoutputFVInfFileName(String outputFVInfFileName) {\r
187 this.outputFVInfFileName = outputFVInfFileName + " ";\r
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