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