]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/MakeDeps.java
Modify GenFfsTask to make it don't create ORG file.
[mirror_edk2.git] / Tools / Source / FrameworkTasks / org / tianocore / framework / tasks / MakeDeps.java
index c72b1f66728dc0e84db5e766f7320dc9abe1413b..5c4de1a78ef232edfb92b151195f64d845a381ef 100644 (file)
@@ -36,6 +36,8 @@ import org.apache.tools.ant.taskdefs.LogStreamHandler;
 import org.apache.tools.ant.types.Commandline;\r
 import org.apache.tools.ant.types.Path;\r
 \r
+import org.tianocore.common.logger.EdkLog;\r
+\r
 /**\r
  Class MakeDeps is used to wrap MakeDeps.exe as an ANT task.\r
  **/\r
@@ -77,6 +79,10 @@ public class MakeDeps extends Task {
 \r
         Project prj  = this.getOwningTarget().getProject();\r
         String  toolPath = prj.getProperty("env.FRAMEWORK_TOOLS_PATH");\r
+        FrameworkLogger logger = new FrameworkLogger(prj, "makedeps");\r
+        EdkLog.setLogLevel(prj.getProperty("env.LOGLEVEL"));\r
+        EdkLog.setLogger(logger);\r
+\r
         ///\r
         /// compose full tool path\r
         ///\r
@@ -107,7 +113,7 @@ public class MakeDeps extends Task {
 \r
         ///\r
         /// if there's no source files, we can do nothing about dependency\r
-        /// \r
+        ///\r
         if (inputFileList.size() == 0) {\r
             throw new BuildException("No source files specified to scan");\r
         }\r
@@ -118,8 +124,9 @@ public class MakeDeps extends Task {
         Iterator iterator = inputFileList.iterator();\r
         while (iterator.hasNext()) {\r
             Input inputFile = (Input)iterator.next();\r
+            String inputFileString = cleanupPathName(inputFile.getFile());\r
             args.append(" -f ");\r
-            args.append(cleanupPathName(inputFile.getFile()));\r
+            args.append(inputFileString);\r
         }\r
 \r
         ///\r
@@ -165,6 +172,8 @@ public class MakeDeps extends Task {
         runner.setAntRun(prj);\r
         runner.setCommandline(cmd.getCommandline());\r
 \r
+        EdkLog.log(EdkLog.EDK_VERBOSE, Commandline.toString(cmd.getCommandline()));\r
+\r
         int result = 0;\r
         try {\r
             result = runner.execute();\r
@@ -173,13 +182,13 @@ public class MakeDeps extends Task {
         }\r
 \r
         if (result != 0) {\r
-            log ("MakeDeps failed");\r
+            EdkLog.log(EdkLog.EDK_INFO, "MakeDeps failed!");\r
             return;\r
         }\r
 \r
         // change the old DEP file format (makefile compatible) to just file list\r
         if (!cleanup()) {\r
-            throw new BuildException(depsFile + " was not generated");\r
+            throw new BuildException(depsFile + " was not generated!");\r
         }\r
     }\r
 \r
@@ -187,16 +196,10 @@ public class MakeDeps extends Task {
     /// Remove any duplicated path separator or inconsistent path separator\r
     ///\r
     private String cleanupPathName(String path) {\r
-        try {\r
-            path = (new File(path)).getCanonicalPath();\r
-        } catch (IOException e) {\r
-            String separator = "\\" + File.separator;\r
-            String duplicateSeparator = separator + "{2}";\r
-            path = Path.translateFile(path);\r
-            path = path.replaceAll(duplicateSeparator, separator);\r
-            return path;\r
-        }\r
-\r
+        String separator = "\\" + File.separator;\r
+        String duplicateSeparator = separator + "{2}";\r
+        path = Path.translateFile(path);\r
+        path = path.replaceAll(duplicateSeparator, separator);\r
         return path;\r
     }\r
 \r
@@ -352,16 +355,12 @@ public class MakeDeps extends Task {
             //\r
             String line = null;\r
             while ((line = lineReader.readLine()) != null) {\r
-                Pattern pattern = Pattern.compile(target + "[ ]*:[ ]*(.+)");\r
-                Matcher matcher = pattern.matcher(line);\r
-\r
-                while (matcher.find()) {\r
+                String[] filePath = line.split(" : ");\r
+                if (filePath.length == 2) {\r
                     ///\r
                     /// keep the file name after ":"\r
                     ///\r
-                    String filePath = line.substring(matcher.start(1), matcher.end(1));\r
-                    filePath = cleanupPathName(filePath);\r
-                    lineSet.add(filePath);\r
+                    lineSet.add(cleanupPathName(filePath[1]));\r
                 }\r
             }\r
             lineReader.close();\r
@@ -377,7 +376,7 @@ public class MakeDeps extends Task {
 \r
             ///\r
             /// compose the final file content\r
-            /// \r
+            ///\r
             StringBuffer cleanedLines = new StringBuffer(40960);\r
             Iterator<String> it = lineSet.iterator();\r
             while (it.hasNext()) {\r