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