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 ", ".");
49 private String dllPath
= "";
52 get class member of createList file
54 @returns file name of createList
56 public boolean getCreateListFile() {
57 return this.createListFile
.getValue().length() > 0;
61 set class member of createList file
63 @param createListFile if createList string equal "on" set '-l' flag
65 public void setCreateListFile(boolean createListFile
) {
67 this.createListFile
.setArg(" -", "l");
74 @returns name of output dir
76 public String
getOutPutDir() {
77 return this.outPutDir
.getValue();
81 set class member of outPutDir
83 @param outPutDir The directory name for ouput file
85 public void setOutPutDir(String outPutDir
) {
86 this.outPutDir
.setArg(" -od ", outPutDir
);
91 get class member of ifrBinFile
93 @return file name of ifrBinFile
95 public boolean getCreateIfrBinFile() {
96 return this.createIfrBinFile
.getValue().length() > 0;
100 set class member of ifrBinFile
102 @param createIfrBinFile The flag to specify if the IFR binary file should
105 public void setCreateIfrBinFile(boolean createIfrBinFile
) {
106 if (createIfrBinFile
) {
107 this.createIfrBinFile
.setArg(" -", "ibin");
112 get class member of vfrFile
114 @returns name of vfrFile
116 public String
getVfrFile() {
117 return this.vfrFile
.getValue();
121 set class member of vfrFile
123 @param vfrFile The name of VFR file
125 public void setVfrFile(String vfrFile
) {
126 this.vfrFile
.setArg(" ", vfrFile
);
130 add includePath in includepath List
132 @param includepath The IncludePath object which represents include path
134 public void addConfiguredIncludepath(IncludePath includepath
){
135 this.includepathList
.insert(includepath
);
139 get class member of processerArg
141 @returns processer argument
143 public String
getProcesserArg() {
144 return this.processerArg
.getValue();
149 set class member of processerArg
151 @param processerArg The processor argument
153 public void setProcesserArg(String processerArg
) {
154 this.processerArg
.setArg(" -ppflag ", processerArg
);
157 public void setDllPath(String dllPath
) {
158 this.dllPath
= dllPath
;
162 The standard execute method of ANT task.
164 public void execute() throws BuildException
{
165 Project project
= this.getProject();
166 String toolPath
= project
.getProperty("env.FRAMEWORK_TOOLS_PATH");
168 if (toolPath
== null) {
171 command
= toolPath
+ File
.separator
+ toolName
;
174 String argument
= "" + createIfrBinFile
182 /// constructs the command-line
184 Commandline commandLine
= new Commandline();
185 commandLine
.setExecutable(command
);
186 commandLine
.createArgument().setLine(argument
);
189 /// configures the Execute object
191 LogStreamHandler streamHandler
= new LogStreamHandler(this,
195 Execute runner
= new Execute(streamHandler
,null);
196 runner
.setAntRun(project
);
197 runner
.setCommandline(commandLine
.getCommandline());
198 runner
.setWorkingDirectory(new File(outPutDir
.getValue()));
199 runner
.setEnvironment(new String
[]{"PATH", dllPath
});
201 EdkLog
.log(this, EdkLog
.EDK_VERBOSE
, Commandline
.toString(commandLine
.getCommandline()));
202 EdkLog
.log(this, vfrFile
.toFileList());
204 int returnVal
= runner
.execute();
205 if (EFI_SUCCESS
== returnVal
) {
206 EdkLog
.log(this, EdkLog
.EDK_VERBOSE
, "VfrCompile succeeded!");
208 EdkLog
.log(this, "ERROR = " + Integer
.toHexString(returnVal
));
209 throw new BuildException("VfrCompile failed!");
211 } catch (IOException e
) {
212 throw new BuildException(e
.getMessage());