]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/PeiReBaseTask.java
Changed spelling to manifest
[mirror_edk2.git] / Tools / Source / FrameworkTasks / org / tianocore / framework / tasks / PeiReBaseTask.java
index c033c0d199d881f4a0c2cc33f5c874c303e56281..1f8a4d1f3c899286a0b07d4b3496173994c91ec4 100644 (file)
@@ -2,14 +2,14 @@
  PeiReBaseTask class.\r
 \r
  PeiReBaseTask is used to call PeiReBase.exe to rebase efi fv 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
   PeiReBaseTask class.\r
@@ -32,53 +33,47 @@ import org.tianocore.logger.EdkLog;
   PeiReBaseTask is used to call PeiReBase.exe to rebase efi fv file.\r
 **/\r
 public class PeiReBaseTask extends Task implements EfiDefine {\r
-    ///\r
-    /// tool name\r
-    ///\r
+    //\r
+    // tool name\r
+    //\r
     private String toolName = "PeiReBase";\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
-    /// Base address\r
-    ///\r
-    private String baseAddr = "";\r
-    \r
-    ///\r
-    /// Architecture \r
-    ///\r
-    private String arch = "";\r
-    \r
+    //\r
+    // Input file\r
+    //\r
+    private FileArg inputFile = new FileArg();\r
+    //\r
+    // Output file\r
+    //\r
+    private FileArg outputFile = new FileArg();\r
+    //\r
+    // Base address\r
+    //\r
+    private ToolArg baseAddr = new ToolArg();\r
+    //\r
+    // \r
+    // \r
+    private FileArg mapFile = new FileArg();\r
+    //\r
+    // Architecture\r
+    //\r
+    private String arch = "IA32";\r
+\r
     /**\r
-     * execute\r
-     * \r
-     * PeiReBaseTask execute function is to assemble tool command line & execute\r
-     * tool command line\r
-     * \r
-     * @throws BuidException\r
-     */\r
+      execute\r
+     \r
+      PeiReBaseTask 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
+        if (isUptodate()) {\r
+            EdkLog.log(this, EdkLog.EDK_VERBOSE, outputFile.toFileList() + " is up-to-date!");\r
+            return;\r
+        }\r
 \r
         Project project = this.getOwningTarget().getProject();\r
-        //\r
-        // set Logger\r
-        //\r
-        FrameworkLogger logger = new FrameworkLogger(project, toolName.toLowerCase());\r
-        EdkLog.setLogLevel(project.getProperty("env.LOGLEVEL"));\r
-        EdkLog.setLogger(logger);\r
-        \r
+\r
         //\r
         // absolute path of efi tools\r
         //\r
@@ -87,28 +82,25 @@ public class PeiReBaseTask extends Task implements EfiDefine {
         String argument;\r
         if (this.arch.equalsIgnoreCase("IA32")){\r
             command = toolName + "_IA32";\r
-        }else if (this.arch.equalsIgnoreCase("X64")){\r
+        } else if (this.arch.equalsIgnoreCase("X64")){\r
             command = toolName + "_X64";\r
-        }else if (this.arch.equalsIgnoreCase("IPF")){\r
+        } else if (this.arch.equalsIgnoreCase("IPF")){\r
             command = toolName + "_IPF";\r
-        }else {\r
+        } else {\r
             command = toolName + "_IA32";\r
         }\r
         if (path != null) {\r
-            command = path + File.separatorChar + command;\r
+            command = path + File.separator + command;\r
         }\r
-        \r
+\r
         //\r
         // argument of tools\r
         //\r
-        File file = new File(outputFile);\r
-        if (!file.isAbsolute() && (!this.outputDir.equalsIgnoreCase(""))) {\r
-            argument = inputFile + " " +  "-O " + outputDir + File.separatorChar\r
-                    + outputFile + " " + this.baseAddr;\r
-        } else {\r
-            argument = inputFile + " " + "-O " + outputFile + " " + this.baseAddr;\r
+        if (mapFile.getValue().length() == 0) {\r
+            mapFile.setArg(" -M ", outputFile.getValue() + ".map");\r
         }\r
-        \r
+        argument = "" + inputFile + outputFile + baseAddr + mapFile;\r
+\r
         //\r
         // return value of fwimage execution\r
         //\r
@@ -128,24 +120,24 @@ public class PeiReBaseTask extends Task implements EfiDefine {
             //\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, inputFile.toFileList() + " => " \r
+                                              + outputFile.toFileList()\r
+                                              + mapFile.toFileList());\r
+\r
             revl = runner.execute();\r
-            \r
+\r
             if (EFI_SUCCESS == revl) {\r
                 //\r
                 // command execution success\r
                 //\r
-                EdkLog.log(EdkLog.EDK_INFO,"PeiBase succeeded!");\r
+                EdkLog.log(this, EdkLog.EDK_VERBOSE, "PeiReBase succeeded!");\r
             } else {\r
                 //\r
                 // command execution fail\r
                 //\r
-                EdkLog.log(EdkLog.EDK_ERROR, "PeiBase failed. (error="\r
-                        + Integer.toHexString(revl) + ")");\r
-                throw new BuildException("PeiBase failed. (error="\r
-                        + Integer.toHexString(revl) + ")");\r
-\r
+                EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));\r
+                throw new BuildException("PeiReBase failed!");\r
             }\r
         } catch (Exception e) {\r
             throw new BuildException(e.getMessage());\r
@@ -153,115 +145,124 @@ public class PeiReBaseTask 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 = "-I " + inputFile;\r
+        this.inputFile.setArg(" -I ", 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(" -O ", 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
-    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
-    public void setOutputDir(String outputDir) {\r
-        this.outputDir = outputDir;\r
-    }\r
-\r
-    /**\r
-     * getBaseAddr\r
-     * \r
-     * This function is to get class member "baseAddr"\r
-     * \r
-     * @return baseAddr   string of base address.\r
-     */\r
+      getBaseAddr\r
+     \r
+      This function is to get class member "baseAddr"\r
+     \r
+      @return baseAddr   string of base address.\r
+     **/\r
     public String getBaseAddr() {\r
-        return baseAddr;\r
+        return baseAddr.getValue();\r
     }\r
 \r
     /**\r
-     * setBaseAddr\r
-     * \r
-     * This function is to set class member "baseAddr"\r
-     * \r
-     * @param baseAddr    string of base address\r
-     */\r
+      setBaseAddr\r
+     \r
+      This function is to set class member "baseAddr"\r
+     \r
+      @param baseAddr    string of base address\r
+     **/\r
     public void setBaseAddr(String baseAddr) {\r
-        this.baseAddr = "-B " +  baseAddr;\r
+        this.baseAddr.setArg(" -B ", baseAddr);\r
     }\r
 \r
     /**\r
-     * getArch\r
-     * \r
-     * This function is to get class member "arch".\r
-     * \r
-     * @return arch       Architecture\r
-     */\r
+      getArch\r
+     \r
+      This function is to get class member "arch".\r
+     \r
+      @return arch       Architecture\r
+     **/\r
     public String getArch() {\r
         return arch;\r
     }\r
 \r
     /**\r
-     * setArch\r
-     * \r
-     * This function is to set class member "arch" \r
-     * \r
-     * @param arch         Architecture\r
-     */\r
+      setArch\r
+     \r
+      This function is to set class member "arch"\r
+     \r
+      @param arch         Architecture\r
+     **/\r
     public void setArch(String arch) {\r
         this.arch = arch;\r
     }\r
+\r
+    /**\r
+       Get the value of map file\r
+\r
+       @return String   The map file path\r
+     **/\r
+    public String getMapFile() {\r
+        return mapFile.getValue();\r
+    }\r
+\r
+    /**\r
+       Set "-M MapFile" argument\r
+\r
+       @param mapFile   The path of map file\r
+     **/\r
+    public void setMapFile(String mapFile) {\r
+        this.mapFile.setArg(" -M ", mapFile);\r
+    }\r
+\r
+    //\r
+    // Dependency check\r
+    // \r
+    private boolean isUptodate() {\r
+        File srcFile = new File(inputFile.getValue());\r
+        File dstFile = new File(outputFile.getValue());\r
+\r
+        if (srcFile.lastModified() > dstFile.lastModified()) {\r
+            return false;\r
+        }\r
+\r
+        return true;\r
+    }\r
 }\r