]>
Commit | Line | Data |
---|---|---|
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 | |
17 | package org.tianocore.framework.tasks;\r | |
18 | \r | |
19 | import java.io.File;\r | |
20 | \r | |
21 | import org.apache.tools.ant.BuildException;\r | |
22 | import org.apache.tools.ant.Project;\r | |
23 | import org.apache.tools.ant.Task;\r | |
24 | import org.apache.tools.ant.taskdefs.Execute;\r | |
25 | import org.apache.tools.ant.taskdefs.LogStreamHandler;\r | |
26 | import org.apache.tools.ant.types.Commandline;\r | |
27 | \r | |
28 | import org.tianocore.common.logger.EdkLog;\r | |
29 | \r | |
30 | /**\r | |
31 | GenCRC32SectionTask\r | |
32 | \r | |
33 | GenCRC32SectionTask is to call GenCRC32Section.exe to generate crc32 section. \r | |
34 | \r | |
35 | **/\r | |
36 | public class GenCRC32SectionTask extends Task implements EfiDefine {\r | |
37 | //\r | |
38 | // Tool name\r | |
39 | //\r | |
40 | private static String toolName = "GenCRC32Section";\r | |
41 | //\r | |
42 | // output file\r | |
43 | //\r | |
44 | private FileArg outputFile = new FileArg();\r | |
45 | //\r | |
46 | // inputFile list\r | |
47 | //\r | |
48 | private InputFile inputFileList = new InputFile();\r | |
49 | \r | |
50 | //\r | |
51 | // Project\r | |
52 | //\r | |
53 | static private Project project;\r | |
54 | \r | |
55 | /**\r | |
56 | execute\r | |
57 | \r | |
58 | GenCRC32SectionTask execute is to assemble tool command line & execute\r | |
59 | tool command line\r | |
60 | \r | |
61 | @throws BuildException\r | |
62 | **/\r | |
63 | public void execute() throws BuildException {\r | |
64 | \r | |
65 | project = this.getOwningTarget().getProject(); \r | |
66 | ///\r | |
67 | /// absolute path of efi tools\r | |
68 | ///\r | |
69 | String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH"); \r | |
70 | String command;\r | |
71 | if (path == null) {\r | |
72 | command = toolName;\r | |
73 | } else {\r | |
74 | command = path + File.separator + toolName ;\r | |
75 | }\r | |
76 | // \r | |
77 | // assemble argument \r | |
78 | //\r | |
79 | String argument = "" + inputFileList.toStringWithSinglepPrefix(" -i ") + outputFile; \r | |
80 | // \r | |
81 | // return value of fwimage execution \r | |
82 | //\r | |
83 | int revl = -1; \r | |
84 | \r | |
85 | try {\r | |
86 | Commandline cmdline = new Commandline();\r | |
87 | cmdline.setExecutable(command);\r | |
88 | cmdline.createArgument().setLine(argument);\r | |
89 | \r | |
90 | LogStreamHandler streamHandler = new LogStreamHandler(this, 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 | |
95 | \r | |
96 | EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));\r | |
97 | EdkLog.log(this, inputFileList.toFileList() + " => " + outputFile.toFileList());\r | |
98 | \r | |
99 | revl = runner.execute();\r | |
100 | if (EFI_SUCCESS == revl){\r | |
101 | //\r | |
102 | // command execution success \r | |
103 | //\r | |
104 | EdkLog.log(this, toolName + " succeeded!");\r | |
105 | } else {\r | |
106 | // \r | |
107 | // command execution fail\r | |
108 | //\r | |
109 | EdkLog.log(this, "ERROR = " + Integer.toHexString(revl));\r | |
110 | // LAH Added This Line\r | |
111 | throw new BuildException(toolName + " failed!");\r | |
112 | }\r | |
113 | } catch (Exception e) {\r | |
114 | throw new BuildException(e.getMessage());\r | |
115 | } \r | |
116 | }\r | |
117 | \r | |
118 | /**\r | |
119 | addInputFile\r | |
120 | \r | |
121 | This function is to add a inputFile element into list\r | |
122 | @param inputFile : inputFile element\r | |
123 | **/\r | |
124 | public void addConfiguredInputfile(InputFile inputFile) {\r | |
125 | inputFileList.insert(inputFile);\r | |
126 | }\r | |
127 | \r | |
128 | /**\r | |
129 | get class member "outputFile"\r | |
130 | @return name of output file\r | |
131 | **/\r | |
132 | public String getOutputFile() {\r | |
133 | return this.outputFile.getValue();\r | |
134 | }\r | |
135 | /**\r | |
136 | set class member "outputFile"\r | |
137 | @param outputFile : outputFile parameter \r | |
138 | **/\r | |
139 | public void setOutputFile(String outputFile) {\r | |
140 | this.outputFile.setArg(" -o ", outputFile);\r | |
141 | }\r | |
142 | }\r |