]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenSectionTask.java
Fix a misspelling.
[mirror_edk2.git] / Tools / Source / FrameworkTasks / org / tianocore / framework / tasks / GenSectionTask.java
1 /** @file
2 GenSectionTask class.
3
4 GenSectionTask is to call GenSection.exe to generate Section.
5
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
11
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.
14
15 **/
16
17 package org.tianocore.framework.tasks;
18
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;
25
26 public class GenSectionTask extends Task implements EfiDefine {
27 ///
28 /// inputfile name
29 ///
30 private String inputFile = "";
31 ///
32 /// outputfile name
33 ///
34 private String outputFile = "";
35 ///
36 /// section type
37 ///
38 private String sectionType = "";
39 ///
40 /// version number
41 ///
42 private String versionNum = "";
43 ///
44 /// interface string
45 ///
46 private String interfaceString = "";
47
48 /**
49 execute
50
51 GenSectionTaks execute is to assemble tool command line & execute tool
52 command line.
53
54 @throws BuildException
55 **/
56 public void execute() throws BuildException {
57 String command;
58 Project project = this.getOwningTarget().getProject();
59 //
60 // absolute path of efi tools
61 //
62 String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");
63 if (path == null) {
64 command = "gensection";
65 } else {
66 command = path + "/" + "gensection";
67 }
68 //
69 // argument of tools
70 //
71 String argument = inputFile + outputFile + sectionType + versionNum
72 + interfaceString;
73 //
74 // return value of gensection execution
75 //
76 int revl = -1;
77
78 try {
79 Commandline cmdline = new Commandline();
80 cmdline.setExecutable(command);
81 cmdline.createArgument().setLine(argument);
82
83 LogStreamHandler streamHandler = new LogStreamHandler(this,
84 Project.MSG_INFO, Project.MSG_WARN);
85 Execute runner = new Execute(streamHandler, null);
86
87 runner.setAntRun(project);
88 runner.setCommandline(cmdline.getCommandline());
89 System.out.println(Commandline.toString(cmdline.getCommandline()));
90
91 revl = runner.execute();
92 if (EFI_SUCCESS == revl) {
93 //
94 // command execution success
95 //
96 System.out.println("gensection succeeded!");
97 } else {
98 //
99 // command execution fail
100 //
101 System.out.println("gensection failed. (error="
102 + Integer.toHexString(revl) + ")");
103 throw new BuildException("gensection failed. (error="
104 + Integer.toHexString(revl) + ")");
105 }
106 } catch (Exception e) {
107 throw new BuildException(e.getMessage());
108 }
109 }
110
111 /**
112 getInputFile
113
114 This function is to get class member "inputFile".
115
116 @return name of input file
117 **/
118 public String getInputFile() {
119 return this.inputFile;
120 }
121
122 /**
123 setInputFile
124
125 This function is to set class member "inputFile".
126
127 @param inputFile name of input file
128 **/
129 public void setInputFile(String inputFile) {
130 this.inputFile = " -i " + inputFile;
131 }
132
133 /**
134 getOutputFile
135
136 This function is to get class member "outputFile".
137
138 @return name of output file
139 **/
140 public String getOutputFile() {
141 return this.outputFile;
142 }
143
144 /**
145 setOutputfile
146
147 This function is to set class member "outputFile".
148 @param outputFile name of output file
149 **/
150 public void setOutputfile(String outputFile) {
151 this.outputFile = " -o " + outputFile;
152 }
153
154 /**
155 getSectionType
156
157 This function is to get class member "sectionType".
158
159 @return sectoin type
160 **/
161 public String getSectionType() {
162 return this.sectionType;
163 }
164
165 /**
166 setSectionType
167
168 This function is to set class member "sectionType".
169
170 @param sectionType section type
171 **/
172 public void setSectionType(String sectionType) {
173 this.sectionType = " -s " + sectionType;
174 }
175
176 /**
177 getVersionNum
178
179 This function is to get class member "versionNum".
180 @return version number
181 **/
182 public String getVersionNum() {
183 return this.versionNum;
184 }
185
186 /**
187 setVersionNume
188
189 This function is to set class member "versionNum".
190 @param versionNum version number
191 **/
192 public void setVersionNum(String versionNum) {
193 this.versionNum = " -v " + versionNum;
194 }
195
196 /**
197 getInterfaceString
198
199 This function is to get class member "interfaceString".
200 @return interface string
201 **/
202 public String getInterfaceString() {
203 return this.interfaceString;
204 }
205
206 /**
207 setInterfaceString
208
209 This funcion is to set class member "interfaceString".
210 @param interfaceString interface string
211 **/
212 public void setInterfaceString(String interfaceString) {
213 this.interfaceString = " -a " + "\"" + interfaceString + "\"";
214 }
215 }