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
;
29 import org
.tianocore
.common
.logger
.EdkLog
;
34 SplitfileTask is used to call splitfile.exe to split input file to 2 output
37 public class SplitfileTask
extends Task
implements EfiDefine
{
41 private String inputFile
= "";
46 private String offset
= "";
52 * SplitfleTask execute function is to assemble tool command line & execute
55 * @throws BuidException
57 public void execute() throws BuildException
{
59 Project project
= this.getOwningTarget().getProject();
64 FrameworkLogger logger
= new FrameworkLogger(project
, "splitfile");
65 EdkLog
.setLogLevel(project
.getProperty("env.LOGLEVEL"));
66 EdkLog
.setLogger(logger
);
69 // absolute path of efi tools
71 String path
= project
.getProperty("env.FRAMEWORK_TOOLS_PATH");
75 command
= "SplitFile";
77 command
= path
+ File
.separatorChar
+ "SplitFile";
83 argument
= inputFile
+ " " + offset
;
86 // return value of fwimage execution
91 Commandline cmdline
= new Commandline();
92 cmdline
.setExecutable(command
);
93 cmdline
.createArgument().setLine(argument
);
95 LogStreamHandler streamHandler
= new LogStreamHandler(this,
96 Project
.MSG_INFO
, Project
.MSG_WARN
);
97 Execute runner
= new Execute(streamHandler
, null);
99 runner
.setAntRun(project
);
100 runner
.setCommandline(cmdline
.getCommandline());
102 EdkLog
.log(EdkLog
.EDK_VERBOSE
, Commandline
.toString(cmdline
.getCommandline()));
103 EdkLog
.log(EdkLog
.EDK_INFO
, (new File(this.inputFile
)).getName());
104 revl
= runner
.execute();
105 if (EFI_SUCCESS
== revl
) {
107 // command execution success
109 EdkLog
.log(EdkLog
.EDK_VERBOSE
, "SplitFile succeeded!");
112 // command execution fail
114 EdkLog
.log(EdkLog
.EDK_INFO
, "ERROR = " + Integer
.toHexString(revl
));
115 throw new BuildException("SplitFile failed!");
117 } catch (Exception e
) {
118 throw new BuildException(e
.getMessage());
125 * This function is to get class member "inputFile".
127 * @return string of input file name.
129 public String
getInputFile() {
136 * This function is to set class member "inputFile".
139 * string of input file name.
141 public void setInputFile(String inputFile
) {
142 this.inputFile
= inputFile
;
148 This function is to get class member "offset"
150 @return offset value of string.
152 public String
getOffset() {
159 This function is to set class member "offset"
162 string of offset value.
164 public void setOffset(String offset
) {
165 this.offset
= offset
;