4 StripTask is used to call Strip.exe to strip input file.
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
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.
17 package org
.tianocore
.framework
.tasks
;
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
;
32 StripTask is used to call Strip.exe to strip input file.
34 public class StripTask
extends Task
implements EfiDefine
{
38 private String inputFile
= "";
43 private String outputFile
= "";
46 // / output directory, this variable is added by jave wrap
48 private String outputDir
= "";
54 * StripTask execute function is to assemble tool command line & execute
57 * @throws BuidException
59 public void execute() throws BuildException
{
61 Project project
= this.getOwningTarget().getProject();
65 FrameworkLogger logger
= new FrameworkLogger(project
, "strip");
66 EdkLog
.setLogLevel(project
.getProperty("env.LOGLEVEL"));
67 EdkLog
.setLogger(logger
);
69 // absolute path of efi tools
71 String path
= project
.getProperty("env.FRAMEWORK_TOOLS_PATH");
77 command
= path
+ File
.separatorChar
+ "Strip";
82 File file
= new File(outputFile
);
83 if (!file
.isAbsolute() && (!this.outputDir
.equalsIgnoreCase(""))) {
84 argument
= inputFile
+ " " + outputDir
+ File
.separatorChar
87 argument
= inputFile
+ " " + outputFile
;
90 // return value of fwimage execution
95 Commandline cmdline
= new Commandline();
96 cmdline
.setExecutable(command
);
97 cmdline
.createArgument().setLine(argument
);
99 LogStreamHandler streamHandler
= new LogStreamHandler(this,
100 Project
.MSG_INFO
, Project
.MSG_WARN
);
101 Execute runner
= new Execute(streamHandler
, null);
103 runner
.setAntRun(project
);
104 runner
.setCommandline(cmdline
.getCommandline());
106 // Set debug log information.
108 EdkLog
.log(EdkLog
.EDK_VERBOSE
, Commandline
.toString(cmdline
.getCommandline()));
109 EdkLog
.log(EdkLog
.EDK_INFO
, (new File(this.inputFile
)).getName());
111 revl
= runner
.execute();
113 if (EFI_SUCCESS
== revl
) {
115 // command execution success
117 EdkLog
.log(EdkLog
.EDK_VERBOSE
, "Strip succeeded!");
120 // command execution fail
122 EdkLog
.log(EdkLog
.EDK_INFO
, "ERROR = " + Integer
.toHexString(revl
));
123 throw new BuildException("Strip failed!");
125 } catch (Exception e
) {
126 throw new BuildException(e
.getMessage());
133 * This function is to get class member "inputFile".
135 * @return string of input file name.
137 public String
getInputFile() {
144 * This function is to set class member "inputFile".
147 * string of input file name.
149 public void setInputFile(String inputFile
) {
150 this.inputFile
= inputFile
;
156 * This function is to get class member "outputFile"
158 * @return outputFile string of output file name.
160 public String
getOutputFile() {
167 * This function is to set class member "outputFile"
170 * string of output file name.
172 public void setOutputFile(String outputFile
) {
173 this.outputFile
= outputFile
;
179 * This function is to get class member "outputDir"
181 * @return outputDir string of output directory.
183 public String
getOutputDir() {
190 * This function is to set class member "outputDir"
193 * string of output directory.
195 public void setOutputDir(String outputDir
) {
196 this.outputDir
= outputDir
;