2 This file is to define an ANT task which wraps VfrCompile.exe tool
4 Copyright (c) 2006, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14 package org
.tianocore
.framework
.tasks
;
17 import java
.io
.IOException
;
18 import java
.util
.ArrayList
;
19 import java
.util
.List
;
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
;
31 VfrcompilerTask Task Class
33 -createListFile : create an output IFR listing file.
34 -outPutDir : deposit all output files to directory OutputDir (default=cwd)
35 -createIfrBinFile: create an IFR HII pack file
36 -vfrFile : name of the input VFR script file
37 -processArg : c processer argument
38 -includepathList : add IncPath to the search path for VFR included files
40 public class VfrCompilerTask
extends Task
implements EfiDefine
{
41 private static String toolName
= "VfrCompile";
43 private ToolArg createListFile
= new ToolArg();
44 private ToolArg createIfrBinFile
= new ToolArg();
45 private ToolArg processerArg
= new ToolArg();
46 private FileArg vfrFile
= new FileArg();
47 private IncludePath includepathList
= new IncludePath();
48 private FileArg outPutDir
= new FileArg(" -od ", ".");
51 get class member of createList file
53 @returns file name of createList
55 public boolean getCreateListFile() {
56 return this.createListFile
.getValue().length() > 0;
60 set class member of createList file
62 @param createListFile if createList string equal "on" set '-l' flag
64 public void setCreateListFile(boolean createListFile
) {
66 this.createListFile
.setArg(" -", "l");
73 @returns name of output dir
75 public String
getOutPutDir() {
76 return this.outPutDir
.getValue();
80 set class member of outPutDir
82 @param outPutDir The directory name for ouput file
84 public void setOutPutDir(String outPutDir
) {
85 this.outPutDir
.setArg(" -od ", outPutDir
);
90 get class member of ifrBinFile
92 @return file name of ifrBinFile
94 public boolean getCreateIfrBinFile() {
95 return this.createIfrBinFile
.getValue().length() > 0;
99 set class member of ifrBinFile
101 @param createIfrBinFile The flag to specify if the IFR binary file should
104 public void setCreateIfrBinFile(boolean createIfrBinFile
) {
105 if (createIfrBinFile
) {
106 this.createIfrBinFile
.setArg(" -", "ibin");
111 get class member of vfrFile
113 @returns name of vfrFile
115 public String
getVfrFile() {
116 return this.vfrFile
.getValue();
120 set class member of vfrFile
122 @param vfrFile The name of VFR file
124 public void setVfrFile(String vfrFile
) {
125 this.vfrFile
.setArg(" ", vfrFile
);
129 add includePath in includepath List
131 @param includepath The IncludePath object which represents include path
133 public void addConfiguredIncludepath(IncludePath includepath
){
134 this.includepathList
.insert(includepath
);
138 get class member of processerArg
140 @returns processer argument
142 public String
getProcesserArg() {
143 return this.processerArg
.getValue();
148 set class member of processerArg
150 @param processerArg The processor argument
152 public void setProcesserArg(String processerArg
) {
153 this.processerArg
.setArg(" -ppflag ", processerArg
);
157 The standard execute method of ANT task.
159 public void execute() throws BuildException
{
160 Project project
= this.getProject();
161 String toolPath
= project
.getProperty("env.FRAMEWORK_TOOLS_PATH");
163 if (toolPath
== null) {
166 command
= toolPath
+ File
.separator
+ toolName
;
169 String argument
= "" + createIfrBinFile
177 /// constructs the command-line
179 Commandline commandLine
= new Commandline();
180 commandLine
.setExecutable(command
);
181 commandLine
.createArgument().setLine(argument
);
184 /// configures the Execute object
186 LogStreamHandler streamHandler
= new LogStreamHandler(this,
190 Execute runner
= new Execute(streamHandler
,null);
191 runner
.setAntRun(project
);
192 runner
.setCommandline(commandLine
.getCommandline());
193 runner
.setWorkingDirectory(new File(outPutDir
.getValue()));
195 EdkLog
.log(this, EdkLog
.EDK_VERBOSE
, Commandline
.toString(commandLine
.getCommandline()));
196 EdkLog
.log(this, vfrFile
.toFileList());
198 int returnVal
= runner
.execute();
199 if (EFI_SUCCESS
== returnVal
) {
200 EdkLog
.log(this, EdkLog
.EDK_VERBOSE
, "VfrCompile succeeded!");
202 EdkLog
.log(this, "ERROR = " + Integer
.toHexString(returnVal
));
203 throw new BuildException("VfrCompile failed!");
205 } catch (IOException e
) {
206 throw new BuildException(e
.getMessage());