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();
79 FrameworkLogger logger
= new FrameworkLogger(project
, toolName
.toLowerCase());
80 EdkLog
.setLogLevel(project
.getProperty("env.LOGLEVEL"));
81 EdkLog
.setLogger(logger
);
84 // absolute path of efi tools
86 String path
= project
.getProperty("env.FRAMEWORK_TOOLS_PATH");
89 if (this.arch
.equalsIgnoreCase("IA32")){
90 command
= toolName
+ "_IA32";
91 }else if (this.arch
.equalsIgnoreCase("X64")){
92 command
= toolName
+ "_X64";
93 }else if (this.arch
.equalsIgnoreCase("IPF")){
94 command
= toolName
+ "_IPF";
96 command
= toolName
+ "_IA32";
99 command
= path
+ File
.separatorChar
+ command
;
105 File file
= new File(outputFile
);
106 if (!file
.isAbsolute() && (!this.outputDir
.equalsIgnoreCase(""))) {
107 argument
= inputFile
+ " " + "-O " + outputDir
+ File
.separatorChar
108 + outputFile
+ " " + this.baseAddr
+ " "
109 + "-M " + outputDir
+ + File
.separatorChar
+ outputFile
+ ".map";
111 argument
= inputFile
+ " " + "-O " + outputFile
+ " " + this.baseAddr
+ " " + "-M " + outputFile
+ ".map";
115 // return value of fwimage execution
120 Commandline cmdline
= new Commandline();
121 cmdline
.setExecutable(command
);
122 cmdline
.createArgument().setLine(argument
);
124 LogStreamHandler streamHandler
= new LogStreamHandler(this,
125 Project
.MSG_INFO
, Project
.MSG_WARN
);
126 Execute runner
= new Execute(streamHandler
, null);
128 runner
.setAntRun(project
);
129 runner
.setCommandline(cmdline
.getCommandline());
131 // Set debug log information.
133 EdkLog
.log(EdkLog
.EDK_VERBOSE
, Commandline
.toString(cmdline
.getCommandline()));
134 EdkLog
.log(EdkLog
.EDK_INFO
, this.inputFileName
);
136 revl
= runner
.execute();
138 if (EFI_SUCCESS
== revl
) {
140 // command execution success
142 EdkLog
.log(EdkLog
.EDK_VERBOSE
, "PeiReBase succeeded!");
145 // command execution fail
147 EdkLog
.log(EdkLog
.EDK_INFO
, "ERROR = " + Integer
.toHexString(revl
));
148 throw new BuildException("PeiReBase failed!");
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.inputFileName
= (new File(inputFile
)).getName();
176 this.inputFile
= "-I " + inputFile
;
182 * This function is to get class member "outputFile"
184 * @return outputFile string of output file name.
186 public String
getOutputFile() {
193 * This function is to set class member "outputFile"
196 * string of output file name.
198 public void setOutputFile(String outputFile
) {
199 this.outputFile
= outputFile
;
205 * This function is to get class member "outputDir"
207 * @return outputDir string of output directory.
209 public String
getOutputDir() {
216 * This function is to set class member "outputDir"
219 * string of output directory.
221 public void setOutputDir(String outputDir
) {
222 this.outputDir
= outputDir
;
228 * This function is to get class member "baseAddr"
230 * @return baseAddr string of base address.
232 public String
getBaseAddr() {
239 * This function is to set class member "baseAddr"
241 * @param baseAddr string of base address
243 public void setBaseAddr(String baseAddr
) {
244 this.baseAddr
= "-B " + baseAddr
;
250 * This function is to get class member "arch".
252 * @return arch Architecture
254 public String
getArch() {
261 * This function is to set class member "arch"
263 * @param arch Architecture
265 public void setArch(String arch
) {