+++ /dev/null
-/** @file\r
- GenDepexTask class.\r
-\r
- GenDepexTask is to call GenDepex.exe to generate depex section.\r
- \r
- Copyright (c) 2006, Intel Corporation\r
- All rights reserved. This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
- \r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
- **/\r
-package org.tianocore.framework.tasks;\r
-\r
-import java.io.File;\r
-\r
-import org.apache.tools.ant.BuildException;\r
-import org.apache.tools.ant.Project;\r
-import org.apache.tools.ant.Task;\r
-import org.apache.tools.ant.taskdefs.Execute;\r
-import org.apache.tools.ant.taskdefs.LogStreamHandler;\r
-import org.apache.tools.ant.types.Commandline;\r
-\r
-import org.tianocore.common.logger.EdkLog;\r
-\r
-/**\r
- GenDepexTask\r
- \r
- GenDepexTask is to call GenDepex.exe to generate depex section.\r
-\r
-**/\r
-public class GenDepexTask extends Task implements EfiDefine {\r
- private static String toolName = "GenDepex";\r
- //\r
- // output binary dependency files name\r
- //\r
- private FileArg outputFile = new FileArg();\r
- //\r
- // input pre-processed dependency text files name\r
- //\r
- private FileArg inputFile = new FileArg();\r
- //\r
- // padding integer value\r
- //\r
- private ToolArg padding = new FileArg();\r
- /**\r
- execute\r
- \r
- GenDepexTask execute is to assemble tool command line & execute tool\r
- command line.\r
- */\r
- public void execute() throws BuildException {\r
-\r
- Project project = this.getOwningTarget().getProject();\r
- //\r
- // absolute path of edk tools\r
- //\r
- String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");\r
- String command;\r
- if (path == null) {\r
- command = toolName;\r
- } else {\r
- command = path + File.separator + toolName;\r
- }\r
- //\r
- // argument of GenDepex tool\r
- //\r
- String argument = "" + inputFile + outputFile + padding;\r
- //\r
- // reture value of GenDepex execution\r
- //\r
- int returnVal = -1;\r
-\r
- try {\r
- Commandline commandLine = new Commandline();\r
- commandLine.setExecutable(command);\r
- commandLine.createArgument().setLine(argument);\r
-\r
- LogStreamHandler streamHandler = new LogStreamHandler(this,\r
- Project.MSG_INFO, Project.MSG_WARN);\r
-\r
- Execute runner = new Execute(streamHandler, null);\r
- runner.setAntRun(project);\r
- runner.setCommandline(commandLine.getCommandline());\r
-\r
- EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(commandLine.getCommandline()));\r
- EdkLog.log(this, inputFile.toFileList() + " => " + outputFile.toFileList());\r
-\r
- returnVal = runner.execute();\r
- if (EFI_SUCCESS == returnVal) {\r
- EdkLog.log(this, EdkLog.EDK_VERBOSE, "GenDepex succeeded!");\r
- } else {\r
- //\r
- // command execution fail\r
- //\r
- EdkLog.log(this, "ERROR = " + Integer.toHexString(returnVal));\r
- throw new BuildException("GenDepex failed!");\r
- }\r
- } catch (Exception e) {\r
- throw new BuildException(e.getMessage());\r
- }\r
- }\r
-\r
- /**\r
- setOutputFile\r
- \r
- This function is to set class member "outputFile"\r
- @param outputFileName name of output file\r
- **/\r
- public void setOutputFile(String outputFileName) {\r
- this.outputFile.setArg(" -O ", outputFileName);\r
- }\r
-\r
- /**\r
- getOutputFile\r
- \r
- This function is to get class member "outputFile".\r
- \r
- @return name of ouput file\r
- **/\r
- public String getOutputFile() {\r
- return this.outputFile.getValue();\r
- }\r
-\r
- /**\r
- setInputFile\r
- \r
- This function is to set class member "inputFile".\r
- @param inputFileName name of inputFile\r
- **/\r
- public void setInputFile(String inputFileName) {\r
- this.inputFile.setArg(" -I ", inputFileName);\r
- }\r
-\r
- /**\r
- getInputFile\r
- \r
- This function is to get class member "inputFile"\r
- @return name of input file\r
- **/\r
- public String getInputFile() {\r
- return this.inputFile.getValue();\r
- }\r
-\r
- /**\r
- setPadding\r
- \r
- This function is to set class member "padding"\r
- @param paddingNum padding value\r
- **/\r
- public void setPadding(String paddingNum) {\r
- this.padding.setArg(" -P ", paddingNum);\r
- }\r
-\r
- /**\r
- getPadding\r
- \r
- This function is to get class member "padding"\r
- @return value of padding\r
- **/\r
- public String getPadding() {\r
- return this.padding.getValue();\r
- }\r
-}\r