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
;
19 import org
.apache
.tools
.ant
.Project
;
20 import org
.apache
.tools
.ant
.Task
;
21 import org
.apache
.tools
.ant
.BuildException
;
22 import org
.apache
.tools
.ant
.taskdefs
.Execute
;
23 import org
.apache
.tools
.ant
.taskdefs
.LogStreamHandler
;
24 import org
.apache
.tools
.ant
.types
.Commandline
;
26 public class GenSectionTask
extends Task
implements EfiDefine
{
30 private String inputFile
= "";
34 private String outputFile
= "";
38 private String sectionType
= "";
42 private String versionNum
= "";
46 private String interfaceString
= "";
51 GenSectionTaks execute is to assemble tool command line & execute tool
54 @throws BuildException
56 public void execute() throws BuildException
{
58 Project project
= this.getOwningTarget().getProject();
60 // absolute path of efi tools
62 String path
= project
.getProperty("env.FRAMEWORK_TOOLS_PATH");
64 command
= "GenSection";
66 command
= path
+ "/" + "GenSection";
71 String argument
= inputFile
+ outputFile
+ sectionType
+ versionNum
74 // return value of gensection execution
79 Commandline cmdline
= new Commandline();
80 cmdline
.setExecutable(command
);
81 cmdline
.createArgument().setLine(argument
);
83 LogStreamHandler streamHandler
= new LogStreamHandler(this,
84 Project
.MSG_INFO
, Project
.MSG_WARN
);
85 Execute runner
= new Execute(streamHandler
, null);
87 runner
.setAntRun(project
);
88 runner
.setCommandline(cmdline
.getCommandline());
89 System
.out
.println(Commandline
.toString(cmdline
.getCommandline()));
91 revl
= runner
.execute();
92 if (EFI_SUCCESS
== revl
) {
94 // command execution success
96 System
.out
.println("gensection succeeded!");
99 // command execution fail
101 System
.out
.println("gensection failed. (error="
102 + Integer
.toHexString(revl
) + ")");
103 throw new BuildException("gensection failed. (error="
104 + Integer
.toHexString(revl
) + ")");
106 } catch (Exception e
) {
107 throw new BuildException(e
.getMessage());
114 This function is to get class member "inputFile".
116 @return name of input file
118 public String
getInputFile() {
119 return this.inputFile
;
125 This function is to set class member "inputFile".
127 @param inputFile name of input file
129 public void setInputFile(String inputFile
) {
130 this.inputFile
= " -i " + inputFile
;
136 This function is to get class member "outputFile".
138 @return name of output file
140 public String
getOutputFile() {
141 return this.outputFile
;
147 This function is to set class member "outputFile".
148 @param outputFile name of output file
150 public void setOutputfile(String outputFile
) {
151 this.outputFile
= " -o " + outputFile
;
157 This function is to get class member "sectionType".
161 public String
getSectionType() {
162 return this.sectionType
;
168 This function is to set class member "sectionType".
170 @param sectionType section type
172 public void setSectionType(String sectionType
) {
173 this.sectionType
= " -s " + sectionType
;
179 This function is to get class member "versionNum".
180 @return version number
182 public String
getVersionNum() {
183 return this.versionNum
;
189 This function is to set class member "versionNum".
190 @param versionNum version number
192 public void setVersionNum(String versionNum
) {
193 this.versionNum
= " -v " + versionNum
;
199 This function is to get class member "interfaceString".
200 @return interface string
202 public String
getInterfaceString() {
203 return this.interfaceString
;
209 This funcion is to set class member "interfaceString".
210 @param interfaceString interface string
212 public void setInterfaceString(String interfaceString
) {
213 this.interfaceString
= " -a " + "\"" + interfaceString
+ "\"";