]>
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 | |
17 | import java.io.File;\r | |
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 | |
37 | ///\r | |
38 | /// The target architecture.\r | |
39 | ///\r | |
40 | private String arch="";\r | |
41 | \r | |
42 | /**\r | |
43 | execute\r | |
44 | \r | |
45 | GenFvImageTask execute is to assemble tool command line & execute tool\r | |
46 | command line.\r | |
47 | **/\r | |
48 | public void execute() throws BuildException {\r | |
49 | Project project = this.getOwningTarget().getProject();\r | |
50 | String path = project.getProperty("env.Framework_Tools_Path");\r | |
51 | String command = "";\r | |
52 | \r | |
53 | if (path == null){\r | |
54 | path = "";\r | |
55 | }else {\r | |
56 | path = path + File.separatorChar;\r | |
57 | }\r | |
58 | \r | |
59 | if (arch.equalsIgnoreCase("")){\r | |
60 | command = path + "GenFvImage";\r | |
61 | }\r | |
62 | if (arch.equalsIgnoreCase("ia32")){\r | |
63 | command = path + "GenFvImage_IA32";\r | |
64 | } \r | |
65 | if (arch.equalsIgnoreCase("x64")){\r | |
66 | command = path + "GenFvImage_X64";\r | |
67 | }\r | |
68 | if (arch.equalsIgnoreCase("ipf")){\r | |
69 | command = path + "GenFvImage_IPF";\r | |
70 | }\r | |
71 | String argument = infFile;\r | |
72 | \r | |
73 | try {\r | |
74 | \r | |
75 | Commandline commandLine = new Commandline();\r | |
76 | commandLine.setExecutable(command);\r | |
77 | commandLine.createArgument().setLine(argument);\r | |
78 | \r | |
79 | LogStreamHandler streamHandler = new LogStreamHandler(this,\r | |
80 | Project.MSG_INFO,\r | |
81 | Project.MSG_WARN);\r | |
82 | //\r | |
83 | // create a execute object and set it's commandline\r | |
84 | //\r | |
85 | Execute runner = new Execute(streamHandler,null);\r | |
86 | runner.setAntRun(project);\r | |
87 | runner.setCommandline(commandLine.getCommandline()); \r | |
88 | System.out.println(Commandline.toString(commandLine.getCommandline()));\r | |
89 | \r | |
90 | int revl = -1;\r | |
91 | //\r | |
92 | // user execute class call external programs - GenFvImage\r | |
93 | //\r | |
94 | revl = runner.execute();\r | |
95 | // \r | |
96 | // execute command line success!\r | |
97 | //\r | |
98 | if (EFI_SUCCESS == revl){\r | |
99 | System.out.println("GenFvImage succeeded!");\r | |
100 | } else {\r | |
101 | \r | |
102 | // \r | |
103 | // execute command line failed! \r | |
104 | //\r | |
105 | throw new BuildException("GenFvImage failed !(error =" + \r | |
106 | Integer.toHexString(revl) + ")");\r | |
107 | }\r | |
108 | \r | |
109 | } catch (Exception e) {\r | |
110 | System.out.println(e.getMessage());\r | |
111 | } \r | |
112 | }\r | |
113 | /**\r | |
114 | getInfFile\r | |
115 | \r | |
116 | This function is to get class member of infFile\r | |
117 | @return String name of infFile\r | |
118 | **/\r | |
119 | public String getInfFile() {\r | |
120 | return infFile;\r | |
121 | }\r | |
122 | \r | |
123 | /**\r | |
124 | setInfFile\r | |
125 | \r | |
126 | This function is to set class member of infFile.\r | |
127 | \r | |
128 | @param infFile name of infFile\r | |
129 | **/\r | |
130 | public void setInfFile(String infFile) {\r | |
131 | this.infFile = "-I " + infFile;\r | |
132 | }\r | |
133 | \r | |
134 | /**\r | |
135 | getArch\r | |
136 | \r | |
137 | This function is to get class member of arch.\r | |
138 | @return The target architecture.\r | |
139 | **/\r | |
140 | public String getArch() {\r | |
141 | return arch;\r | |
142 | }\r | |
143 | \r | |
144 | /**\r | |
145 | setArch\r | |
146 | \r | |
147 | This function is to set class member of arch. \r | |
148 | \r | |
149 | @param arch The target architecture.\r | |
150 | **/\r | |
151 | public void setArch(String arch) {\r | |
152 | this.arch = arch;\r | |
153 | } \r | |
154 | } |