]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/VfrCompilerTask.java
1) Changed ToolArg class to abstract generic arguments of a tool
[mirror_edk2.git] / Tools / Source / FrameworkTasks / org / tianocore / framework / tasks / VfrCompilerTask.java
index 198ba5eeefe9254c605514eb8c2d51a7fff66183..13b855cdd881038fa46e18b54da15f44c7df82bc 100644 (file)
@@ -25,6 +25,8 @@ import org.apache.tools.ant.taskdefs.Execute;
 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
  VfrcompilerTask Task Class\r
   class member \r
@@ -36,23 +38,22 @@ import org.apache.tools.ant.types.Commandline;
       -includepathList : add IncPath to the search path for VFR included files\r
  **/\r
 public class VfrCompilerTask extends Task implements EfiDefine {\r
-    private String createListFile = "";\r
-    private String outPutDir = "";\r
-    private File outPutFile;\r
-    private String createIfrBinFile = "";\r
-    private String processerArg ="";\r
-    private String vfrFile = "";\r
-    private String vfrFileName = "";\r
+    private static String toolName = "VfrCompile";\r
 \r
-    private List<IncludePath> includepathList = new ArrayList<IncludePath>();\r
+    private ToolArg createListFile = new ToolArg();\r
+    private ToolArg createIfrBinFile = new ToolArg();\r
+    private ToolArg processerArg = new ToolArg();\r
+    private FileArg vfrFile = new FileArg();\r
+    private IncludePath includepathList = new IncludePath();\r
+    private FileArg outPutDir = new FileArg(" -od ", ".");\r
 \r
     /**\r
      get class member of createList file\r
 \r
      @returns file name of createList\r
      **/\r
-    public String getCreateListFile() {\r
-        return createListFile;\r
+    public boolean getCreateListFile() {\r
+        return this.createListFile.getValue().length() > 0;\r
     }\r
 \r
     /**\r
@@ -60,9 +61,10 @@ public class VfrCompilerTask extends Task implements EfiDefine {
 \r
      @param     createListFile  if createList string equal "on" set '-l' flag\r
      **/\r
-    public void setCreateListFile(String createListFile) {\r
-        if (createListFile.equals("ON")||createListFile.equals("on"))\r
-            this.createListFile = " -l";\r
+    public void setCreateListFile(boolean createListFile) {\r
+        if (createListFile) {\r
+            this.createListFile.setArg(" -", "l");\r
+        }\r
     }\r
 \r
     /**\r
@@ -71,7 +73,7 @@ public class VfrCompilerTask extends Task implements EfiDefine {
      @returns name of output dir\r
      **/\r
     public String getOutPutDir() {\r
-        return outPutDir;\r
+        return this.outPutDir.getValue();\r
     }\r
 \r
     /**\r
@@ -80,10 +82,7 @@ public class VfrCompilerTask extends Task implements EfiDefine {
      @param     outPutDir   The directory name for ouput file\r
      **/\r
     public void setOutPutDir(String outPutDir) {\r
-        if (outPutDir != null) {\r
-            outPutFile = new File(outPutDir);\r
-        }\r
-        this.outPutDir = " -od " + outPutDir;\r
+        this.outPutDir.setArg(" -od ", outPutDir);\r
     }\r
 \r
 \r
@@ -92,8 +91,8 @@ public class VfrCompilerTask extends Task implements EfiDefine {
 \r
      @return file name of ifrBinFile\r
      **/\r
-    public String getCreateIfrBinFile() {\r
-        return createIfrBinFile;\r
+    public boolean getCreateIfrBinFile() {\r
+        return this.createIfrBinFile.getValue().length() > 0;\r
     }\r
 \r
     /**\r
@@ -102,9 +101,10 @@ public class VfrCompilerTask extends Task implements EfiDefine {
      @param     createIfrBinFile    The flag to specify if the IFR binary file should\r
                                     be generated or not\r
      */\r
-    public void setCreateIfrBinFile(String createIfrBinFile) {\r
-        if (createIfrBinFile.equals("ON") || createIfrBinFile.equals("on"));\r
-        this.createIfrBinFile = " -ibin";\r
+    public void setCreateIfrBinFile(boolean createIfrBinFile) {\r
+        if (createIfrBinFile) {\r
+            this.createIfrBinFile.setArg(" -", "ibin");\r
+        }\r
     }\r
 \r
     /**\r
@@ -113,7 +113,7 @@ public class VfrCompilerTask extends Task implements EfiDefine {
      @returns name of vfrFile\r
      **/\r
     public String getVfrFile() {\r
-        return vfrFile;\r
+        return this.vfrFile.getValue();\r
     }\r
 \r
     /**\r
@@ -122,8 +122,7 @@ public class VfrCompilerTask extends Task implements EfiDefine {
      @param     vfrFile The name of VFR file\r
      **/\r
     public void setVfrFile(String vfrFile) {\r
-        this.vfrFileName = (new File(vfrFile)).getName();\r
-        this.vfrFile = " " + vfrFile;\r
+        this.vfrFile.setArg(" ", vfrFile);\r
     }\r
 \r
     /**\r
@@ -131,18 +130,17 @@ public class VfrCompilerTask extends Task implements EfiDefine {
 \r
      @param     includepath The IncludePath object which represents include path\r
      **/\r
-    public void addIncludepath(IncludePath includepath){\r
-        includepathList.add(includepath);\r
+    public void addConfiguredIncludepath(IncludePath includepath){\r
+        this.includepathList.insert(includepath);\r
     }\r
 \r
-\r
     /**\r
      get class member of processerArg\r
 \r
      @returns processer argument\r
      **/\r
     public String getProcesserArg() {\r
-        return processerArg;\r
+        return this.processerArg.getValue();\r
     }\r
 \r
 \r
@@ -152,7 +150,7 @@ public class VfrCompilerTask extends Task implements EfiDefine {
      @param     processerArg    The processor argument\r
      */\r
     public void setProcesserArg(String processerArg) {\r
-        this.processerArg = " -ppflag " + processerArg;\r
+        this.processerArg.setArg(" -ppflag ", processerArg);\r
     }\r
 \r
     /**\r
@@ -163,23 +161,17 @@ public class VfrCompilerTask extends Task implements EfiDefine {
         String  toolPath= project.getProperty("env.FRAMEWORK_TOOLS_PATH");\r
         String  command;\r
         if (toolPath == null) {\r
-            command = "VfrCompile";\r
+            command = toolName;\r
         } else {\r
-            command = toolPath + "/" + "VfrCompile";\r
+            command = toolPath + File.separator + toolName;\r
         }\r
-        String incPath = "";        \r
 \r
-        int count = includepathList.size();    \r
-        for (int i = 0; i < count; i++) {\r
-            incPath += includepathList.get(i).toString();\r
-        }\r
-\r
-        String argument = this.createIfrBinFile +\r
-                          this.processerArg + \r
-                          incPath +\r
-                          this.outPutDir + \r
-                          this.createListFile +\r
-                          this.vfrFile ;\r
+        String argument = "" + createIfrBinFile\r
+                             + processerArg  \r
+                             + includepathList\r
+                             + outPutDir\r
+                             + createListFile\r
+                             + vfrFile;\r
         try {\r
             ///\r
             /// constructs the command-line\r
@@ -196,21 +188,18 @@ public class VfrCompilerTask extends Task implements EfiDefine {
                                                                   Project.MSG_WARN);\r
 \r
             Execute runner = new Execute(streamHandler,null);\r
-            runner.setAntRun(project);\r
-            \r
+            runner.setAntRun(project);            \r
             runner.setCommandline(commandLine.getCommandline());\r
+            runner.setWorkingDirectory(new File(outPutDir.getValue())); \r
             \r
-            if (outPutFile != null && outPutFile.exists()) {\r
-                runner.setWorkingDirectory(outPutFile); \r
-            }\r
+            EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(commandLine.getCommandline()));\r
+            EdkLog.log(this, vfrFile.toFileList());\r
 \r
-            log(Commandline.toString(commandLine.getCommandline()), Project.MSG_VERBOSE);\r
-            log(vfrFileName);\r
             int returnVal = runner.execute();\r
             if (EFI_SUCCESS == returnVal) {\r
-                log("VfrCompile succeeded!", Project.MSG_VERBOSE);\r
+                EdkLog.log(this, EdkLog.EDK_VERBOSE, "VfrCompile succeeded!");\r
             } else {\r
-                log("ERROR = " + Integer.toHexString(returnVal));\r
+                EdkLog.log(this, "ERROR = " + Integer.toHexString(returnVal));\r
                 throw new BuildException("VfrCompile failed!");\r
             }\r
         } catch (IOException e) {\r