]>
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 | |
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 | |
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 | |
23c2f30c | 86 | File file = new File(outputFVInfFile);\r |
47f2f011 | 87 | if (!file.isAbsolute() && (!this.outputDir.equalsIgnoreCase(""))) {\r |
23c2f30c | 88 | argument = this.inputFVInfFile +\r |
ff225cbb | 89 | this.outputDir +\r |
47f2f011 | 90 | File.separatorChar +\r |
23c2f30c | 91 | this.outputFVInfFile +\r |
47f2f011 | 92 | this.patternStr;\r |
93 | } else {\r | |
23c2f30c | 94 | argument = this.inputFVInfFile +\r |
95 | this.outputFVInfFile +\r | |
47f2f011 | 96 | this.patternStr;\r |
97 | }\r | |
98 | //\r | |
99 | // return value of fwimage execution\r | |
100 | //\r | |
101 | int revl = -1;\r | |
102 | \r | |
103 | try {\r | |
104 | Commandline cmdline = new Commandline();\r | |
105 | cmdline.setExecutable(command);\r | |
106 | cmdline.createArgument().setLine(argument);\r | |
107 | \r | |
108 | LogStreamHandler streamHandler = new LogStreamHandler(this,\r | |
109 | Project.MSG_INFO, Project.MSG_WARN);\r | |
110 | Execute runner = new Execute(streamHandler, null);\r | |
111 | \r | |
112 | runner.setAntRun(project);\r | |
113 | runner.setCommandline(cmdline.getCommandline());\r | |
114 | //\r | |
115 | // Set debug log information.\r | |
116 | //\r | |
91f7d582 | 117 | EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));\r |
118 | EdkLog.log(this, EdkLog.EDK_INFO, (new File(this.inputFVInfFile)).getName());\r | |
47f2f011 | 119 | revl = runner.execute();\r |
120 | \r | |
121 | if (EFI_SUCCESS == revl) {\r | |
122 | //\r | |
123 | // command execution success\r | |
124 | //\r | |
91f7d582 | 125 | EdkLog.log(this, EdkLog.EDK_VERBOSE, "ModifyInfTask succeeded!");\r |
47f2f011 | 126 | } else {\r |
127 | //\r | |
128 | // command execution fail\r | |
129 | //\r | |
91f7d582 | 130 | EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));\r |
219e2247 | 131 | throw new BuildException("ModifyInfTask failed!");\r |
47f2f011 | 132 | }\r |
133 | } catch (Exception e) {\r | |
134 | throw new BuildException(e.getMessage());\r | |
135 | }\r | |
136 | }\r | |
137 | \r | |
138 | /**\r | |
23c2f30c | 139 | * getinputFVInfFile\r |
ff225cbb | 140 | *\r |
23c2f30c | 141 | * This function is to get class member "inputFVInfFile".\r |
ff225cbb | 142 | *\r |
47f2f011 | 143 | * @return string of input inf file name.\r |
144 | */\r | |
23c2f30c | 145 | public String getinputFVInfFile() {\r |
146 | return this.inputFVInfFile;\r | |
47f2f011 | 147 | }\r |
148 | \r | |
149 | /**\r | |
23c2f30c | 150 | * setinputFVInfFile\r |
ff225cbb | 151 | *\r |
23c2f30c | 152 | * This function is to set class member "inputFVInfFile".\r |
ff225cbb | 153 | *\r |
47f2f011 | 154 | * @param inputFile\r |
155 | * string of input inf file name.\r | |
156 | */\r | |
23c2f30c | 157 | public void setinputFVInfFile(String inputFVInfFileName) {\r |
158 | this.inputFVInfFile= inputFVInfFileName + " ";\r | |
47f2f011 | 159 | }\r |
160 | \r | |
161 | /**\r | |
23c2f30c | 162 | * getoutputFVInfFile\r |
ff225cbb | 163 | *\r |
23c2f30c | 164 | * This function is to get class member "outputFVInfFile"\r |
ff225cbb | 165 | *\r |
23c2f30c | 166 | * @return outputFVInfFile string of output inf file name.\r |
47f2f011 | 167 | */\r |
23c2f30c | 168 | public String getoutputFVInfFile() {\r |
169 | return this.outputFVInfFile;\r | |
47f2f011 | 170 | }\r |
171 | \r | |
172 | /**\r | |
23c2f30c | 173 | * setoutputFVInfFile\r |
ff225cbb | 174 | *\r |
23c2f30c | 175 | * This function is to set class member "outputFVInfFile"\r |
ff225cbb | 176 | *\r |
23c2f30c | 177 | * @param outputFVInfFile\r |
47f2f011 | 178 | * string of output inf file name.\r |
179 | */\r | |
23c2f30c | 180 | public void setoutputFVInfFile(String outputFVInfFileName) {\r |
181 | this.outputFVInfFile = outputFVInfFileName + " ";\r | |
47f2f011 | 182 | }\r |
183 | \r | |
184 | /**\r | |
185 | * getpatternStr\r | |
ff225cbb | 186 | *\r |
47f2f011 | 187 | * This function is to get class member "patternStr"\r |
ff225cbb | 188 | *\r |
47f2f011 | 189 | * @return patternStr string of pattern.\r |
190 | */\r | |
191 | public String getpatternStr() {\r | |
192 | return this.patternStr;\r | |
193 | }\r | |
194 | \r | |
195 | /**\r | |
196 | * setpatternStr\r | |
ff225cbb | 197 | *\r |
47f2f011 | 198 | * This function is to set class member "patternStr"\r |
ff225cbb | 199 | *\r |
47f2f011 | 200 | * @param patternStr\r |
201 | * string of patternStr.\r | |
202 | */\r | |
203 | public void setpatternStr(String patternStr) {\r | |
01026c70 | 204 | this.patternStr = patternStr;\r |
47f2f011 | 205 | }\r |
206 | \r | |
207 | /**\r | |
208 | * getoutputDir\r | |
ff225cbb | 209 | *\r |
47f2f011 | 210 | * This function is to get class member "outputDir"\r |
ff225cbb | 211 | *\r |
47f2f011 | 212 | * @return outputDir string of output directory.\r |
213 | */\r | |
214 | public String getoutputDir() {\r | |
215 | return this.outputDir;\r | |
216 | }\r | |
217 | \r | |
218 | /**\r | |
219 | * setoutputDir\r | |
ff225cbb | 220 | *\r |
47f2f011 | 221 | * This function is to set class member "outputDir"\r |
ff225cbb | 222 | *\r |
47f2f011 | 223 | * @param patternStr\r |
224 | * string of output directory.\r | |
225 | */\r | |
226 | public void setoutputDir(String outputDir) {\r | |
227 | this.outputDir = outputDir;\r | |
228 | }\r | |
229 | }\r |