]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenCRC32SectionTask.java
Fixed the issue caused by introducing INCLUDE_PATH property;
[mirror_edk2.git] / Tools / Source / FrameworkTasks / org / tianocore / framework / tasks / GenCRC32SectionTask.java
CommitLineData
878ddf1f 1/** @file\r
2 GenCRC32SectionTask class.\r
3\r
4 GenCRC32SectionTask is to call GenCRC32Section.exe to generate crc32 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
19import java.util.*;\r
20import org.apache.tools.ant.Project;\r
21import org.apache.tools.ant.Task;\r
22import org.apache.tools.ant.BuildException;\r
23import org.apache.tools.ant.taskdefs.Execute;\r
24import org.apache.tools.ant.taskdefs.LogStreamHandler;\r
25import org.apache.tools.ant.types.Commandline;\r
26\r
27/**\r
28 GenCRC32SectionTask\r
29 \r
30 GenCRC32SectionTask is to call GenCRC32Section.exe to generate crc32 section. \r
31 \r
32**/\r
82810f3b 33public class GenCRC32SectionTask extends Task implements EfiDefine {\r
878ddf1f 34 ///\r
35 /// output file\r
36 ///\r
37 private String outputFile;\r
38 ///\r
39 /// inputFile list\r
40 ///\r
82810f3b 41 private List<NestElement> inputFileList = new ArrayList<NestElement>();\r
878ddf1f 42 \r
43 ///\r
44 /// Project\r
45 ///\r
46 static private Project project;\r
47 \r
48 /**\r
49 execute\r
50 \r
51 GenCRC32SectionTask execute is to assemble tool command line & execute\r
52 tool command line\r
53 \r
54 @throws BuildException\r
55 **/\r
56 public void execute() throws BuildException {\r
57 \r
58 project = this.getOwningTarget().getProject(); \r
59 ///\r
60 /// absolute path of efi tools\r
61 ///\r
2da8968b 62 String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH"); \r
878ddf1f 63 String command;\r
64 if (path == null) {\r
fad77353 65 command = "GenCRC32Section";\r
878ddf1f 66 } else {\r
fad77353 67 command = path + "/" + "GenCRC32Section" ;\r
878ddf1f 68 }\r
69 // \r
70 // string line of input files \r
71 // \r
82810f3b 72 String inputFiles = " -i "; \r
73 for (int i = 0; i < inputFileList.size(); ++i) {\r
74 inputFiles += inputFileList.get(i).toString(" ");\r
75 }\r
76\r
878ddf1f 77 // \r
78 // assemble argument \r
79 //\r
80 String argument = inputFiles + outputFile; \r
81 // \r
82 // return value of fwimage execution \r
83 //\r
84 int revl = -1; \r
85 \r
86 try {\r
87 Commandline cmdline = new Commandline();\r
88 cmdline.setExecutable(command);\r
89 cmdline.createArgument().setLine(argument);\r
90 \r
91 LogStreamHandler streamHandler = new LogStreamHandler(this, Project.MSG_INFO, Project.MSG_WARN);\r
92 Execute runner = new Execute(streamHandler, null);\r
93 \r
94 runner.setAntRun(project);\r
95 runner.setCommandline(cmdline.getCommandline());\r
219e2247 96 log(Commandline.toString(cmdline.getCommandline()), Project.MSG_VERBOSE);\r
97 log(" ");\r
878ddf1f 98 revl = runner.execute();\r
99 if (EFI_SUCCESS == revl){\r
100 //\r
101 // command execution success \r
102 //\r
3f7b510e 103 log("GenCRC32Section succeeded!", Project.MSG_VERBOSE);\r
219e2247 104 } else {\r
878ddf1f 105 // \r
106 // command execution fail\r
107 //\r
219e2247 108 log("ERROR = " + Integer.toHexString(revl));\r
c59963f5 109 // LAH Added This Line\r
3f7b510e 110 throw new BuildException("GenCRC32Section failed!");\r
878ddf1f 111 }\r
112 } catch (Exception e) {\r
113 throw new BuildException(e.getMessage());\r
219e2247 114 } \r
878ddf1f 115 }\r
116\r
117 /**\r
118 addInputFile\r
119 \r
120 This function is to add a inputFile element into list\r
121 @param inputFile : inputFile element\r
122 **/\r
123 public void addInputfile(InputFile inputFile) {\r
124 inputFileList.add(inputFile);\r
125 }\r
126 \r
127 /**\r
128 get class member "outputFile"\r
129 * @return name of output file\r
130 */\r
131 public String getOutputFile() {\r
132 return this.outputFile;\r
133 }\r
134 /**\r
135 * set class member "outputFile"\r
136 * @param outputFile : outputFile parameter \r
137 */\r
138 public void setOutputFile(String outputFile) {\r
139 this.outputFile = " -o " + outputFile;\r
82810f3b 140 }\r
878ddf1f 141}\r