]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Java/Source/FrameworkTasks/org/tianocore/framework/tasks/StripTask.java
- Fixed EDKT240. Now the Blank.pad file for alignment purpose will no longer be needed.
[mirror_edk2.git] / Tools / Java / Source / FrameworkTasks / org / tianocore / framework / tasks / StripTask.java
CommitLineData
a15bb0d3 1/** @file\r
2 StripTask class.\r
3\r
4 StripTask is used to call Strip.exe to strip input file.\r
ff225cbb 5\r
6\r
a15bb0d3 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
ff225cbb 12\r
a15bb0d3 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
ff225cbb 27\r
28import org.tianocore.common.logger.EdkLog;\r
a15bb0d3 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
0fdb42ac 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
a15bb0d3 54\r
ff225cbb 55\r
a15bb0d3 56 /**\r
0fdb42ac 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
a15bb0d3 64 public void execute() throws BuildException {\r
65\r
66 Project project = this.getOwningTarget().getProject();\r
91f7d582 67\r
a15bb0d3 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
0fdb42ac 74\r
a15bb0d3 75 if (path == null) {\r
0fdb42ac 76 command = toolName;\r
a15bb0d3 77 } else {\r
0fdb42ac 78 command = path + File.separator + toolName;\r
a15bb0d3 79 }\r
0fdb42ac 80\r
a15bb0d3 81 //\r
82 // argument of tools\r
83 //\r
0fdb42ac 84 argument = "" + inputFile + outputFile;\r
85\r
a15bb0d3 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
0fdb42ac 102 runner.setWorkingDirectory(new File(outputDir));\r
103\r
a15bb0d3 104 //\r
105 // Set debug log information.\r
106 //\r
91f7d582 107 EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));\r
0fdb42ac 108 EdkLog.log(this, EdkLog.EDK_INFO, inputFile.toFileList() + " => " + outputFile.toFileList());\r
ff225cbb 109\r
a15bb0d3 110 revl = runner.execute();\r
ff225cbb 111\r
a15bb0d3 112 if (EFI_SUCCESS == revl) {\r
113 //\r
114 // command execution success\r
115 //\r
0fdb42ac 116 EdkLog.log(this, EdkLog.EDK_VERBOSE, toolName + " succeeded!");\r
a15bb0d3 117 } else {\r
118 //\r
119 // command execution fail\r
120 //\r
91f7d582 121 EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));\r
0fdb42ac 122 throw new BuildException(toolName + " failed!");\r
a15bb0d3 123 }\r
124 } catch (Exception e) {\r
125 throw new BuildException(e.getMessage());\r
126 }\r
127 }\r
128\r
129 /**\r
0fdb42ac 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
a15bb0d3 136 public String getInputFile() {\r
0fdb42ac 137 return inputFile.getValue();\r
a15bb0d3 138 }\r
139\r
140 /**\r
0fdb42ac 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
a15bb0d3 148 public void setInputFile(String inputFile) {\r
0fdb42ac 149 this.inputFile.setArg(" ", inputFile);\r
a15bb0d3 150 }\r
151\r
152 /**\r
0fdb42ac 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
a15bb0d3 159 public String getOutputFile() {\r
0fdb42ac 160 return outputFile.getValue();\r
a15bb0d3 161 }\r
162\r
163 /**\r
0fdb42ac 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
a15bb0d3 171 public void setOutputFile(String outputFile) {\r
0fdb42ac 172 this.outputFile.setArg(" ", outputFile);\r
a15bb0d3 173 }\r
174\r
175 /**\r
0fdb42ac 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
a15bb0d3 182 public String getOutputDir() {\r
183 return outputDir;\r
184 }\r
185\r
186 /**\r
0fdb42ac 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
a15bb0d3 194 public void setOutputDir(String outputDir) {\r
195 this.outputDir = outputDir;\r
196 }\r
197}\r