]>
Commit | Line | Data |
---|---|---|
878ddf1f | 1 | /** @file\r |
2 | GenFvImageTask class.\r | |
3 | \r | |
4 | GenFvImageTask is to call GenFvImage.exe to generate FvImage.\r | |
5 | \r | |
6 | Copyright (c) 2006, Intel Corporation\r | |
7 | All rights reserved. This program and the accompanying materials\r | |
8 | are licensed and made available under the terms and conditions of the BSD License\r | |
9 | which accompanies this distribution. The full text of the license may be found at\r | |
10 | http://opensource.org/licenses/bsd-license.php\r | |
11 | \r | |
12 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
13 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
14 | \r | |
15 | **/\r | |
16 | package org.tianocore.framework.tasks;\r | |
2da8968b | 17 | import java.io.File;\r |
878ddf1f | 18 | \r |
19 | import org.apache.tools.ant.BuildException;\r | |
20 | import org.apache.tools.ant.Project;\r | |
21 | import org.apache.tools.ant.Task;\r | |
22 | import org.apache.tools.ant.taskdefs.Execute;\r | |
23 | import org.apache.tools.ant.taskdefs.LogStreamHandler;\r | |
24 | import org.apache.tools.ant.types.Commandline;\r | |
25 | \r | |
26 | /**\r | |
27 | GenFvImageTask\r | |
28 | \r | |
29 | GenFvImageTask is to call GenFvImage.exe to generate the FvImage.\r | |
30 | \r | |
31 | **/\r | |
32 | public class GenFvImageTask extends Task implements EfiDefine{\r | |
33 | ///\r | |
34 | /// The name of input inf file\r | |
35 | ///\r | |
36 | private String infFile="";\r | |
2da8968b | 37 | \r |
878ddf1f | 38 | /**\r |
39 | execute\r | |
40 | \r | |
41 | GenFvImageTask execute is to assemble tool command line & execute tool\r | |
42 | command line.\r | |
43 | **/\r | |
44 | public void execute() throws BuildException {\r | |
45 | Project project = this.getOwningTarget().getProject();\r | |
2da8968b | 46 | String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");\r |
47 | String command = "";\r | |
48 | \r | |
49 | if (path == null){\r | |
878ddf1f | 50 | path = "";\r |
2da8968b | 51 | }else {\r |
52 | path = path + File.separatorChar;\r | |
878ddf1f | 53 | }\r |
2da8968b | 54 | \r |
1507f64e | 55 | command = path + "GenFvImage";\r |
8742c000 | 56 | \r |
2da8968b | 57 | String argument = infFile;\r |
58 | \r | |
878ddf1f | 59 | try {\r |
2da8968b | 60 | \r |
61 | Commandline commandLine = new Commandline();\r | |
62 | commandLine.setExecutable(command);\r | |
63 | commandLine.createArgument().setLine(argument);\r | |
64 | \r | |
65 | LogStreamHandler streamHandler = new LogStreamHandler(this,\r | |
66 | Project.MSG_INFO,\r | |
67 | Project.MSG_WARN);\r | |
68 | //\r | |
69 | // create a execute object and set it's commandline\r | |
70 | //\r | |
71 | Execute runner = new Execute(streamHandler,null);\r | |
72 | runner.setAntRun(project);\r | |
73 | runner.setCommandline(commandLine.getCommandline()); \r | |
74 | System.out.println(Commandline.toString(commandLine.getCommandline()));\r | |
75 | \r | |
76 | int revl = -1;\r | |
77 | //\r | |
78 | // user execute class call external programs - GenFvImage\r | |
79 | //\r | |
80 | revl = runner.execute();\r | |
81 | // \r | |
82 | // execute command line success!\r | |
83 | //\r | |
84 | if (EFI_SUCCESS == revl){\r | |
85 | System.out.println("GenFvImage succeeded!");\r | |
878ddf1f | 86 | } else {\r |
2da8968b | 87 | \r |
88 | // \r | |
89 | // execute command line failed! \r | |
90 | //\r | |
91 | throw new BuildException("GenFvImage failed !(error =" + \r | |
92 | Integer.toHexString(revl) + ")");\r | |
878ddf1f | 93 | }\r |
2da8968b | 94 | \r |
878ddf1f | 95 | } catch (Exception e) {\r |
2da8968b | 96 | System.out.println(e.getMessage());\r |
97 | } \r | |
878ddf1f | 98 | }\r |
99 | /**\r | |
100 | getInfFile\r | |
101 | \r | |
102 | This function is to get class member of infFile\r | |
103 | @return String name of infFile\r | |
104 | **/\r | |
105 | public String getInfFile() {\r | |
106 | return infFile;\r | |
107 | }\r | |
108 | \r | |
109 | /**\r | |
110 | setInfFile\r | |
111 | \r | |
112 | This function is to set class member of infFile.\r | |
113 | \r | |
114 | @param infFile name of infFile\r | |
115 | **/\r | |
116 | public void setInfFile(String infFile) {\r | |
2da8968b | 117 | this.infFile = "-I " + infFile;\r |
878ddf1f | 118 | }\r |
119 | \r | |
8742c000 | 120 | }\r |