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