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
;
21 import org
.apache
.tools
.ant
.BuildException
;
22 import org
.apache
.tools
.ant
.Project
;
23 import org
.apache
.tools
.ant
.Task
;
24 import org
.apache
.tools
.ant
.taskdefs
.Execute
;
25 import org
.apache
.tools
.ant
.taskdefs
.LogStreamHandler
;
26 import org
.apache
.tools
.ant
.types
.Commandline
;
28 import org
.tianocore
.common
.logger
.EdkLog
;
33 GenCRC32SectionTask is to call GenCRC32Section.exe to generate crc32 section.
36 public class GenCRC32SectionTask
extends Task
implements EfiDefine
{
40 private static String toolName
= "GenCRC32Section";
44 private FileArg outputFile
= new FileArg();
48 private InputFile inputFileList
= new InputFile();
53 static private Project project
;
58 GenCRC32SectionTask execute is to assemble tool command line & execute
61 @throws BuildException
63 public void execute() throws BuildException
{
65 project
= this.getOwningTarget().getProject();
67 /// absolute path of efi tools
69 String path
= project
.getProperty("env.FRAMEWORK_TOOLS_PATH");
74 command
= path
+ File
.separator
+ toolName
;
79 String argument
= "" + inputFileList
.toStringWithSinglepPrefix(" -i ") + outputFile
;
81 // return value of fwimage execution
86 Commandline cmdline
= new Commandline();
87 cmdline
.setExecutable(command
);
88 cmdline
.createArgument().setLine(argument
);
90 LogStreamHandler streamHandler
= new LogStreamHandler(this, Project
.MSG_INFO
, Project
.MSG_WARN
);
91 Execute runner
= new Execute(streamHandler
, null);
93 runner
.setAntRun(project
);
94 runner
.setCommandline(cmdline
.getCommandline());
96 EdkLog
.log(this, EdkLog
.EDK_VERBOSE
, Commandline
.toString(cmdline
.getCommandline()));
97 EdkLog
.log(this, inputFileList
.toFileList() + " => " + outputFile
.toFileList());
99 revl
= runner
.execute();
100 if (EFI_SUCCESS
== revl
){
102 // command execution success
104 EdkLog
.log(this, toolName
+ " succeeded!");
107 // command execution fail
109 EdkLog
.log(this, "ERROR = " + Integer
.toHexString(revl
));
110 // LAH Added This Line
111 throw new BuildException(toolName
+ " failed!");
113 } catch (Exception e
) {
114 throw new BuildException(e
.getMessage());
121 This function is to add a inputFile element into list
122 @param inputFile : inputFile element
124 public void addConfiguredInputfile(InputFile inputFile
) {
125 inputFileList
.insert(inputFile
);
129 get class member "outputFile"
130 @return name of output file
132 public String
getOutputFile() {
133 return this.outputFile
.getValue();
136 set class member "outputFile"
137 @param outputFile : outputFile parameter
139 public void setOutputFile(String outputFile
) {
140 this.outputFile
.setArg(" -o ", outputFile
);