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 FileArg inputFile
= new FileArg();
47 private FileArg outputFile
= new FileArg();
51 private ToolArg baseAddr
= new ToolArg();
55 private FileArg mapFile
= new FileArg();
59 private String arch
= "IA32";
64 PeiReBaseTask execute function is to assemble tool command line & execute
69 public void execute() throws BuildException
{
71 EdkLog
.log(this, EdkLog
.EDK_VERBOSE
, outputFile
.toFileList() + " is up-to-date!");
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
.separator
+ command
;
99 if (mapFile
.getValue().length() == 0) {
100 mapFile
.setArg(" -M ", outputFile
.getValue() + ".map");
102 argument
= "" + inputFile
+ outputFile
+ baseAddr
+ mapFile
;
105 // return value of fwimage execution
110 Commandline cmdline
= new Commandline();
111 cmdline
.setExecutable(command
);
112 cmdline
.createArgument().setLine(argument
);
114 LogStreamHandler streamHandler
= new LogStreamHandler(this,
115 Project
.MSG_INFO
, Project
.MSG_WARN
);
116 Execute runner
= new Execute(streamHandler
, null);
118 runner
.setAntRun(project
);
119 runner
.setCommandline(cmdline
.getCommandline());
121 // Set debug log information.
123 EdkLog
.log(this, EdkLog
.EDK_VERBOSE
, Commandline
.toString(cmdline
.getCommandline()));
124 EdkLog
.log(this, EdkLog
.EDK_INFO
, inputFile
.toFileList() + " => "
125 + outputFile
.toFileList()
126 + mapFile
.toFileList());
128 revl
= runner
.execute();
130 if (EFI_SUCCESS
== revl
) {
132 // command execution success
134 EdkLog
.log(this, EdkLog
.EDK_VERBOSE
, "PeiReBase succeeded!");
137 // command execution fail
139 EdkLog
.log(this, EdkLog
.EDK_INFO
, "ERROR = " + Integer
.toHexString(revl
));
140 throw new BuildException("PeiReBase failed!");
142 } catch (Exception e
) {
143 throw new BuildException(e
.getMessage());
150 This function is to get class member "inputFile".
152 @return string of input file name.
154 public String
getInputFile() {
155 return inputFile
.getValue();
161 This function is to set class member "inputFile".
164 string of input file name.
166 public void setInputFile(String inputFile
) {
167 this.inputFile
.setArg(" -I ", inputFile
);
173 This function is to get class member "outputFile"
175 @return outputFile string of output file name.
177 public String
getOutputFile() {
178 return outputFile
.getValue();
184 This function is to set class member "outputFile"
187 string of output file name.
189 public void setOutputFile(String outputFile
) {
190 this.outputFile
.setArg(" -O ", outputFile
);
196 This function is to get class member "baseAddr"
198 @return baseAddr string of base address.
200 public String
getBaseAddr() {
201 return baseAddr
.getValue();
207 This function is to set class member "baseAddr"
209 @param baseAddr string of base address
211 public void setBaseAddr(String baseAddr
) {
212 this.baseAddr
.setArg(" -B ", baseAddr
);
218 This function is to get class member "arch".
220 @return arch Architecture
222 public String
getArch() {
229 This function is to set class member "arch"
231 @param arch Architecture
233 public void setArch(String arch
) {
238 Get the value of map file
240 @return String The map file path
242 public String
getMapFile() {
243 return mapFile
.getValue();
247 Set "-M MapFile" argument
249 @param mapFile The path of map file
251 public void setMapFile(String mapFile
) {
252 this.mapFile
.setArg(" -M ", mapFile
);
258 private boolean isUptodate() {
259 File srcFile
= new File(inputFile
.getValue());
260 File dstFile
= new File(outputFile
.getValue());
262 if (srcFile
.lastModified() > dstFile
.lastModified()) {