]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenAcpiTableTask.java
Fixed EDKT102;
[mirror_edk2.git] / Tools / Source / FrameworkTasks / org / tianocore / framework / tasks / GenAcpiTableTask.java
CommitLineData
a15bb0d3 1/** @file\r
2 GenAcpiTable class.\r
3\r
4 GenAcpiTable is used to call GenAcpiTable.exe to generate ACPI Table image .\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
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
27import org.tianocore.logger.EdkLog;\r
28\r
29/**\r
30 GenAcpiTable class.\r
31\r
32 GenAcpiTable is used to call GenAcpiTable.exe to generate ACPI Table image .\r
33**/\r
34public class GenAcpiTableTask extends Task implements EfiDefine {\r
35 // /\r
36 // / input file\r
37 // /\r
38 private String inputFile = "";\r
39\r
40 // /\r
41 // / output file\r
42 // /\r
43 private String outputFile = "";\r
44\r
45 // /\r
46 // / output directory, this variable is added by jave wrap\r
47 // /\r
48 private String outputDir = "";\r
49\r
50 /**\r
51 * execute\r
52 * \r
53 * StripTask execute function is to assemble tool command line & execute\r
54 * tool command line\r
55 * \r
56 * @throws BuidException\r
57 */\r
58 public void execute() throws BuildException {\r
59\r
60 Project project = this.getOwningTarget().getProject();\r
61 //\r
62 // set Logger\r
63 //\r
64 FrameworkLogger logger = new FrameworkLogger(project, "genacpitable");\r
65 EdkLog.setLogLevel(project.getProperty("env.LOGLEVEL"));\r
66 EdkLog.setLogger(logger);\r
67 //\r
68 // absolute path of efi tools\r
69 //\r
70 String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");\r
71 String command;\r
72 String argument;\r
73 if (path == null) {\r
74 command = "GenAcpiTable";\r
75 } else {\r
76 command = path + File.separatorChar + "GenAcpiTable";\r
77 }\r
78 //\r
79 // argument of tools\r
80 //\r
81 File file = new File(outputFile);\r
82 if (!file.isAbsolute() && (!this.outputDir.equalsIgnoreCase(""))) {\r
83 argument = inputFile + " " + outputDir + File.separatorChar\r
84 + outputFile;\r
85 } else {\r
86 argument = inputFile + " " + outputFile;\r
87 }\r
88 //\r
89 // return value of fwimage execution\r
90 //\r
91 int revl = -1;\r
92\r
93 try {\r
94 Commandline cmdline = new Commandline();\r
95 cmdline.setExecutable(command);\r
96 cmdline.createArgument().setLine(argument);\r
97\r
98 LogStreamHandler streamHandler = new LogStreamHandler(this,\r
99 Project.MSG_INFO, Project.MSG_WARN);\r
100 Execute runner = new Execute(streamHandler, null);\r
101\r
102 runner.setAntRun(project);\r
103 runner.setCommandline(cmdline.getCommandline());\r
104 //\r
105 // Set debug log information.\r
106 //\r
107 EdkLog.log(EdkLog.EDK_INFO, Commandline.toString(cmdline.getCommandline()));\r
108 \r
109 revl = runner.execute();\r
110 \r
111 if (EFI_SUCCESS == revl) {\r
112 //\r
113 // command execution success\r
114 //\r
115 EdkLog.log(EdkLog.EDK_INFO,"GenAcpiTable successed!");\r
116 } else {\r
117 //\r
118 // command execution fail\r
119 //\r
120 EdkLog.log(EdkLog.EDK_ERROR, "GenAcpiTable failed. (error="\r
121 + Integer.toHexString(revl) + ")");\r
122 throw new BuildException("GenAcpiTable failed. (error="\r
123 + Integer.toHexString(revl) + ")");\r
124\r
125 }\r
126 } catch (Exception e) {\r
127 throw new BuildException(e.getMessage());\r
128 }\r
129 }\r
130\r
131 /**\r
132 * getInputFile\r
133 * \r
134 * This function is to get class member "inputFile".\r
135 * \r
136 * @return string of input file name.\r
137 */\r
138 public String getInputFile() {\r
139 return inputFile;\r
140 }\r
141\r
142 /**\r
143 * setComponentType\r
144 * \r
145 * This function is to set class member "inputFile".\r
146 * \r
147 * @param inputFile\r
148 * string of input file name.\r
149 */\r
150 public void setInputFile(String inputFile) {\r
151 this.inputFile = inputFile;\r
152 }\r
153\r
154 /**\r
155 * getOutputFile\r
156 * \r
157 * This function is to get class member "outputFile"\r
158 * \r
159 * @return outputFile string of output file name.\r
160 */\r
161 public String getOutputFile() {\r
162 return outputFile;\r
163 }\r
164\r
165 /**\r
166 * setOutputFile\r
167 * \r
168 * This function is to set class member "outputFile"\r
169 * \r
170 * @param outputFile\r
171 * string of output file name.\r
172 */\r
173 public void setOutputFile(String outputFile) {\r
174 this.outputFile = outputFile;\r
175 }\r
176\r
177 /**\r
178 * getOutputDir\r
179 * \r
180 * This function is to get class member "outputDir"\r
181 * \r
182 * @return outputDir string of output directory.\r
183 */\r
184 public String getOutputDir() {\r
185 return outputDir;\r
186 }\r
187\r
188 /**\r
189 * setOutputDir\r
190 * \r
191 * This function is to set class member "outputDir"\r
192 * \r
193 * @param outputDir\r
194 * string of output directory.\r
195 */\r
196 public void setOutputDir(String outputDir) {\r
197 this.outputDir = outputDir;\r
198 }\r
199}\r