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