]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenDepexTask.java
Fix a misspelling.
[mirror_edk2.git] / Tools / Source / FrameworkTasks / org / tianocore / framework / tasks / GenDepexTask.java
1 /** @file
2 GenDepexTask class.
3
4 GenDepexTask is to call GenDepex.exe to generate depex section.
5
6 Copyright (c) 2006, Intel Corporation
7 All rights reserved. This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
11
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14
15 **/
16 package org.tianocore.framework.tasks;
17 import org.apache.tools.ant.BuildException;
18 import org.apache.tools.ant.Project;
19 import org.apache.tools.ant.Task;
20 import org.apache.tools.ant.taskdefs.Execute;
21 import org.apache.tools.ant.taskdefs.LogStreamHandler;
22 import org.apache.tools.ant.types.Commandline;
23 /**
24 GenDepexTask
25
26 GenDepexTask is to call GenDepex.exe to generate depex section.
27
28 **/
29 public class GenDepexTask extends Task implements EfiDefine {
30 ///
31 /// output binary dependency files name
32 ///
33 private String outputFile = "";
34 ///
35 /// input pre-processed dependency text files name
36 ///
37 private String inputFile = "";
38 ///
39 /// padding integer value
40 ///
41 private String padding = "";
42 /**
43 execute
44
45 GenDepexTask execute is to assemble tool command line & execute tool
46 command line.
47 */
48 public void execute() throws BuildException {
49
50 Project project = this.getOwningTarget().getProject();
51 //
52 // absolute path of edk tools
53 //
54 String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");
55 String command;
56 if (path == null) {
57 command = "gendepex";
58 } else {
59 command = path + "/" + "gendepex";
60 }
61 //
62 // argument of GenDepex tool
63 //
64 String argument = inputFile + outputFile + padding;
65 //
66 // reture value of GenDepex execution
67 //
68 int returnVal = -1;
69
70 try {
71 Commandline commandLine = new Commandline();
72 commandLine.setExecutable(command);
73 commandLine.createArgument().setLine(argument);
74
75 LogStreamHandler streamHandler = new LogStreamHandler(this,
76 Project.MSG_INFO, Project.MSG_WARN);
77
78 Execute runner = new Execute(streamHandler, null);
79 runner.setAntRun(project);
80 runner.setCommandline(commandLine.getCommandline());
81
82 System.out.println(Commandline.toString(commandLine
83 .getCommandline()));
84
85 returnVal = runner.execute();
86 if (EFI_SUCCESS == returnVal) {
87 //
88 // command execution success
89 //
90 System.out.println("GenDepex execute succeeded!");
91
92 } else {
93 //
94 // command execution fail
95 //
96 System.out.println("GenDepex failed. (error="
97 + Integer.toHexString(returnVal) + ")");
98 throw new BuildException("GenDepex failed. (error="
99 + Integer.toHexString(returnVal) + ")");
100 }
101 } catch (Exception e) {
102 throw new BuildException(e.getMessage());
103 }
104 }
105
106 /**
107 setOutputFile
108
109 This function is to set class member "outputFile"
110 @param outputFileName name of output file
111 **/
112 public void setOutputFile(String outputFileName) {
113 this.outputFile = " -O " + outputFileName;
114 }
115
116 /**
117 getOutputFile
118
119 This function is to get class member "outputFile".
120
121 @return name of ouput file
122 **/
123 public String getOutputFile() {
124 return this.outputFile;
125 }
126
127 /**
128 setInputFile
129
130 This function is to set class member "inputFile".
131 @param inputFileName name of inputFile
132 **/
133 public void setInputFile(String inputFileName) {
134 this.inputFile = " -I " + inputFileName;
135 }
136
137 /**
138 getInputFile
139
140 This function is to get class member "inputFile"
141 @return name of input file
142 **/
143 public String getInputFile() {
144 return this.inputFile;
145 }
146
147 /**
148 setPadding
149
150 This function is to set class member "padding"
151 @param paddingNum padding value
152 **/
153 public void setPadding(String paddingNum) {
154 this.padding = " -P " + paddingNum;
155 }
156
157 /**
158 getPadding
159
160 This function is to get class member "padding"
161 @return value of padding
162 **/
163 public String getPadding() {
164 return this.padding;
165 }
166 }