]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenSectionTask.java
Updated PeiRebase to produce a map file of the relocations done by this tool. This...
[mirror_edk2.git] / Tools / Source / FrameworkTasks / org / tianocore / framework / tasks / GenSectionTask.java
CommitLineData
878ddf1f 1/** @file\r
2 GenSectionTask class.\r
3\r
4 GenSectionTask is to call GenSection.exe to generate Section.\r
5 \r
6 Copyright (c) 2006, Intel Corporation\r
7 All rights reserved. This program and the accompanying materials\r
8 are licensed and made available under the terms and conditions of the BSD License\r
9 which accompanies this distribution. The full text of the license may be found at\r
10 http://opensource.org/licenses/bsd-license.php\r
11 \r
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
14 \r
15**/\r
16\r
17package org.tianocore.framework.tasks;\r
18\r
219e2247 19import java.io.File;\r
20\r
21import org.apache.tools.ant.BuildException;\r
878ddf1f 22import org.apache.tools.ant.Project;\r
23import org.apache.tools.ant.Task;\r
878ddf1f 24import org.apache.tools.ant.taskdefs.Execute;\r
25import org.apache.tools.ant.taskdefs.LogStreamHandler;\r
26import org.apache.tools.ant.types.Commandline;\r
27\r
28public class GenSectionTask extends Task implements EfiDefine {\r
29 ///\r
30 /// inputfile name\r
31 ///\r
32 private String inputFile = "";\r
33 ///\r
219e2247 34 /// \r
35 /// \r
36 private String inputFileName = "";\r
37 ///\r
878ddf1f 38 /// outputfile name\r
39 ///\r
40 private String outputFile = "";\r
41 ///\r
42 /// section type\r
43 ///\r
44 private String sectionType = "";\r
45 ///\r
46 /// version number\r
47 ///\r
48 private String versionNum = "";\r
49 ///\r
50 /// interface string\r
51 ///\r
52 private String interfaceString = "";\r
53\r
54 /**\r
55 execute\r
56 \r
57 GenSectionTaks execute is to assemble tool command line & execute tool\r
58 command line.\r
59 \r
60 @throws BuildException\r
61 **/\r
62 public void execute() throws BuildException {\r
63 String command;\r
64 Project project = this.getOwningTarget().getProject();\r
65 //\r
66 // absolute path of efi tools\r
67 //\r
2da8968b 68 String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");\r
878ddf1f 69 if (path == null) {\r
fad77353 70 command = "GenSection";\r
878ddf1f 71 } else {\r
fad77353 72 command = path + "/" + "GenSection";\r
878ddf1f 73 }\r
74 //\r
75 // argument of tools\r
76 //\r
77 String argument = inputFile + outputFile + sectionType + versionNum\r
78 + interfaceString;\r
79 //\r
80 // return value of gensection execution\r
81 //\r
82 int revl = -1;\r
83\r
84 try {\r
85 Commandline cmdline = new Commandline();\r
86 cmdline.setExecutable(command);\r
87 cmdline.createArgument().setLine(argument);\r
88\r
89 LogStreamHandler streamHandler = new LogStreamHandler(this,\r
90 Project.MSG_INFO, Project.MSG_WARN);\r
91 Execute runner = new Execute(streamHandler, null);\r
92\r
93 runner.setAntRun(project);\r
94 runner.setCommandline(cmdline.getCommandline());\r
878ddf1f 95\r
219e2247 96 log(inputFileName);\r
97 log(Commandline.toString(cmdline.getCommandline()), Project.MSG_VERBOSE);\r
878ddf1f 98 revl = runner.execute();\r
99 if (EFI_SUCCESS == revl) {\r
219e2247 100 log("gensection succeeded!", Project.MSG_VERBOSE);\r
878ddf1f 101 } else {\r
102 //\r
103 // command execution fail\r
104 //\r
219e2247 105 log("ERROR = " + Integer.toHexString(revl));\r
106 throw new BuildException("gensection failed!");\r
878ddf1f 107 }\r
108 } catch (Exception e) {\r
109 throw new BuildException(e.getMessage());\r
110 }\r
111 }\r
112\r
113 /**\r
114 getInputFile\r
115 \r
116 This function is to get class member "inputFile".\r
117 \r
118 @return name of input file\r
119 **/\r
120 public String getInputFile() {\r
121 return this.inputFile;\r
122 }\r
123\r
124 /**\r
125 setInputFile\r
126 \r
127 This function is to set class member "inputFile".\r
128 \r
129 @param inputFile name of input file\r
130 **/\r
131 public void setInputFile(String inputFile) {\r
219e2247 132 this.inputFileName = (new File(inputFile)).getName();\r
878ddf1f 133 this.inputFile = " -i " + inputFile;\r
134 }\r
135\r
136 /**\r
137 getOutputFile\r
138 \r
139 This function is to get class member "outputFile".\r
140 \r
141 @return name of output file\r
142 **/\r
143 public String getOutputFile() {\r
144 return this.outputFile;\r
145 }\r
146\r
147 /**\r
148 setOutputfile\r
149 \r
150 This function is to set class member "outputFile".\r
151 @param outputFile name of output file\r
152 **/\r
153 public void setOutputfile(String outputFile) {\r
154 this.outputFile = " -o " + outputFile;\r
155 }\r
156\r
157 /**\r
158 getSectionType\r
159 \r
160 This function is to get class member "sectionType".\r
161 \r
162 @return sectoin type\r
163 **/\r
164 public String getSectionType() {\r
165 return this.sectionType;\r
166 }\r
167\r
168 /**\r
169 setSectionType\r
170 \r
171 This function is to set class member "sectionType".\r
172 \r
173 @param sectionType section type\r
174 **/\r
175 public void setSectionType(String sectionType) {\r
176 this.sectionType = " -s " + sectionType;\r
177 }\r
178\r
179 /**\r
180 getVersionNum\r
181 \r
182 This function is to get class member "versionNum".\r
183 @return version number\r
184 **/\r
185 public String getVersionNum() {\r
186 return this.versionNum;\r
187 }\r
188\r
189 /**\r
190 setVersionNume\r
191 \r
192 This function is to set class member "versionNum".\r
193 @param versionNum version number\r
194 **/\r
195 public void setVersionNum(String versionNum) {\r
196 this.versionNum = " -v " + versionNum;\r
197 }\r
198\r
199 /**\r
200 getInterfaceString\r
201 \r
202 This function is to get class member "interfaceString".\r
203 @return interface string\r
204 **/\r
205 public String getInterfaceString() {\r
206 return this.interfaceString;\r
207 }\r
208\r
209 /**\r
210 setInterfaceString\r
211 \r
212 This funcion is to set class member "interfaceString".\r
213 @param interfaceString interface string\r
214 **/\r
215 public void setInterfaceString(String interfaceString) {\r
216 this.interfaceString = " -a " + "\"" + interfaceString + "\"";\r
217 }\r
218}\r