]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenDepexTask.java
1. Rename PeiCoreLib to PeiServicesLib and rename all the interfaces from PeiCoreXXX...
[mirror_edk2.git] / Tools / Source / FrameworkTasks / org / tianocore / framework / tasks / GenDepexTask.java
CommitLineData
878ddf1f 1/** @file\r
2 GenDepexTask class.\r
3\r
4 GenDepexTask is to call GenDepex.exe to generate depex section.\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
16package org.tianocore.framework.tasks;\r
17import org.apache.tools.ant.BuildException;\r
18import org.apache.tools.ant.Project;\r
19import org.apache.tools.ant.Task;\r
20import org.apache.tools.ant.taskdefs.Execute;\r
21import org.apache.tools.ant.taskdefs.LogStreamHandler;\r
22import org.apache.tools.ant.types.Commandline;\r
23/**\r
24 GenDepexTask\r
25 \r
26 GenDepexTask is to call GenDepex.exe to generate depex section.\r
27\r
28**/\r
29public class GenDepexTask extends Task implements EfiDefine {\r
30 ///\r
31 /// output binary dependency files name\r
32 ///\r
33 private String outputFile = "";\r
34 ///\r
35 /// input pre-processed dependency text files name\r
36 ///\r
37 private String inputFile = "";\r
38 ///\r
39 /// padding integer value\r
40 ///\r
41 private String padding = "";\r
42 /**\r
43 execute\r
44 \r
45 GenDepexTask execute is to assemble tool command line & execute tool\r
46 command line.\r
47 */\r
48 public void execute() throws BuildException {\r
49\r
50 Project project = this.getOwningTarget().getProject();\r
51 //\r
52 // absolute path of edk tools\r
53 //\r
54 String path = project.getProperty("env.Framework_Tools_Path");\r
55 String command;\r
56 if (path == null) {\r
6959ee43 57 command = "GenDepex";\r
878ddf1f 58 } else {\r
6959ee43 59 command = path + "/" + "GenDepex";\r
878ddf1f 60 }\r
61 //\r
62 // argument of GenDepex tool\r
63 //\r
64 String argument = inputFile + outputFile + padding;\r
65 //\r
66 // reture value of GenDepex execution\r
67 //\r
68 int returnVal = -1;\r
69\r
70 try {\r
71 Commandline commandLine = new Commandline();\r
72 commandLine.setExecutable(command);\r
73 commandLine.createArgument().setLine(argument);\r
74\r
75 LogStreamHandler streamHandler = new LogStreamHandler(this,\r
76 Project.MSG_INFO, Project.MSG_WARN);\r
77\r
78 Execute runner = new Execute(streamHandler, null);\r
79 runner.setAntRun(project);\r
80 runner.setCommandline(commandLine.getCommandline());\r
81\r
82 System.out.println(Commandline.toString(commandLine\r
83 .getCommandline()));\r
84\r
85 returnVal = runner.execute();\r
86 if (EFI_SUCCESS == returnVal) {\r
87 //\r
88 // command execution success\r
89 //\r
ba40a584 90 System.out.println("GenDepex execute succeeded!");\r
878ddf1f 91\r
92 } else {\r
93 //\r
94 // command execution fail\r
95 //\r
96 System.out.println("GenDepex failed. (error="\r
97 + Integer.toHexString(returnVal) + ")");\r
98 throw new BuildException("GenDepex failed. (error="\r
99 + Integer.toHexString(returnVal) + ")");\r
100 }\r
101 } catch (Exception e) {\r
102 throw new BuildException(e.getMessage());\r
103 }\r
104 }\r
105\r
106 /**\r
107 setOutputFile\r
108 \r
109 This function is to set class member "outputFile"\r
110 @param outputFileName name of output file\r
111 **/\r
112 public void setOutputFile(String outputFileName) {\r
113 this.outputFile = " -O " + outputFileName;\r
114 }\r
115\r
116 /**\r
117 getOutputFile\r
118 \r
119 This function is to get class member "outputFile".\r
120 \r
121 @return name of ouput file\r
122 **/\r
123 public String getOutputFile() {\r
124 return this.outputFile;\r
125 }\r
126\r
127 /**\r
128 setInputFile\r
129 \r
130 This function is to set class member "inputFile".\r
131 @param inputFileName name of inputFile\r
132 **/\r
133 public void setInputFile(String inputFileName) {\r
134 this.inputFile = " -I " + inputFileName;\r
135 }\r
136\r
137 /**\r
138 getInputFile\r
139 \r
140 This function is to get class member "inputFile"\r
141 @return name of input file\r
142 **/\r
143 public String getInputFile() {\r
144 return this.inputFile;\r
145 }\r
146\r
147 /**\r
148 setPadding\r
149 \r
150 This function is to set class member "padding"\r
151 @param paddingNum padding value\r
152 **/\r
153 public void setPadding(String paddingNum) {\r
154 this.padding = " -P " + paddingNum;\r
155 }\r
156\r
157 /**\r
158 getPadding\r
159 \r
160 This function is to get class member "padding"\r
161 @return value of padding\r
162 **/\r
163 public String getPadding() {\r
164 return this.padding;\r
165 }\r
ba40a584 166}\r