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