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
= "";
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_INFO
, Commandline
.toString(cmdline
.getCommandline()));
133 revl
= runner
.execute();
135 if (EFI_SUCCESS
== revl
) {
137 // command execution success
139 EdkLog
.log(EdkLog
.EDK_INFO
,"PeiBase succeeded!");
142 // command execution fail
144 EdkLog
.log(EdkLog
.EDK_ERROR
, "PeiBase failed. (error="
145 + Integer
.toHexString(revl
) + ")");
146 throw new BuildException("PeiBase failed. (error="
147 + Integer
.toHexString(revl
) + ")");
150 } catch (Exception e
) {
151 throw new BuildException(e
.getMessage());
158 * This function is to get class member "inputFile".
160 * @return string of input file name.
162 public String
getInputFile() {
169 * This function is to set class member "inputFile".
172 * string of input file name.
174 public void setInputFile(String inputFile
) {
175 this.inputFile
= "-I " + inputFile
;
181 * This function is to get class member "outputFile"
183 * @return outputFile string of output file name.
185 public String
getOutputFile() {
192 * This function is to set class member "outputFile"
195 * string of output file name.
197 public void setOutputFile(String outputFile
) {
198 this.outputFile
= outputFile
;
204 * This function is to get class member "outputDir"
206 * @return outputDir string of output directory.
208 public String
getOutputDir() {
215 * This function is to set class member "outputDir"
218 * string of output directory.
220 public void setOutputDir(String outputDir
) {
221 this.outputDir
= outputDir
;
227 * This function is to get class member "baseAddr"
229 * @return baseAddr string of base address.
231 public String
getBaseAddr() {
238 * This function is to set class member "baseAddr"
240 * @param baseAddr string of base address
242 public void setBaseAddr(String baseAddr
) {
243 this.baseAddr
= "-B " + baseAddr
;
249 * This function is to get class member "arch".
251 * @return arch Architecture
253 public String
getArch() {
260 * This function is to set class member "arch"
262 * @param arch Architecture
264 public void setArch(String arch
) {