4 GenSectionTask is to call GenSection.exe to generate Section.
6 Copyright (c) 2006, Intel Corporation
7 All rights reserved. This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 package org
.tianocore
.framework
.tasks
;
21 import org
.apache
.tools
.ant
.BuildException
;
22 import org
.apache
.tools
.ant
.Project
;
23 import org
.apache
.tools
.ant
.Task
;
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 public class GenSectionTask
extends Task
implements EfiDefine
{
32 private String inputFile
= "";
36 private String inputFileName
= "";
40 private String outputFile
= "";
44 private String sectionType
= "";
48 private String versionNum
= "";
52 private String interfaceString
= "";
57 GenSectionTaks execute is to assemble tool command line & execute tool
60 @throws BuildException
62 public void execute() throws BuildException
{
64 Project project
= this.getOwningTarget().getProject();
66 // absolute path of efi tools
68 String path
= project
.getProperty("env.FRAMEWORK_TOOLS_PATH");
70 command
= "GenSection";
72 command
= path
+ "/" + "GenSection";
77 String argument
= inputFile
+ outputFile
+ sectionType
+ versionNum
80 // return value of gensection execution
85 Commandline cmdline
= new Commandline();
86 cmdline
.setExecutable(command
);
87 cmdline
.createArgument().setLine(argument
);
89 LogStreamHandler streamHandler
= new LogStreamHandler(this,
90 Project
.MSG_INFO
, Project
.MSG_WARN
);
91 Execute runner
= new Execute(streamHandler
, null);
93 runner
.setAntRun(project
);
94 runner
.setCommandline(cmdline
.getCommandline());
97 log(Commandline
.toString(cmdline
.getCommandline()), Project
.MSG_VERBOSE
);
98 revl
= runner
.execute();
99 if (EFI_SUCCESS
== revl
) {
100 log("GenSection succeeded!", Project
.MSG_VERBOSE
);
103 // command execution fail
105 log("ERROR = " + Integer
.toHexString(revl
));
106 throw new BuildException("GenSection failed!");
108 } catch (Exception e
) {
109 throw new BuildException(e
.getMessage());
116 This function is to get class member "inputFile".
118 @return name of input file
120 public String
getInputFile() {
121 return this.inputFile
;
127 This function is to set class member "inputFile".
129 @param inputFile name of input file
131 public void setInputFile(String inputFile
) {
132 this.inputFileName
= (new File(inputFile
)).getName();
133 this.inputFile
= " -i " + inputFile
;
139 This function is to get class member "outputFile".
141 @return name of output file
143 public String
getOutputFile() {
144 return this.outputFile
;
150 This function is to set class member "outputFile".
151 @param outputFile name of output file
153 public void setOutputfile(String outputFile
) {
154 this.outputFile
= " -o " + outputFile
;
160 This function is to get class member "sectionType".
164 public String
getSectionType() {
165 return this.sectionType
;
171 This function is to set class member "sectionType".
173 @param sectionType section type
175 public void setSectionType(String sectionType
) {
176 this.sectionType
= " -s " + sectionType
;
182 This function is to get class member "versionNum".
183 @return version number
185 public String
getVersionNum() {
186 return this.versionNum
;
192 This function is to set class member "versionNum".
193 @param versionNum version number
195 public void setVersionNum(String versionNum
) {
196 this.versionNum
= " -v " + versionNum
;
202 This function is to get class member "interfaceString".
203 @return interface string
205 public String
getInterfaceString() {
206 return this.interfaceString
;
212 This funcion is to set class member "interfaceString".
213 @param interfaceString interface string
215 public void setInterfaceString(String interfaceString
) {
216 this.interfaceString
= " -a " + "\"" + interfaceString
+ "\"";