]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/StripTask.java
Remove FrameworkLogger in FrameworkTasks and EdkException in GenBuild. Update EdkLog...
[mirror_edk2.git] / Tools / Source / FrameworkTasks / org / tianocore / framework / tasks / StripTask.java
CommitLineData
a15bb0d3 1/** @file\r
2 StripTask class.\r
3\r
4 StripTask is used to call Strip.exe to strip input file.\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 StripTask class.\r
32\r
33 StripTask is used to call Strip.exe to strip input file.\r
34 */\r
35public class StripTask 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
ff225cbb 51\r
a15bb0d3 52 /**\r
53 * execute\r
ff225cbb 54 *\r
a15bb0d3 55 * StripTask execute function is to assemble tool command line & execute\r
56 * tool command line\r
ff225cbb 57 *\r
a15bb0d3 58 * @throws BuidException\r
59 */\r
60 public void execute() throws BuildException {\r
61\r
62 Project project = this.getOwningTarget().getProject();\r
91f7d582 63\r
a15bb0d3 64 //\r
65 // absolute path of efi tools\r
66 //\r
67 String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");\r
68 String command;\r
69 String argument;\r
70 if (path == null) {\r
3f7b510e 71 command = "Strip";\r
a15bb0d3 72 } else {\r
73 command = path + File.separatorChar + "Strip";\r
74 }\r
75 //\r
76 // argument of tools\r
77 //\r
78 File file = new File(outputFile);\r
79 if (!file.isAbsolute() && (!this.outputDir.equalsIgnoreCase(""))) {\r
80 argument = inputFile + " " + outputDir + File.separatorChar\r
81 + outputFile;\r
82 } else {\r
83 argument = inputFile + " " + outputFile;\r
84 }\r
85 //\r
86 // return value of fwimage execution\r
87 //\r
88 int revl = -1;\r
89\r
90 try {\r
91 Commandline cmdline = new Commandline();\r
92 cmdline.setExecutable(command);\r
93 cmdline.createArgument().setLine(argument);\r
94\r
95 LogStreamHandler streamHandler = new LogStreamHandler(this,\r
96 Project.MSG_INFO, Project.MSG_WARN);\r
97 Execute runner = new Execute(streamHandler, null);\r
98\r
99 runner.setAntRun(project);\r
100 runner.setCommandline(cmdline.getCommandline());\r
101 //\r
102 // Set debug log information.\r
103 //\r
91f7d582 104 EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));\r
105 EdkLog.log(this, EdkLog.EDK_INFO, (new File(this.inputFile)).getName());\r
ff225cbb 106\r
a15bb0d3 107 revl = runner.execute();\r
ff225cbb 108\r
a15bb0d3 109 if (EFI_SUCCESS == revl) {\r
110 //\r
111 // command execution success\r
112 //\r
91f7d582 113 EdkLog.log(this, EdkLog.EDK_VERBOSE, "Strip 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
219e2247 119 throw new BuildException("Strip 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
127 * getInputFile\r
ff225cbb 128 *\r
a15bb0d3 129 * This function is to get class member "inputFile".\r
ff225cbb 130 *\r
a15bb0d3 131 * @return string of input file name.\r
132 */\r
133 public String getInputFile() {\r
134 return inputFile;\r
135 }\r
136\r
137 /**\r
138 * setComponentType\r
ff225cbb 139 *\r
a15bb0d3 140 * This function is to set class member "inputFile".\r
ff225cbb 141 *\r
a15bb0d3 142 * @param inputFile\r
143 * string of input file name.\r
144 */\r
145 public void setInputFile(String inputFile) {\r
146 this.inputFile = inputFile;\r
147 }\r
148\r
149 /**\r
150 * getOutputFile\r
ff225cbb 151 *\r
a15bb0d3 152 * This function is to get class member "outputFile"\r
ff225cbb 153 *\r
a15bb0d3 154 * @return outputFile string of output file name.\r
155 */\r
156 public String getOutputFile() {\r
157 return outputFile;\r
158 }\r
159\r
160 /**\r
161 * setOutputFile\r
ff225cbb 162 *\r
a15bb0d3 163 * This function is to set class member "outputFile"\r
ff225cbb 164 *\r
a15bb0d3 165 * @param outputFile\r
166 * string of output file name.\r
167 */\r
168 public void setOutputFile(String outputFile) {\r
169 this.outputFile = outputFile;\r
170 }\r
171\r
172 /**\r
173 * getOutputDir\r
ff225cbb 174 *\r
a15bb0d3 175 * This function is to get class member "outputDir"\r
ff225cbb 176 *\r
a15bb0d3 177 * @return outputDir string of output directory.\r
178 */\r
179 public String getOutputDir() {\r
180 return outputDir;\r
181 }\r
182\r
183 /**\r
184 * setOutputDir\r
ff225cbb 185 *\r
a15bb0d3 186 * This function is to set class member "outputDir"\r
ff225cbb 187 *\r
a15bb0d3 188 * @param outputDir\r
189 * string of output directory.\r
190 */\r
191 public void setOutputDir(String outputDir) {\r
192 this.outputDir = outputDir;\r
193 }\r
194}\r