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
+ " "
108 + "-M " + outputDir
+ + File
.separatorChar
+ outputFile
+ ".map";
110 argument
= inputFile
+ " " + "-O " + outputFile
+ " " + this.baseAddr
+ " " + "-M " + outputFile
+ ".map";
114 // return value of fwimage execution
119 Commandline cmdline
= new Commandline();
120 cmdline
.setExecutable(command
);
121 cmdline
.createArgument().setLine(argument
);
123 LogStreamHandler streamHandler
= new LogStreamHandler(this,
124 Project
.MSG_INFO
, Project
.MSG_WARN
);
125 Execute runner
= new Execute(streamHandler
, null);
127 runner
.setAntRun(project
);
128 runner
.setCommandline(cmdline
.getCommandline());
130 // Set debug log information.
132 EdkLog
.log(EdkLog
.EDK_VERBOSE
, Commandline
.toString(cmdline
.getCommandline()));
133 EdkLog
.log(EdkLog
.EDK_INFO
, this.inputFileName
);
135 revl
= runner
.execute();
137 if (EFI_SUCCESS
== revl
) {
139 // command execution success
141 EdkLog
.log(EdkLog
.EDK_VERBOSE
, "PeiReBase succeeded!");
144 // command execution fail
146 EdkLog
.log(EdkLog
.EDK_INFO
, "ERROR = " + Integer
.toHexString(revl
));
147 throw new BuildException("PeiReBase failed!");
149 } catch (Exception e
) {
150 throw new BuildException(e
.getMessage());
157 * This function is to get class member "inputFile".
159 * @return string of input file name.
161 public String
getInputFile() {
168 * This function is to set class member "inputFile".
171 * string of input file name.
173 public void setInputFile(String inputFile
) {
174 this.inputFileName
= (new File(inputFile
)).getName();
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
) {