4 PeiReBaseTask is used to call PeiReBase.exe to rebase efi fv 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 PeiReBaseTask is used to call PeiReBase.exe to rebase efi fv file.
34 public class PeiReBaseTask
extends Task
implements EfiDefine
{
38 private String toolName
= "PeiReBase";
42 private String inputFile
= "";
43 private String inputFileName
= "";
47 private String outputFile
= "";
50 // / Output directory, this variable is added by jave wrap
52 private String outputDir
= "";
57 private String baseAddr
= "";
62 private String arch
= "";
67 * PeiReBaseTask execute function is to assemble tool command line & execute
70 * @throws BuidException
72 public void execute() throws BuildException
{
74 Project project
= this.getOwningTarget().getProject();
78 FrameworkLogger logger
= new FrameworkLogger(project
, toolName
.toLowerCase());
79 EdkLog
.setLogLevel(project
.getProperty("env.LOGLEVEL"));
80 EdkLog
.setLogger(logger
);
83 // absolute path of efi tools
85 String path
= project
.getProperty("env.FRAMEWORK_TOOLS_PATH");
88 if (this.arch
.equalsIgnoreCase("IA32")){
89 command
= toolName
+ "_IA32";
90 }else if (this.arch
.equalsIgnoreCase("X64")){
91 command
= toolName
+ "_X64";
92 }else if (this.arch
.equalsIgnoreCase("IPF")){
93 command
= toolName
+ "_IPF";
95 command
= toolName
+ "_IA32";
98 command
= path
+ File
.separatorChar
+ command
;
104 File file
= new File(outputFile
);
105 if (!file
.isAbsolute() && (!this.outputDir
.equalsIgnoreCase(""))) {
106 argument
= inputFile
+ " " + "-O " + outputDir
+ File
.separatorChar
107 + outputFile
+ " " + this.baseAddr
;
109 argument
= inputFile
+ " " + "-O " + outputFile
+ " " + this.baseAddr
;
113 // return value of fwimage execution
118 Commandline cmdline
= new Commandline();
119 cmdline
.setExecutable(command
);
120 cmdline
.createArgument().setLine(argument
);
122 LogStreamHandler streamHandler
= new LogStreamHandler(this,
123 Project
.MSG_INFO
, Project
.MSG_WARN
);
124 Execute runner
= new Execute(streamHandler
, null);
126 runner
.setAntRun(project
);
127 runner
.setCommandline(cmdline
.getCommandline());
129 // Set debug log information.
131 EdkLog
.log(EdkLog
.EDK_VERBOSE
, Commandline
.toString(cmdline
.getCommandline()));
132 EdkLog
.log(EdkLog
.EDK_INFO
, this.inputFileName
);
134 revl
= runner
.execute();
136 if (EFI_SUCCESS
== revl
) {
138 // command execution success
140 EdkLog
.log(EdkLog
.EDK_VERBOSE
, "PeiReBase succeeded!");
143 // command execution fail
145 EdkLog
.log(EdkLog
.EDK_INFO
, "ERROR = " + Integer
.toHexString(revl
));
146 throw new BuildException("PeiReBase failed!");
148 } catch (Exception e
) {
149 throw new BuildException(e
.getMessage());
156 * This function is to get class member "inputFile".
158 * @return string of input file name.
160 public String
getInputFile() {
167 * This function is to set class member "inputFile".
170 * string of input file name.
172 public void setInputFile(String inputFile
) {
173 this.inputFileName
= (new File(inputFile
)).getName();
174 this.inputFile
= "-I " + inputFile
;
180 * This function is to get class member "outputFile"
182 * @return outputFile string of output file name.
184 public String
getOutputFile() {
191 * This function is to set class member "outputFile"
194 * string of output file name.
196 public void setOutputFile(String outputFile
) {
197 this.outputFile
= outputFile
;
203 * This function is to get class member "outputDir"
205 * @return outputDir string of output directory.
207 public String
getOutputDir() {
214 * This function is to set class member "outputDir"
217 * string of output directory.
219 public void setOutputDir(String outputDir
) {
220 this.outputDir
= outputDir
;
226 * This function is to get class member "baseAddr"
228 * @return baseAddr string of base address.
230 public String
getBaseAddr() {
237 * This function is to set class member "baseAddr"
239 * @param baseAddr string of base address
241 public void setBaseAddr(String baseAddr
) {
242 this.baseAddr
= "-B " + baseAddr
;
248 * This function is to get class member "arch".
250 * @return arch Architecture
252 public String
getArch() {
259 * This function is to set class member "arch"
261 * @param arch Architecture
263 public void setArch(String arch
) {