4 SplitfileTask is used to call splitfile.exe to split input file to 2 output
8 Copyright (c) 2006, Intel Corporation
9 All rights reserved. This program and the accompanying materials
10 are licensed and made available under the terms and conditions of the BSD License
11 which accompanies this distribution. The full text of the license may be found at
12 http://opensource.org/licenses/bsd-license.php
14 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
15 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 package org
.tianocore
.framework
.tasks
;
22 import org
.apache
.tools
.ant
.Task
;
23 import org
.apache
.tools
.ant
.Project
;
24 import org
.apache
.tools
.ant
.BuildException
;
25 import org
.apache
.tools
.ant
.taskdefs
.Execute
;
26 import org
.apache
.tools
.ant
.taskdefs
.LogStreamHandler
;
27 import org
.apache
.tools
.ant
.types
.Commandline
;
28 import org
.tianocore
.logger
.EdkLog
;
33 SplitfileTask is used to call splitfile.exe to split input file to 2 output
36 public class SplitfileTask
extends Task
implements EfiDefine
{
40 private String inputFile
= "";
45 private String offset
= "";
51 * SplitfleTask execute function is to assemble tool command line & execute
54 * @throws BuidException
56 public void execute() throws BuildException
{
58 Project project
= this.getOwningTarget().getProject();
63 FrameworkLogger logger
= new FrameworkLogger(project
, "splitfile");
64 EdkLog
.setLogLevel(project
.getProperty("env.LOGLEVEL"));
65 EdkLog
.setLogger(logger
);
68 // absolute path of efi tools
70 String path
= project
.getProperty("env.FRAMEWORK_TOOLS_PATH");
74 command
= "SplitFile";
76 command
= path
+ File
.separatorChar
+ "SplitFile";
82 argument
= inputFile
+ " " + offset
;
85 // return value of fwimage execution
90 Commandline cmdline
= new Commandline();
91 cmdline
.setExecutable(command
);
92 cmdline
.createArgument().setLine(argument
);
94 LogStreamHandler streamHandler
= new LogStreamHandler(this,
95 Project
.MSG_INFO
, Project
.MSG_WARN
);
96 Execute runner
= new Execute(streamHandler
, null);
98 runner
.setAntRun(project
);
99 runner
.setCommandline(cmdline
.getCommandline());
101 EdkLog
.log(EdkLog
.EDK_INFO
, Commandline
.toString(cmdline
.getCommandline()));
102 revl
= runner
.execute();
103 if (EFI_SUCCESS
== revl
) {
105 // command execution success
107 EdkLog
.log(EdkLog
.EDK_INFO
, "splitfile succeeded!");
110 // command execution fail
112 EdkLog
.log(EdkLog
.EDK_ERROR
, "splitfile failed. (error="
113 + Integer
.toHexString(revl
) + ")");
114 throw new BuildException("splitfile failed. (error="
115 + Integer
.toHexString(revl
) + ")");
118 } catch (Exception e
) {
119 throw new BuildException(e
.getMessage());
126 * This function is to get class member "inputFile".
128 * @return string of input file name.
130 public String
getInputFile() {
137 * This function is to set class member "inputFile".
140 * string of input file name.
142 public void setInputFile(String inputFile
) {
143 this.inputFile
= inputFile
;
149 This function is to get class member "offset"
151 @return offset value of string.
153 public String
getOffset() {
160 This function is to set class member "offset"
163 string of offset value.
165 public void setOffset(String offset
) {
166 this.offset
= offset
;