2 GenCRC32SectionTask class.
4 GenCRC32SectionTask is to call GenCRC32Section.exe to generate crc32 section.
6 Copyright (c) 2006, Intel Corporation
7 All rights reserved. This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 package org
.tianocore
.framework
.tasks
;
20 import org
.apache
.tools
.ant
.Project
;
21 import org
.apache
.tools
.ant
.Task
;
22 import org
.apache
.tools
.ant
.BuildException
;
23 import org
.apache
.tools
.ant
.taskdefs
.Execute
;
24 import org
.apache
.tools
.ant
.taskdefs
.LogStreamHandler
;
25 import org
.apache
.tools
.ant
.types
.Commandline
;
30 GenCRC32SectionTask is to call GenCRC32Section.exe to generate crc32 section.
33 public class GenCRC32SectionTask
extends Task
implements EfiDefine
{
37 private String outputFile
;
41 private List
<Object
> inputFileList
= new ArrayList
<Object
>();
46 static private Project project
;
51 GenCRC32SectionTask execute is to assemble tool command line & execute
54 @throws BuildException
56 public void execute() throws BuildException
{
58 project
= this.getOwningTarget().getProject();
60 /// absolute path of efi tools
62 String path
= project
.getProperty("env.FRAMEWORK_TOOLS_PATH");
65 command
= "GenCRC32Section";
67 command
= path
+ "/" + "GenCRC32Section" ;
70 // string line of input files
72 String inputFiles
= list2Str(inputFileList
, "");
76 String argument
= inputFiles
+ outputFile
;
78 // return value of fwimage execution
83 Commandline cmdline
= new Commandline();
84 cmdline
.setExecutable(command
);
85 cmdline
.createArgument().setLine(argument
);
87 LogStreamHandler streamHandler
= new LogStreamHandler(this, Project
.MSG_INFO
, Project
.MSG_WARN
);
88 Execute runner
= new Execute(streamHandler
, null);
90 runner
.setAntRun(project
);
91 runner
.setCommandline(cmdline
.getCommandline());
92 log(Commandline
.toString(cmdline
.getCommandline()), Project
.MSG_VERBOSE
);
94 revl
= runner
.execute();
95 if (EFI_SUCCESS
== revl
){
97 // command execution success
99 log("gencrc32section succeeded!", Project
.MSG_VERBOSE
);
102 // command execution fail
104 log("ERROR = " + Integer
.toHexString(revl
));
106 } catch (Exception e
) {
107 throw new BuildException(e
.getMessage());
114 This function is to add a inputFile element into list
115 @param inputFile : inputFile element
117 public void addInputfile(InputFile inputFile
) {
118 inputFileList
.add(inputFile
);
122 get class member "outputFile"
123 * @return name of output file
125 public String
getOutputFile() {
126 return this.outputFile
;
129 * set class member "outputFile"
130 * @param outputFile : outputFile parameter
132 public void setOutputFile(String outputFile
) {
133 this.outputFile
= " -o " + outputFile
;
137 * transfer List to String
138 * @param list : nested element list
139 * @param tag : interval tag of parameter
140 * @return string line of parameters
142 private String
list2Str(List list
, String tag
) {
144 * string line for return
146 String paraStr
= " -i";
148 * nested element in list
152 * iterator of nested element list
154 Iterator elementIter
= list
.iterator();
156 * string parameter list
158 List
<Object
> strList
= new ArrayList
<Object
>();
160 while (elementIter
.hasNext()) {
161 element
= (NestElement
) elementIter
.next();
162 if (null != element
.getFile()) {
163 FileParser
.loadFile(project
, strList
, element
.getFile(), tag
);
165 paraStr
= paraStr
+ element
.getName();
169 * iterator of string parameter list
171 Iterator strIter
= strList
.iterator();
172 while (strIter
.hasNext()) {
173 paraStr
= paraStr
+ " " + strIter
.next();