]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | ModifyInfTask class.\r | |
3 | \r | |
4 | ModifyInfTask is used to call Modify.exe to generate inf file.\r | |
5 | \r | |
6 | \r | |
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 | |
12 | \r | |
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 | |
27 | \r | |
28 | import org.tianocore.common.logger.EdkLog;\r | |
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 | |
36 | ///\r | |
37 | /// tool name\r | |
38 | ///\r | |
39 | private String toolName = "ModifyInf";\r | |
40 | \r | |
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 | |
58 | ///\r | |
59 | private String outputDir = "";\r | |
60 | \r | |
61 | /**\r | |
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 | |
69 | public void execute() throws BuildException {\r | |
70 | \r | |
71 | Project project = this.getOwningTarget().getProject();\r | |
72 | //\r | |
73 | // set Logger\r | |
74 | //\r | |
75 | FrameworkLogger logger = new FrameworkLogger(project, "modifyinftask");\r | |
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 | |
95 | this.outputDir +\r | |
96 | File.separatorChar +\r | |
97 | this.outputFVInfFileName +\r | |
98 | this.patternStr;\r | |
99 | } else {\r | |
100 | argument = this.inputFVInfFileName +\r | |
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 | |
123 | EdkLog.log(EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));\r | |
124 | EdkLog.log(EdkLog.EDK_INFO, (new File(this.inputFVInfFileName)).getName());\r | |
125 | revl = runner.execute();\r | |
126 | \r | |
127 | if (EFI_SUCCESS == revl) {\r | |
128 | //\r | |
129 | // command execution success\r | |
130 | //\r | |
131 | EdkLog.log(EdkLog.EDK_VERBOSE, "ModifyInfTask succeeded!");\r | |
132 | } else {\r | |
133 | //\r | |
134 | // command execution fail\r | |
135 | //\r | |
136 | EdkLog.log(EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));\r | |
137 | throw new BuildException("ModifyInfTask failed!");\r | |
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 | |
146 | *\r | |
147 | * This function is to get class member "inputFVInfFileName".\r | |
148 | *\r | |
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 | |
157 | *\r | |
158 | * This function is to set class member "inputFVInfFileName".\r | |
159 | *\r | |
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 | |
169 | *\r | |
170 | * This function is to get class member "outputFVInfFileName"\r | |
171 | *\r | |
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 | |
180 | *\r | |
181 | * This function is to set class member "outputFVInfFileName"\r | |
182 | *\r | |
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 | |
192 | *\r | |
193 | * This function is to get class member "patternStr"\r | |
194 | *\r | |
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 | |
203 | *\r | |
204 | * This function is to set class member "patternStr"\r | |
205 | *\r | |
206 | * @param patternStr\r | |
207 | * string of patternStr.\r | |
208 | */\r | |
209 | public void setpatternStr(String patternStr) {\r | |
210 | this.patternStr = patternStr;\r | |
211 | }\r | |
212 | \r | |
213 | /**\r | |
214 | * getoutputDir\r | |
215 | *\r | |
216 | * This function is to get class member "outputDir"\r | |
217 | *\r | |
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 | |
226 | *\r | |
227 | * This function is to set class member "outputDir"\r | |
228 | *\r | |
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 |