]>
Commit | Line | Data |
---|---|---|
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 | |
17 | package org.tianocore.framework.tasks;\r | |
18 | \r | |
19 | import java.io.File;\r | |
20 | \r | |
21 | import org.apache.tools.ant.Task;\r | |
22 | import org.apache.tools.ant.Project;\r | |
23 | import org.apache.tools.ant.BuildException;\r | |
24 | import org.apache.tools.ant.taskdefs.Execute;\r | |
25 | import org.apache.tools.ant.taskdefs.LogStreamHandler;\r | |
26 | import org.apache.tools.ant.types.Commandline;\r | |
ff225cbb | 27 | \r |
28 | import 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 | |
35 | public class ModifyInfTask extends Task implements EfiDefine {\r | |
0fdb42ac | 36 | //\r |
37 | // tool name\r | |
38 | //\r | |
47f2f011 | 39 | private String toolName = "ModifyInf";\r |
ff225cbb | 40 | \r |
0fdb42ac | 41 | //\r |
42 | // input FV inf file\r | |
43 | //\r | |
44 | private FileArg inputFVInfFile = new FileArg();\r | |
47f2f011 | 45 | \r |
0fdb42ac | 46 | //\r |
47 | // output FV inf file\r | |
48 | //\r | |
49 | private FileArg outputFVInfFile = new FileArg();\r | |
47f2f011 | 50 | \r |
0fdb42ac | 51 | //\r |
52 | // pattern string\r | |
53 | //\r | |
54 | private ToolArg patternStr = new ToolArg();\r | |
47f2f011 | 55 | \r |
0fdb42ac | 56 | //\r |
57 | // Output dir\r | |
58 | //\r | |
59 | private String outputDir = ".";\r | |
ff225cbb | 60 | \r |
47f2f011 | 61 | /**\r |
0fdb42ac | 62 | execute\r |
63 | \r | |
64 | ModifyInfTask execute function is to assemble tool command line & execute\r | |
65 | tool command line\r | |
66 | \r | |
67 | @throws BuidException\r | |
68 | **/\r | |
47f2f011 | 69 | public void execute() throws BuildException {\r |
70 | \r | |
71 | Project project = this.getOwningTarget().getProject();\r | |
72 | //\r | |
47f2f011 | 73 | // absolute path of efi tools\r |
74 | //\r | |
75 | String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");\r | |
76 | String command;\r | |
77 | String argument;\r | |
78 | if (path == null) {\r | |
79 | command = toolName;\r | |
80 | } else {\r | |
81 | command = path + File.separatorChar + toolName;\r | |
82 | }\r | |
83 | //\r | |
84 | // argument of tools\r | |
85 | //\r | |
0fdb42ac | 86 | argument = "" + this.inputFVInfFile + this.outputFVInfFile + this.patternStr;\r |
47f2f011 | 87 | //\r |
88 | // return value of fwimage execution\r | |
89 | //\r | |
90 | int revl = -1;\r | |
91 | \r | |
92 | try {\r | |
93 | Commandline cmdline = new Commandline();\r | |
94 | cmdline.setExecutable(command);\r | |
95 | cmdline.createArgument().setLine(argument);\r | |
96 | \r | |
97 | LogStreamHandler streamHandler = new LogStreamHandler(this,\r | |
98 | Project.MSG_INFO, Project.MSG_WARN);\r | |
99 | Execute runner = new Execute(streamHandler, null);\r | |
100 | \r | |
101 | runner.setAntRun(project);\r | |
102 | runner.setCommandline(cmdline.getCommandline());\r | |
0fdb42ac | 103 | runner.setWorkingDirectory(new File(outputDir));\r |
104 | \r | |
47f2f011 | 105 | //\r |
106 | // Set debug log information.\r | |
107 | //\r | |
91f7d582 | 108 | EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));\r |
0fdb42ac | 109 | EdkLog.log(this, EdkLog.EDK_INFO, this.inputFVInfFile.toFileList()\r |
110 | + " => " + this.inputFVInfFile.toFileList());\r | |
47f2f011 | 111 | \r |
0fdb42ac | 112 | revl = runner.execute();\r |
47f2f011 | 113 | if (EFI_SUCCESS == revl) {\r |
114 | //\r | |
115 | // command execution success\r | |
116 | //\r | |
0fdb42ac | 117 | EdkLog.log(this, EdkLog.EDK_VERBOSE, toolName + " succeeded!");\r |
47f2f011 | 118 | } else {\r |
119 | //\r | |
120 | // command execution fail\r | |
121 | //\r | |
91f7d582 | 122 | EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));\r |
0fdb42ac | 123 | throw new BuildException(toolName + " failed!");\r |
47f2f011 | 124 | }\r |
125 | } catch (Exception e) {\r | |
126 | throw new BuildException(e.getMessage());\r | |
127 | }\r | |
128 | }\r | |
129 | \r | |
130 | /**\r | |
0fdb42ac | 131 | getinputFVInfFile\r |
132 | \r | |
133 | This function is to get class member "inputFVInfFile".\r | |
134 | \r | |
135 | @return string of input inf file name.\r | |
136 | **/\r | |
23c2f30c | 137 | public String getinputFVInfFile() {\r |
0fdb42ac | 138 | return this.inputFVInfFile.getValue();\r |
47f2f011 | 139 | }\r |
140 | \r | |
141 | /**\r | |
0fdb42ac | 142 | setinputFVInfFile\r |
143 | \r | |
144 | This function is to set class member "inputFVInfFile".\r | |
145 | \r | |
146 | @param inputFile\r | |
147 | string of input inf file name.\r | |
148 | **/\r | |
23c2f30c | 149 | public void setinputFVInfFile(String inputFVInfFileName) {\r |
0fdb42ac | 150 | this.inputFVInfFile.setArg(" ", inputFVInfFileName);\r |
47f2f011 | 151 | }\r |
152 | \r | |
153 | /**\r | |
0fdb42ac | 154 | getoutputFVInfFile\r |
155 | \r | |
156 | This function is to get class member "outputFVInfFile"\r | |
157 | \r | |
158 | @return outputFVInfFile string of output inf file name.\r | |
159 | **/\r | |
23c2f30c | 160 | public String getoutputFVInfFile() {\r |
0fdb42ac | 161 | return this.outputFVInfFile.getValue();\r |
47f2f011 | 162 | }\r |
163 | \r | |
164 | /**\r | |
0fdb42ac | 165 | setoutputFVInfFile\r |
166 | \r | |
167 | This function is to set class member "outputFVInfFile"\r | |
168 | \r | |
169 | @param outputFVInfFile\r | |
170 | string of output inf file name.\r | |
171 | **/\r | |
23c2f30c | 172 | public void setoutputFVInfFile(String outputFVInfFileName) {\r |
0fdb42ac | 173 | this.outputFVInfFile.setArg(" ", outputFVInfFileName);\r |
47f2f011 | 174 | }\r |
175 | \r | |
176 | /**\r | |
0fdb42ac | 177 | getpatternStr\r |
178 | \r | |
179 | This function is to get class member "patternStr"\r | |
180 | \r | |
181 | @return patternStr string of pattern.\r | |
182 | **/\r | |
47f2f011 | 183 | public String getpatternStr() {\r |
0fdb42ac | 184 | return this.patternStr.getValue();\r |
47f2f011 | 185 | }\r |
186 | \r | |
187 | /**\r | |
0fdb42ac | 188 | setpatternStr\r |
189 | \r | |
190 | This function is to set class member "patternStr"\r | |
191 | \r | |
192 | @param patternStr\r | |
193 | string of patternStr.\r | |
194 | **/\r | |
47f2f011 | 195 | public void setpatternStr(String patternStr) {\r |
0fdb42ac | 196 | this.patternStr.setArg(" ", patternStr);\r |
47f2f011 | 197 | }\r |
198 | \r | |
199 | /**\r | |
0fdb42ac | 200 | getoutputDir\r |
201 | \r | |
202 | This function is to get class member "outputDir"\r | |
203 | \r | |
204 | @return outputDir string of output directory.\r | |
205 | **/\r | |
47f2f011 | 206 | public String getoutputDir() {\r |
207 | return this.outputDir;\r | |
208 | }\r | |
209 | \r | |
210 | /**\r | |
0fdb42ac | 211 | setoutputDir\r |
212 | \r | |
213 | This function is to set class member "outputDir"\r | |
214 | \r | |
215 | @param patternStr\r | |
216 | string of output directory.\r | |
217 | **/\r | |
47f2f011 | 218 | public void setoutputDir(String outputDir) {\r |
219 | this.outputDir = outputDir;\r | |
220 | }\r | |
221 | }\r |