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
;
19 import org
.apache
.tools
.ant
.BuildException
;
20 import org
.apache
.tools
.ant
.Project
;
21 import org
.apache
.tools
.ant
.Task
;
22 import org
.apache
.tools
.ant
.taskdefs
.Execute
;
23 import org
.apache
.tools
.ant
.taskdefs
.LogStreamHandler
;
24 import org
.apache
.tools
.ant
.types
.Commandline
;
26 import org
.tianocore
.common
.logger
.EdkLog
;
29 VfrcompilerTask Task Class
31 -createListFile : create an output IFR listing file.
32 -outPutDir : deposit all output files to directory OutputDir (default=cwd)
33 -createIfrBinFile: create an IFR HII pack file
34 -vfrFile : name of the input VFR script file
35 -processArg : c processer argument
36 -includepathList : add IncPath to the search path for VFR included files
38 public class VfrCompilerTask
extends Task
implements EfiDefine
{
39 private static String toolName
= "VfrCompile";
41 private ToolArg createListFile
= new ToolArg();
42 private ToolArg createIfrBinFile
= new ToolArg();
43 private ToolArg processerArg
= new ToolArg();
44 private FileArg vfrFile
= new FileArg();
45 private IncludePath includepathList
= new IncludePath();
46 private FileArg outPutDir
= new FileArg(" -od ", ".");
47 private String dllPath
= "";
50 get class member of createList file
52 @returns file name of createList
54 public boolean getCreateListFile() {
55 return this.createListFile
.getValue().length() > 0;
59 set class member of createList file
61 @param createListFile if createList string equal "on" set '-l' flag
63 public void setCreateListFile(boolean createListFile
) {
65 this.createListFile
.setArg(" -", "l");
72 @returns name of output dir
74 public String
getOutPutDir() {
75 return this.outPutDir
.getValue();
79 set class member of outPutDir
81 @param outPutDir The directory name for ouput file
83 public void setOutPutDir(String outPutDir
) {
84 this.outPutDir
.setArg(" -od ", outPutDir
);
89 get class member of ifrBinFile
91 @return file name of ifrBinFile
93 public boolean getCreateIfrBinFile() {
94 return this.createIfrBinFile
.getValue().length() > 0;
98 set class member of ifrBinFile
100 @param createIfrBinFile The flag to specify if the IFR binary file should
103 public void setCreateIfrBinFile(boolean createIfrBinFile
) {
104 if (createIfrBinFile
) {
105 this.createIfrBinFile
.setArg(" -", "ibin");
110 get class member of vfrFile
112 @returns name of vfrFile
114 public String
getVfrFile() {
115 return this.vfrFile
.getValue();
119 set class member of vfrFile
121 @param vfrFile The name of VFR file
123 public void setVfrFile(String vfrFile
) {
124 this.vfrFile
.setArg(" ", vfrFile
);
128 add includePath in includepath List
130 @param includepath The IncludePath object which represents include path
132 public void addConfiguredIncludepath(IncludePath includepath
){
133 this.includepathList
.insert(includepath
);
137 get class member of processerArg
139 @returns processer argument
141 public String
getProcesserArg() {
142 return this.processerArg
.getValue();
147 set class member of processerArg
149 @param processerArg The processor argument
151 public void setProcesserArg(String processerArg
) {
152 this.processerArg
.setArg(" -ppflag ", processerArg
);
155 public void setDllPath(String dllPath
) {
156 this.dllPath
= dllPath
;
160 The standard execute method of ANT task.
162 public void execute() throws BuildException
{
163 Project project
= this.getProject();
164 String toolPath
= project
.getProperty("env.FRAMEWORK_TOOLS_PATH");
166 if (toolPath
== null) {
169 command
= toolPath
+ File
.separator
+ toolName
;
172 String argument
= "" + createIfrBinFile
180 /// constructs the command-line
182 Commandline commandLine
= new Commandline();
183 commandLine
.setExecutable(command
);
184 commandLine
.createArgument().setLine(argument
);
187 /// configures the Execute object
189 LogStreamHandler streamHandler
= new LogStreamHandler(this,
193 Execute runner
= new Execute(streamHandler
,null);
194 runner
.setAntRun(project
);
195 runner
.setCommandline(commandLine
.getCommandline());
196 runner
.setWorkingDirectory(new File(outPutDir
.getValue()));
197 runner
.setEnvironment(new String
[]{"PATH", dllPath
});
199 EdkLog
.log(this, EdkLog
.EDK_VERBOSE
, Commandline
.toString(commandLine
.getCommandline()));
200 EdkLog
.log(this, vfrFile
.toFileList());
202 int returnVal
= runner
.execute();
203 if (EFI_SUCCESS
== returnVal
) {
204 EdkLog
.log(this, EdkLog
.EDK_VERBOSE
, "VfrCompile succeeded!");
206 EdkLog
.log(this, "ERROR = " + Integer
.toHexString(returnVal
));
207 throw new BuildException("VfrCompile failed!");
209 } catch (IOException e
) {
210 throw new BuildException(e
.getMessage());