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
;
28 import org
.tianocore
.common
.logger
.EdkLog
;
33 PeiReBaseTask is used to call PeiReBase.exe to rebase efi fv file.
35 public class PeiReBaseTask
extends Task
implements EfiDefine
{
39 private String toolName
= "PeiReBase";
43 private String inputFile
= "";
44 private String inputFileName
= "";
48 private String outputFile
= "";
51 // / Output directory, this variable is added by jave wrap
53 private String outputDir
= "";
58 private String baseAddr
= "";
63 private String arch
= "";
68 * PeiReBaseTask execute function is to assemble tool command line & execute
71 * @throws BuidException
73 public void execute() throws BuildException
{
75 Project project
= this.getOwningTarget().getProject();
78 // absolute path of efi tools
80 String path
= project
.getProperty("env.FRAMEWORK_TOOLS_PATH");
83 if (this.arch
.equalsIgnoreCase("IA32")){
84 command
= toolName
+ "_IA32";
85 }else if (this.arch
.equalsIgnoreCase("X64")){
86 command
= toolName
+ "_X64";
87 }else if (this.arch
.equalsIgnoreCase("IPF")){
88 command
= toolName
+ "_IPF";
90 command
= toolName
+ "_IA32";
93 command
= path
+ File
.separatorChar
+ command
;
99 File file
= new File(outputFile
);
100 if (!file
.isAbsolute() && (!this.outputDir
.equalsIgnoreCase(""))) {
101 argument
= inputFile
+ " " + "-O " + outputDir
+ File
.separatorChar
102 + outputFile
+ " " + this.baseAddr
+ " "
103 + "-M " + outputDir
+ + File
.separatorChar
+ outputFile
+ ".map";
105 argument
= inputFile
+ " " + "-O " + outputFile
+ " " + this.baseAddr
+ " " + "-M " + outputFile
+ ".map";
109 // return value of fwimage execution
114 Commandline cmdline
= new Commandline();
115 cmdline
.setExecutable(command
);
116 cmdline
.createArgument().setLine(argument
);
118 LogStreamHandler streamHandler
= new LogStreamHandler(this,
119 Project
.MSG_INFO
, Project
.MSG_WARN
);
120 Execute runner
= new Execute(streamHandler
, null);
122 runner
.setAntRun(project
);
123 runner
.setCommandline(cmdline
.getCommandline());
125 // Set debug log information.
127 EdkLog
.log(this, EdkLog
.EDK_VERBOSE
, Commandline
.toString(cmdline
.getCommandline()));
128 EdkLog
.log(this, EdkLog
.EDK_INFO
, this.inputFileName
);
130 revl
= runner
.execute();
132 if (EFI_SUCCESS
== revl
) {
134 // command execution success
136 EdkLog
.log(this, EdkLog
.EDK_VERBOSE
, "PeiReBase succeeded!");
139 // command execution fail
141 EdkLog
.log(this, EdkLog
.EDK_INFO
, "ERROR = " + Integer
.toHexString(revl
));
142 throw new BuildException("PeiReBase failed!");
144 } catch (Exception e
) {
145 throw new BuildException(e
.getMessage());
152 * This function is to get class member "inputFile".
154 * @return string of input file name.
156 public String
getInputFile() {
163 * This function is to set class member "inputFile".
166 * string of input file name.
168 public void setInputFile(String inputFile
) {
169 this.inputFileName
= (new File(inputFile
)).getName();
170 this.inputFile
= "-I " + inputFile
;
176 * This function is to get class member "outputFile"
178 * @return outputFile string of output file name.
180 public String
getOutputFile() {
187 * This function is to set class member "outputFile"
190 * string of output file name.
192 public void setOutputFile(String outputFile
) {
193 this.outputFile
= outputFile
;
199 * This function is to get class member "outputDir"
201 * @return outputDir string of output directory.
203 public String
getOutputDir() {
210 * This function is to set class member "outputDir"
213 * string of output directory.
215 public void setOutputDir(String outputDir
) {
216 this.outputDir
= outputDir
;
222 * This function is to get class member "baseAddr"
224 * @return baseAddr string of base address.
226 public String
getBaseAddr() {
233 * This function is to set class member "baseAddr"
235 * @param baseAddr string of base address
237 public void setBaseAddr(String baseAddr
) {
238 this.baseAddr
= "-B " + baseAddr
;
244 * This function is to get class member "arch".
246 * @return arch Architecture
248 public String
getArch() {
255 * This function is to set class member "arch"
257 * @param arch Architecture
259 public void setArch(String arch
) {