]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenAcpiTableTask.java
Remove FrameworkLogger in FrameworkTasks and EdkException in GenBuild. Update EdkLog...
[mirror_edk2.git] / Tools / Source / FrameworkTasks / org / tianocore / framework / tasks / GenAcpiTableTask.java
1 /** @file
2 GenAcpiTable class.
3
4 GenAcpiTable is used to call GenAcpiTable.exe to generate ACPI Table image .
5
6
7 Copyright (c) 2006, Intel Corporation
8 All rights reserved. This program and the accompanying materials
9 are licensed and made available under the terms and conditions of the BSD License
10 which accompanies this distribution. The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php
12
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15
16 **/
17 package org.tianocore.framework.tasks;
18
19 import java.io.File;
20
21 import org.apache.tools.ant.Task;
22 import org.apache.tools.ant.Project;
23 import org.apache.tools.ant.BuildException;
24 import org.apache.tools.ant.taskdefs.Execute;
25 import org.apache.tools.ant.taskdefs.LogStreamHandler;
26 import org.apache.tools.ant.types.Commandline;
27
28 import org.tianocore.common.logger.EdkLog;
29
30 /**
31 GenAcpiTable class.
32
33 GenAcpiTable is used to call GenAcpiTable.exe to generate ACPI Table image .
34 **/
35 public class GenAcpiTableTask extends Task implements EfiDefine {
36 // /
37 // / input file
38 // /
39 private String inputFile = "";
40
41 // /
42 // / output file
43 // /
44 private String outputFile = "";
45
46 // /
47 // / output directory, this variable is added by jave wrap
48 // /
49 private String outputDir = "";
50
51 /**
52 * execute
53 *
54 * StripTask execute function is to assemble tool command line & execute
55 * tool command line
56 *
57 * @throws BuidException
58 */
59 public void execute() throws BuildException {
60
61 Project project = this.getOwningTarget().getProject();
62 //
63 // absolute path of efi tools
64 //
65 String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");
66 String command;
67 String argument;
68 if (path == null) {
69 command = "GenAcpiTable";
70 } else {
71 command = path + File.separatorChar + "GenAcpiTable";
72 }
73 //
74 // argument of tools
75 //
76 File file = new File(outputFile);
77 if (!file.isAbsolute() && (!this.outputDir.equalsIgnoreCase(""))) {
78 argument = inputFile + " " + outputDir + File.separatorChar
79 + outputFile;
80 } else {
81 argument = inputFile + " " + outputFile;
82 }
83 //
84 // return value of fwimage execution
85 //
86 int revl = -1;
87
88 try {
89 Commandline cmdline = new Commandline();
90 cmdline.setExecutable(command);
91 cmdline.createArgument().setLine(argument);
92
93 LogStreamHandler streamHandler = new LogStreamHandler(this,
94 Project.MSG_INFO, Project.MSG_WARN);
95 Execute runner = new Execute(streamHandler, null);
96
97 runner.setAntRun(project);
98 runner.setCommandline(cmdline.getCommandline());
99 //
100 // Set debug log information.
101 //
102 EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));
103 EdkLog.log(this, EdkLog.EDK_INFO, (new File(this.inputFile)).getName());
104 revl = runner.execute();
105
106 if (EFI_SUCCESS == revl) {
107 //
108 // command execution success
109 //
110 EdkLog.log(this, EdkLog.EDK_VERBOSE, "GenAcpiTable succeeded!");
111 } else {
112 //
113 // command execution fail
114 //
115 EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));
116 throw new BuildException("GenAcpiTable failed!");
117 }
118 } catch (Exception e) {
119 throw new BuildException(e.getMessage());
120 }
121 }
122
123 /**
124 * getInputFile
125 *
126 * This function is to get class member "inputFile".
127 *
128 * @return string of input file name.
129 */
130 public String getInputFile() {
131 return inputFile;
132 }
133
134 /**
135 * setComponentType
136 *
137 * This function is to set class member "inputFile".
138 *
139 * @param inputFile
140 * string of input file name.
141 */
142 public void setInputFile(String inputFile) {
143 this.inputFile = inputFile;
144 }
145
146 /**
147 * getOutputFile
148 *
149 * This function is to get class member "outputFile"
150 *
151 * @return outputFile string of output file name.
152 */
153 public String getOutputFile() {
154 return outputFile;
155 }
156
157 /**
158 * setOutputFile
159 *
160 * This function is to set class member "outputFile"
161 *
162 * @param outputFile
163 * string of output file name.
164 */
165 public void setOutputFile(String outputFile) {
166 this.outputFile = outputFile;
167 }
168
169 /**
170 * getOutputDir
171 *
172 * This function is to get class member "outputDir"
173 *
174 * @return outputDir string of output directory.
175 */
176 public String getOutputDir() {
177 return outputDir;
178 }
179
180 /**
181 * setOutputDir
182 *
183 * This function is to set class member "outputDir"
184 *
185 * @param outputDir
186 * string of output directory.
187 */
188 public void setOutputDir(String outputDir) {
189 this.outputDir = outputDir;
190 }
191 }