4 EfiCompressTask is used to call EfiCompress.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
;
28 import org
.tianocore
.common
.logger
.EdkLog
;
31 EfiCompressTask class.
33 EfiCompressTask is used to call EfiCompress.exe to strip input file.
35 public class EfiCompressTask
extends Task
implements EfiDefine
{
39 private String inputFile
= "";
44 private String outputFile
= "";
47 // / output directory, this variable is added by jave wrap
49 private String outputDir
= "";
54 * EfiCompressTask execute function is to assemble tool command line & execute
57 * @throws BuidException
59 public void execute() throws BuildException
{
61 Project project
= this.getOwningTarget().getProject();
64 // absolute path of efi tools
66 String path
= project
.getProperty("env.FRAMEWORK_TOOLS_PATH");
70 command
= "EfiCompress";
72 command
= path
+ File
.separatorChar
+ "EfiCompress";
77 File file
= new File(outputFile
);
78 if (!file
.isAbsolute() && (!this.outputDir
.equalsIgnoreCase(""))) {
79 argument
= inputFile
+ " " + outputDir
+ File
.separatorChar
82 argument
= inputFile
+ " " + outputFile
;
85 // return value of fwimage execution
90 Commandline cmdline
= new Commandline();
91 cmdline
.setExecutable(command
);
92 cmdline
.createArgument().setLine(argument
);
94 LogStreamHandler streamHandler
= new LogStreamHandler(this,
95 Project
.MSG_INFO
, Project
.MSG_WARN
);
96 Execute runner
= new Execute(streamHandler
, null);
98 runner
.setAntRun(project
);
99 runner
.setCommandline(cmdline
.getCommandline());
101 // Set debug log information.
103 EdkLog
.log(this, EdkLog
.EDK_VERBOSE
, Commandline
.toString(cmdline
.getCommandline()));
104 EdkLog
.log(this, EdkLog
.EDK_INFO
, (new File(this.inputFile
)).getName());
106 revl
= runner
.execute();
108 if (EFI_SUCCESS
== revl
) {
110 // command execution success
112 EdkLog
.log(this, EdkLog
.EDK_VERBOSE
, "EfiCompress succeeded!");
115 // command execution fail
117 EdkLog
.log(this, EdkLog
.EDK_INFO
, "ERROR = " + Integer
.toHexString(revl
));
118 throw new BuildException("EfiCompress failed!");
121 } catch (Exception e
) {
122 throw new BuildException(e
.getMessage());
129 * This function is to get class member "inputFile".
131 * @return string of input file name.
133 public String
getInputFile() {
140 * This function is to set class member "inputFile".
143 * string of input file name.
145 public void setInputFile(String inputFile
) {
146 this.inputFile
= inputFile
;
152 * This function is to get class member "outputFile"
154 * @return outputFile string of output file name.
156 public String
getOutputFile() {
163 * This function is to set class member "outputFile"
166 * string of output file name.
168 public void setOutputFile(String outputFile
) {
169 this.outputFile
= outputFile
;
175 * This function is to get class member "outputDir"
177 * @return outputDir string of output directory.
179 public String
getOutputDir() {
186 * This function is to set class member "outputDir"
189 * string of output directory.
191 public void setOutputDir(String outputDir
) {
192 this.outputDir
= outputDir
;