]>
Commit | Line | Data |
---|---|---|
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 | |
17 | package org.tianocore.framework.tasks;\r | |
18 | \r | |
19 | import java.io.File;\r | |
20 | \r | |
21 | import org.apache.tools.ant.Task;\r | |
22 | import org.apache.tools.ant.Project;\r | |
23 | import org.apache.tools.ant.BuildException;\r | |
24 | import org.apache.tools.ant.taskdefs.Execute;\r | |
25 | import org.apache.tools.ant.taskdefs.LogStreamHandler;\r | |
26 | import org.apache.tools.ant.types.Commandline;\r | |
ff225cbb | 27 | \r |
28 | import 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 | |
35 | public 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 | |
63 | // set Logger\r | |
64 | //\r | |
65 | FrameworkLogger logger = new FrameworkLogger(project, "genacpitable");\r | |
66 | EdkLog.setLogLevel(project.getProperty("env.LOGLEVEL"));\r | |
67 | EdkLog.setLogger(logger);\r | |
68 | //\r | |
69 | // absolute path of efi tools\r | |
70 | //\r | |
71 | String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");\r | |
72 | String command;\r | |
73 | String argument;\r | |
74 | if (path == null) {\r | |
75 | command = "GenAcpiTable";\r | |
76 | } else {\r | |
77 | command = path + File.separatorChar + "GenAcpiTable";\r | |
78 | }\r | |
79 | //\r | |
80 | // argument of tools\r | |
81 | //\r | |
82 | File file = new File(outputFile);\r | |
83 | if (!file.isAbsolute() && (!this.outputDir.equalsIgnoreCase(""))) {\r | |
84 | argument = inputFile + " " + outputDir + File.separatorChar\r | |
85 | + outputFile;\r | |
86 | } else {\r | |
87 | argument = inputFile + " " + outputFile;\r | |
88 | }\r | |
89 | //\r | |
90 | // return value of fwimage execution\r | |
91 | //\r | |
92 | int revl = -1;\r | |
93 | \r | |
94 | try {\r | |
95 | Commandline cmdline = new Commandline();\r | |
96 | cmdline.setExecutable(command);\r | |
97 | cmdline.createArgument().setLine(argument);\r | |
98 | \r | |
99 | LogStreamHandler streamHandler = new LogStreamHandler(this,\r | |
100 | Project.MSG_INFO, Project.MSG_WARN);\r | |
101 | Execute runner = new Execute(streamHandler, null);\r | |
102 | \r | |
103 | runner.setAntRun(project);\r | |
104 | runner.setCommandline(cmdline.getCommandline());\r | |
105 | //\r | |
106 | // Set debug log information.\r | |
107 | //\r | |
219e2247 | 108 | EdkLog.log(EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));\r |
109 | EdkLog.log(EdkLog.EDK_INFO, (new File(this.inputFile)).getName());\r | |
a15bb0d3 | 110 | revl = runner.execute();\r |
ff225cbb | 111 | \r |
a15bb0d3 | 112 | if (EFI_SUCCESS == revl) {\r |
113 | //\r | |
114 | // command execution success\r | |
115 | //\r | |
219e2247 | 116 | EdkLog.log(EdkLog.EDK_VERBOSE, "GenAcpiTable succeeded!");\r |
a15bb0d3 | 117 | } else {\r |
118 | //\r | |
119 | // command execution fail\r | |
120 | //\r | |
219e2247 | 121 | EdkLog.log(EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));\r |
122 | throw new BuildException("GenAcpiTable failed!");\r | |
a15bb0d3 | 123 | }\r |
124 | } catch (Exception e) {\r | |
125 | throw new BuildException(e.getMessage());\r | |
126 | }\r | |
127 | }\r | |
128 | \r | |
129 | /**\r | |
130 | * getInputFile\r | |
ff225cbb | 131 | *\r |
a15bb0d3 | 132 | * This function is to get class member "inputFile".\r |
ff225cbb | 133 | *\r |
a15bb0d3 | 134 | * @return string of input file name.\r |
135 | */\r | |
136 | public String getInputFile() {\r | |
137 | return inputFile;\r | |
138 | }\r | |
139 | \r | |
140 | /**\r | |
141 | * setComponentType\r | |
ff225cbb | 142 | *\r |
a15bb0d3 | 143 | * This function is to set class member "inputFile".\r |
ff225cbb | 144 | *\r |
a15bb0d3 | 145 | * @param inputFile\r |
146 | * string of input file name.\r | |
147 | */\r | |
148 | public void setInputFile(String inputFile) {\r | |
149 | this.inputFile = inputFile;\r | |
150 | }\r | |
151 | \r | |
152 | /**\r | |
153 | * getOutputFile\r | |
ff225cbb | 154 | *\r |
a15bb0d3 | 155 | * This function is to get class member "outputFile"\r |
ff225cbb | 156 | *\r |
a15bb0d3 | 157 | * @return outputFile string of output file name.\r |
158 | */\r | |
159 | public String getOutputFile() {\r | |
160 | return outputFile;\r | |
161 | }\r | |
162 | \r | |
163 | /**\r | |
164 | * setOutputFile\r | |
ff225cbb | 165 | *\r |
a15bb0d3 | 166 | * This function is to set class member "outputFile"\r |
ff225cbb | 167 | *\r |
a15bb0d3 | 168 | * @param outputFile\r |
169 | * string of output file name.\r | |
170 | */\r | |
171 | public void setOutputFile(String outputFile) {\r | |
172 | this.outputFile = outputFile;\r | |
173 | }\r | |
174 | \r | |
175 | /**\r | |
176 | * getOutputDir\r | |
ff225cbb | 177 | *\r |
a15bb0d3 | 178 | * This function is to get class member "outputDir"\r |
ff225cbb | 179 | *\r |
a15bb0d3 | 180 | * @return outputDir string of output directory.\r |
181 | */\r | |
182 | public String getOutputDir() {\r | |
183 | return outputDir;\r | |
184 | }\r | |
185 | \r | |
186 | /**\r | |
187 | * setOutputDir\r | |
ff225cbb | 188 | *\r |
a15bb0d3 | 189 | * This function is to set class member "outputDir"\r |
ff225cbb | 190 | *\r |
a15bb0d3 | 191 | * @param outputDir\r |
192 | * string of output directory.\r | |
193 | */\r | |
194 | public void setOutputDir(String outputDir) {\r | |
195 | this.outputDir = outputDir;\r | |
196 | }\r | |
197 | }\r |