]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/EfiCompressTask.java
Remove dependence check of FD upon FlashMap.fdf
[mirror_edk2.git] / Tools / Source / FrameworkTasks / org / tianocore / framework / tasks / EfiCompressTask.java
index 0ee1c10b9423b58b7148899f0b37c5eb72d75556..1ffd61f0158303ffa4cb8ecc4a78b4c15d8694ca 100644 (file)
@@ -2,14 +2,14 @@
  EfiCompressTask class.\r
 \r
  EfiCompressTask is used to call EfiCompress.exe to strip input file.\r
\r
\r
+\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
+\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
@@ -24,7 +24,8 @@ import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.taskdefs.Execute;\r
 import org.apache.tools.ant.taskdefs.LogStreamHandler;\r
 import org.apache.tools.ant.types.Commandline;\r
-import org.tianocore.logger.EdkLog;\r
+\r
+import org.tianocore.common.logger.EdkLog;\r
 \r
 /**\r
   EfiCompressTask class.\r
@@ -32,38 +33,37 @@ import org.tianocore.logger.EdkLog;
   EfiCompressTask is used to call EfiCompress.exe to strip input file.\r
 **/\r
 public class EfiCompressTask extends Task implements EfiDefine {\r
-    // /\r
-    // / input file\r
-    // /\r
-    private String inputFile = "";\r
-\r
-    // /\r
-    // / output file\r
-    // /\r
-    private String outputFile = "";\r
-\r
-    // /\r
-    // / output directory, this variable is added by jave wrap\r
-    // /\r
-    private String outputDir = "";\r
+    //\r
+    // \r
+    // \r
+    private final static String toolName = "EfiCompress";\r
+    //\r
+    // input file\r
+    //\r
+    private FileArg inputFile = new FileArg();\r
+\r
+    //\r
+    // output file\r
+    //\r
+    private FileArg outputFile = new FileArg();\r
+\r
+    //\r
+    // output directory, this variable is added by jave wrap\r
+    //\r
+    private String outputDir = ".";\r
 \r
     /**\r
-     * execute\r
-     * \r
-     * EfiCompressTask execute function is to assemble tool command line & execute\r
-     * tool command line\r
-     * \r
-     * @throws BuidException\r
-     */\r
+      execute\r
+     \r
+      EfiCompressTask execute function is to assemble tool command line & execute\r
+      tool command line\r
+     \r
+      @throws BuidException\r
+     **/\r
     public void execute() throws BuildException {\r
 \r
         Project project = this.getOwningTarget().getProject();\r
-        //\r
-        // set Logger\r
-        //\r
-        FrameworkLogger logger = new FrameworkLogger(project, "eficompress");\r
-        EdkLog.setLogLevel(project.getProperty("env.LOGLEVEL"));\r
-        EdkLog.setLogger(logger);\r
+\r
         //\r
         // absolute path of efi tools\r
         //\r
@@ -71,20 +71,14 @@ public class EfiCompressTask extends Task implements EfiDefine {
         String command;\r
         String argument;\r
         if (path == null) {\r
-            command = "EfiCompress";\r
+            command = toolName;\r
         } else {\r
-            command = path + File.separatorChar + "EfiCompress";\r
+            command = path + File.separator + toolName;\r
         }\r
         //\r
         // argument of tools\r
         //\r
-        File file = new File(outputFile);\r
-        if (!file.isAbsolute() && (!this.outputDir.equalsIgnoreCase(""))) {\r
-            argument = inputFile + " " + outputDir + File.separatorChar\r
-                    + outputFile;\r
-        } else {\r
-            argument = inputFile + " " + outputFile;\r
-        }\r
+        argument = "" + inputFile + outputFile;\r
         //\r
         // return value of fwimage execution\r
         //\r
@@ -101,26 +95,27 @@ public class EfiCompressTask extends Task implements EfiDefine {
 \r
             runner.setAntRun(project);\r
             runner.setCommandline(cmdline.getCommandline());\r
+            runner.setWorkingDirectory(new File(outputDir));\r
+\r
             //\r
             // Set debug log information.\r
             //\r
-            EdkLog.log(EdkLog.EDK_INFO, Commandline.toString(cmdline.getCommandline()));\r
-            \r
+            EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));\r
+            EdkLog.log(this, EdkLog.EDK_INFO, this.inputFile.toFileList() + " => "\r
+                                              + this.outputFile.toFileList());\r
+\r
             revl = runner.execute();\r
-            \r
             if (EFI_SUCCESS == revl) {\r
                 //\r
                 // command execution success\r
                 //\r
-                EdkLog.log(EdkLog.EDK_INFO,"EfiCompress succeeded!");\r
+                EdkLog.log(this, EdkLog.EDK_VERBOSE, toolName + " succeeded!");\r
             } else {\r
                 //\r
                 // command execution fail\r
                 //\r
-                EdkLog.log(EdkLog.EDK_ERROR, "EfiCompress failed. (error="\r
-                        + Integer.toHexString(revl) + ")");\r
-                throw new BuildException("Strip failed. (error="\r
-                        + Integer.toHexString(revl) + ")");\r
+                EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));\r
+                throw new BuildException(toolName + " failed!");\r
 \r
             }\r
         } catch (Exception e) {\r
@@ -129,70 +124,70 @@ public class EfiCompressTask extends Task implements EfiDefine {
     }\r
 \r
     /**\r
-     * getInputFile\r
-     * \r
-     * This function is to get class member "inputFile".\r
-     * \r
-     * @return string of input file name.\r
-     */\r
+      getInputFile\r
+     \r
+      This function is to get class member "inputFile".\r
+     \r
+      @return string of input file name.\r
+     **/\r
     public String getInputFile() {\r
-        return inputFile;\r
+        return inputFile.getValue();\r
     }\r
 \r
     /**\r
-     * setComponentType\r
-     * \r
-     * This function is to set class member "inputFile".\r
-     * \r
-     * @param inputFile\r
-     *            string of input file name.\r
-     */\r
+      setComponentType\r
+     \r
+      This function is to set class member "inputFile".\r
+     \r
+      @param inputFile\r
+                 string of input file name.\r
+     **/\r
     public void setInputFile(String inputFile) {\r
-        this.inputFile = inputFile;\r
+        this.inputFile.setArg(" ", inputFile);\r
     }\r
 \r
     /**\r
-     * getOutputFile\r
-     * \r
-     * This function is to get class member "outputFile"\r
-     * \r
-     * @return outputFile string of output file name.\r
-     */\r
+      getOutputFile\r
+     \r
+      This function is to get class member "outputFile"\r
+     \r
+      @return outputFile string of output file name.\r
+     **/\r
     public String getOutputFile() {\r
-        return outputFile;\r
+        return outputFile.getValue();\r
     }\r
 \r
     /**\r
-     * setOutputFile\r
-     * \r
-     * This function is to set class member "outputFile"\r
-     * \r
-     * @param outputFile\r
-     *            string of output file name.\r
-     */\r
+      setOutputFile\r
+     \r
+      This function is to set class member "outputFile"\r
+     \r
+      @param outputFile\r
+                 string of output file name.\r
+     **/\r
     public void setOutputFile(String outputFile) {\r
-        this.outputFile = outputFile;\r
+        this.outputFile.setArg(" ", outputFile);\r
     }\r
 \r
     /**\r
-     * getOutputDir\r
-     * \r
-     * This function is to get class member "outputDir"\r
-     * \r
-     * @return outputDir string of output directory.\r
-     */\r
+      getOutputDir\r
+     \r
+      This function is to get class member "outputDir"\r
+     \r
+      @return outputDir string of output directory.\r
+     **/\r
     public String getOutputDir() {\r
         return outputDir;\r
     }\r
 \r
     /**\r
-     * setOutputDir\r
-     * \r
-     * This function is to set class member "outputDir"\r
-     * \r
-     * @param outputDir\r
-     *            string of output directory.\r
-     */\r
+      setOutputDir\r
+     \r
+      This function is to set class member "outputDir"\r
+     \r
+      @param outputDir\r
+                 string of output directory.\r
+     **/\r
     public void setOutputDir(String outputDir) {\r
         this.outputDir = outputDir;\r
     }\r