]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Java/Source/FrameworkTasks/org/tianocore/framework/tasks/GenAcpiTableTask.java
- Fixed EDKT240. Now the Blank.pad file for alignment purpose will no longer be needed.
[mirror_edk2.git] / Tools / Java / 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
0fdb42ac 36 //\r
37 // Tool name\r
38 // \r
39 private static String toolName = "GenAcpiTable";\r
40\r
41 //\r
42 // input file\r
43 //\r
44 private FileArg inputFile = new FileArg();\r
45\r
46 //\r
47 // output file\r
48 //\r
49 private FileArg outputFile = new FileArg();\r
50\r
51 //\r
52 // output directory, this variable is added by jave wrap\r
53 //\r
54 private String outputDir = ".";\r
a15bb0d3 55\r
56 /**\r
0fdb42ac 57 execute\r
58 \r
59 StripTask execute function is to assemble tool command line & execute\r
60 tool command line\r
61 \r
62 @throws BuidException\r
63 **/\r
a15bb0d3 64 public void execute() throws BuildException {\r
65\r
66 Project project = this.getOwningTarget().getProject();\r
67 //\r
a15bb0d3 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
0fdb42ac 74 command = toolName;\r
a15bb0d3 75 } else {\r
0fdb42ac 76 command = path + File.separator + toolName;\r
a15bb0d3 77 }\r
78 //\r
79 // argument of tools\r
80 //\r
0fdb42ac 81 argument = "" + inputFile + outputFile;\r
82\r
a15bb0d3 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
0fdb42ac 99 runner.setWorkingDirectory(new File(outputDir));\r
100\r
a15bb0d3 101 //\r
102 // Set debug log information.\r
103 //\r
91f7d582 104 EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));\r
0fdb42ac 105 EdkLog.log(this, EdkLog.EDK_INFO, this.inputFile.toFileList() + " => " \r
106 + this.outputFile.toFileList());\r
ff225cbb 107\r
0fdb42ac 108 revl = runner.execute();\r
a15bb0d3 109 if (EFI_SUCCESS == revl) {\r
110 //\r
111 // command execution success\r
112 //\r
0fdb42ac 113 EdkLog.log(this, EdkLog.EDK_VERBOSE, toolName + " succeeded!");\r
a15bb0d3 114 } else {\r
115 //\r
116 // command execution fail\r
117 //\r
91f7d582 118 EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));\r
0fdb42ac 119 throw new BuildException(toolName + " failed!");\r
a15bb0d3 120 }\r
121 } catch (Exception e) {\r
122 throw new BuildException(e.getMessage());\r
123 }\r
124 }\r
125\r
126 /**\r
0fdb42ac 127 getInputFile\r
128 \r
129 This function is to get class member "inputFile".\r
130 \r
131 @return string of input file name.\r
132 **/\r
a15bb0d3 133 public String getInputFile() {\r
0fdb42ac 134 return inputFile.getValue();\r
a15bb0d3 135 }\r
136\r
137 /**\r
0fdb42ac 138 setComponentType\r
139 \r
140 This function is to set class member "inputFile".\r
141 \r
142 @param inputFile\r
143 string of input file name.\r
144 **/\r
a15bb0d3 145 public void setInputFile(String inputFile) {\r
0fdb42ac 146 this.inputFile.setArg(" ", inputFile);\r
a15bb0d3 147 }\r
148\r
149 /**\r
0fdb42ac 150 getOutputFile\r
151 \r
152 This function is to get class member "outputFile"\r
153 \r
154 @return outputFile string of output file name.\r
155 **/\r
a15bb0d3 156 public String getOutputFile() {\r
0fdb42ac 157 return outputFile.getValue();\r
a15bb0d3 158 }\r
159\r
160 /**\r
0fdb42ac 161 setOutputFile\r
162 \r
163 This function is to set class member "outputFile"\r
164 \r
165 @param outputFile\r
166 string of output file name.\r
167 **/\r
a15bb0d3 168 public void setOutputFile(String outputFile) {\r
0fdb42ac 169 this.outputFile.setArg(" ", outputFile);\r
a15bb0d3 170 }\r
171\r
172 /**\r
0fdb42ac 173 getOutputDir\r
174 \r
175 This function is to get class member "outputDir"\r
176 \r
177 @return outputDir string of output directory.\r
178 **/\r
a15bb0d3 179 public String getOutputDir() {\r
180 return outputDir;\r
181 }\r
182\r
183 /**\r
0fdb42ac 184 setOutputDir\r
185 \r
186 This function is to set class member "outputDir"\r
187 \r
188 @param outputDir\r
189 string of output directory.\r
190 **/\r
a15bb0d3 191 public void setOutputDir(String outputDir) {\r
192 this.outputDir = outputDir;\r
193 }\r
194}\r