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 static String toolName
= "SplitFile";
46 private FileArg inputFile
= new FileArg();
51 private ToolArg offset
= new ToolArg();
56 private String outputDir
= ".";
61 SplitfleTask execute function is to assemble tool command line & execute
66 public void execute() throws BuildException
{
68 Project project
= this.getOwningTarget().getProject();
71 // absolute path of efi tools
73 String path
= project
.getProperty("env.FRAMEWORK_TOOLS_PATH");
79 command
= path
+ File
.separator
+ toolName
;
85 argument
= "" + inputFile
+ offset
;
88 // return value of fwimage execution
93 Commandline cmdline
= new Commandline();
94 cmdline
.setExecutable(command
);
95 cmdline
.createArgument().setLine(argument
);
97 LogStreamHandler streamHandler
= new LogStreamHandler(this,
98 Project
.MSG_INFO
, Project
.MSG_WARN
);
99 Execute runner
= new Execute(streamHandler
, null);
101 runner
.setAntRun(project
);
102 runner
.setCommandline(cmdline
.getCommandline());
103 runner
.setWorkingDirectory(new File(outputDir
));
105 EdkLog
.log(this, EdkLog
.EDK_VERBOSE
, Commandline
.toString(cmdline
.getCommandline()));
106 String fileName
= inputFile
.toFileList();
107 EdkLog
.log(this, EdkLog
.EDK_INFO
, fileName
+ " => " + fileName
+ "1 " + fileName
+ "2");
109 revl
= runner
.execute();
110 if (EFI_SUCCESS
== revl
) {
112 // command execution success
114 EdkLog
.log(this, EdkLog
.EDK_VERBOSE
, toolName
+ " succeeded!");
117 // command execution fail
119 EdkLog
.log(this, EdkLog
.EDK_INFO
, "ERROR = " + Integer
.toHexString(revl
));
120 throw new BuildException(toolName
+ " failed!");
122 } catch (Exception e
) {
123 throw new BuildException(e
.getMessage());
130 This function is to get class member "inputFile".
132 @return string of input file name.
134 public String
getInputFile() {
135 return inputFile
.getValue();
141 This function is to set class member "inputFile".
144 string of input file name.
146 public void setInputFile(String inputFile
) {
147 this.inputFile
.setArg(" ", inputFile
);
153 This function is to get class member "offset"
155 @return offset value of string.
157 public String
getOffset() {
158 return offset
.getValue();
164 This function is to set class member "offset"
167 string of offset value.
169 public void setOffset(String offset
) {
170 this.offset
.setArg(" ", offset
);
176 This function is to get class member "outputDir"
178 @return outputDir string of output directory.
180 public String
getOutputDir() {
187 This function is to set class member "outputDir"
190 string of output directory.
192 public void setOutputDir(String outputDir
) {
193 this.outputDir
= outputDir
;