]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - Tools/Java/Source/FrameworkTasks/org/tianocore/framework/tasks/StripTask.java
Removed the need of external MakeDeps.exe. Now parsing include files is built in...
[mirror_edk2.git] / Tools / Java / Source / FrameworkTasks / org / tianocore / framework / tasks / StripTask.java
... / ...
CommitLineData
1/** @file\r
2 StripTask class.\r
3\r
4 StripTask is used to call Strip.exe to strip input file.\r
5\r
6\r
7 Copyright (c) 2006, Intel Corporation\r
8 All rights reserved. This program and the accompanying materials\r
9 are licensed and made available under the terms and conditions of the BSD License\r
10 which accompanies this distribution. The full text of the license may be found at\r
11 http://opensource.org/licenses/bsd-license.php\r
12\r
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
15\r
16 **/\r
17package org.tianocore.framework.tasks;\r
18\r
19import java.io.File;\r
20\r
21import org.apache.tools.ant.Task;\r
22import org.apache.tools.ant.Project;\r
23import org.apache.tools.ant.BuildException;\r
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
28import org.tianocore.common.logger.EdkLog;\r
29\r
30/**\r
31 StripTask class.\r
32\r
33 StripTask is used to call Strip.exe to strip input file.\r
34 */\r
35public class StripTask extends Task implements EfiDefine {\r
36 //\r
37 // \r
38 // \r
39 private static String toolName = "Strip";\r
40 //\r
41 // input file\r
42 //\r
43 private FileArg inputFile = new FileArg();\r
44\r
45 //\r
46 // output file\r
47 //\r
48 private FileArg outputFile = new FileArg();\r
49\r
50 //\r
51 // output directory, this variable is added by jave wrap\r
52 //\r
53 private String outputDir = ".";\r
54\r
55\r
56 /**\r
57 execute\r
58 \r
59 StripTask execute function is to assemble tool command line & execute\r
60 tool command line\r
61 \r
62 @throws BuidException\r
63 **/\r
64 public void execute() throws BuildException {\r
65\r
66 Project project = this.getOwningTarget().getProject();\r
67\r
68 //\r
69 // absolute path of efi tools\r
70 //\r
71 String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");\r
72 String command;\r
73 String argument;\r
74\r
75 if (path == null) {\r
76 command = toolName;\r
77 } else {\r
78 command = path + File.separator + toolName;\r
79 }\r
80\r
81 //\r
82 // argument of tools\r
83 //\r
84 argument = "" + inputFile + outputFile;\r
85\r
86 //\r
87 // return value of fwimage execution\r
88 //\r
89 int revl = -1;\r
90\r
91 try {\r
92 Commandline cmdline = new Commandline();\r
93 cmdline.setExecutable(command);\r
94 cmdline.createArgument().setLine(argument);\r
95\r
96 LogStreamHandler streamHandler = new LogStreamHandler(this,\r
97 Project.MSG_INFO, Project.MSG_WARN);\r
98 Execute runner = new Execute(streamHandler, null);\r
99\r
100 runner.setAntRun(project);\r
101 runner.setCommandline(cmdline.getCommandline());\r
102 runner.setWorkingDirectory(new File(outputDir));\r
103\r
104 //\r
105 // Set debug log information.\r
106 //\r
107 EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));\r
108 EdkLog.log(this, EdkLog.EDK_INFO, inputFile.toFileList() + " => " + outputFile.toFileList());\r
109\r
110 revl = runner.execute();\r
111\r
112 if (EFI_SUCCESS == revl) {\r
113 //\r
114 // command execution success\r
115 //\r
116 EdkLog.log(this, EdkLog.EDK_VERBOSE, toolName + " succeeded!");\r
117 } else {\r
118 //\r
119 // command execution fail\r
120 //\r
121 EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));\r
122 throw new BuildException(toolName + " failed!");\r
123 }\r
124 } catch (Exception e) {\r
125 throw new BuildException(e.getMessage());\r
126 }\r
127 }\r
128\r
129 /**\r
130 getInputFile\r
131 \r
132 This function is to get class member "inputFile".\r
133 \r
134 @return string of input file name.\r
135 **/\r
136 public String getInputFile() {\r
137 return inputFile.getValue();\r
138 }\r
139\r
140 /**\r
141 setComponentType\r
142 \r
143 This function is to set class member "inputFile".\r
144 \r
145 @param inputFile\r
146 string of input file name.\r
147 **/\r
148 public void setInputFile(String inputFile) {\r
149 this.inputFile.setArg(" ", inputFile);\r
150 }\r
151\r
152 /**\r
153 getOutputFile\r
154 \r
155 This function is to get class member "outputFile"\r
156 \r
157 @return outputFile string of output file name.\r
158 **/\r
159 public String getOutputFile() {\r
160 return outputFile.getValue();\r
161 }\r
162\r
163 /**\r
164 setOutputFile\r
165 \r
166 This function is to set class member "outputFile"\r
167 \r
168 @param outputFile\r
169 string of output file name.\r
170 **/\r
171 public void setOutputFile(String outputFile) {\r
172 this.outputFile.setArg(" ", outputFile);\r
173 }\r
174\r
175 /**\r
176 getOutputDir\r
177 \r
178 This function is to get class member "outputDir"\r
179 \r
180 @return outputDir string of output directory.\r
181 **/\r
182 public String getOutputDir() {\r
183 return outputDir;\r
184 }\r
185\r
186 /**\r
187 setOutputDir\r
188 \r
189 This function is to set class member "outputDir"\r
190 \r
191 @param outputDir\r
192 string of output directory.\r
193 **/\r
194 public void setOutputDir(String outputDir) {\r
195 this.outputDir = outputDir;\r
196 }\r
197}\r