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 fvinfFile
= new FileArg();
59 private FileArg mapFile
= new FileArg();
63 private String arch
= "IA32";
68 PeiReBaseTask execute function is to assemble tool command line & execute
73 public void execute() throws BuildException
{
75 EdkLog
.log(this, EdkLog
.EDK_VERBOSE
, outputFile
.toFileList() + " is up-to-date!");
79 Project project
= this.getOwningTarget().getProject();
82 // absolute path of efi tools
84 String path
= project
.getProperty("env.FRAMEWORK_TOOLS_PATH");
87 if (this.arch
.equalsIgnoreCase("IA32")){
88 command
= toolName
+ "_IA32";
89 } else if (this.arch
.equalsIgnoreCase("X64")){
90 command
= toolName
+ "_X64";
91 } else if (this.arch
.equalsIgnoreCase("IPF")){
92 command
= toolName
+ "_IPF";
94 command
= toolName
+ "_IA32";
97 command
= path
+ File
.separator
+ command
;
103 if (mapFile
.getValue().length() == 0) {
104 mapFile
.setArg(" -M ", outputFile
.getValue() + ".map");
106 argument
= "" + inputFile
+ outputFile
+ baseAddr
+ fvinfFile
+ mapFile
;
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
, inputFile
.toFileList() + " => "
129 + outputFile
.toFileList()
130 + mapFile
.toFileList());
132 revl
= runner
.execute();
134 if (EFI_SUCCESS
== revl
) {
136 // command execution success
138 EdkLog
.log(this, EdkLog
.EDK_VERBOSE
, "PeiReBase succeeded!");
141 // command execution fail
143 EdkLog
.log(this, EdkLog
.EDK_INFO
, "ERROR = " + Integer
.toHexString(revl
));
144 throw new BuildException("PeiReBase failed!");
146 } catch (Exception e
) {
147 throw new BuildException(e
.getMessage());
154 This function is to get class member "inputFile".
156 @return string of input file name.
158 public String
getInputFile() {
159 return inputFile
.getValue();
165 This function is to set class member "inputFile".
168 string of input file name.
170 public void setInputFile(String inputFile
) {
171 this.inputFile
.setArg(" -I ", inputFile
);
177 This function is to get class member "outputFile"
179 @return outputFile string of output file name.
181 public String
getOutputFile() {
182 return outputFile
.getValue();
188 This function is to set class member "outputFile"
191 string of output file name.
193 public void setOutputFile(String outputFile
) {
194 this.outputFile
.setArg(" -O ", outputFile
);
200 This function is to get class member "baseAddr"
202 @return baseAddr string of base address.
204 public String
getBaseAddr() {
205 return baseAddr
.getValue();
211 This function is to set class member "baseAddr"
213 @param baseAddr string of base address
215 public void setBaseAddr(String baseAddr
) {
216 this.baseAddr
.setArg(" -B ", baseAddr
);
222 This function is to get class member "arch".
224 @return arch Architecture
226 public String
getArch() {
233 This function is to set class member "arch"
235 @param arch Architecture
237 public void setArch(String arch
) {
242 Get the value of fv.inf file
244 @return String The fv.inf file path
246 public String
getFvInfFile() {
247 return fvinfFile
.getValue();
251 Set "-F FvinfFile" argument
253 @param fvinfFile The path of fv.inf file
255 public void setFvInfFile(String fvinfFile
) {
256 this.fvinfFile
.setArg(" -F ", fvinfFile
);
260 Get the value of map file
262 @return String The map file path
264 public String
getMapFile() {
265 return mapFile
.getValue();
269 Set "-M MapFile" argument
271 @param mapFile The path of map file
273 public void setMapFile(String mapFile
) {
274 this.mapFile
.setArg(" -M ", mapFile
);
280 private boolean isUptodate() {
281 File srcFile
= new File(inputFile
.getValue());
282 File dstFile
= new File(outputFile
.getValue());
284 if (srcFile
.lastModified() > dstFile
.lastModified()) {