Support two more attribute LIBPATH and INCLUDEPATH in tools_def file.
authorwuyizhong <wuyizhong@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 16 Oct 2006 09:24:08 +0000 (09:24 +0000)
committerwuyizhong <wuyizhong@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 16 Oct 2006 09:24:08 +0000 (09:24 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1761 6f19259b-4bc3-4df7-8a09-765794883524

Tools/Java/Source/Cpptasks/net/sf/antcontrib/cpptasks/userdefine/CommandLineUserDefine.java
Tools/Java/Source/GenBuild/org/tianocore/build/GenBuildTask.java

index f9177cf..3ed6c96 100644 (file)
@@ -45,8 +45,6 @@ public class CommandLineUserDefine {
 \r
     String outputDelimiter = null;\r
     \r
-    private static String pathName = null;\r
-    \r
     public void command(CCTask cctask, UserDefineDef userdefine) {\r
         boolean isGccCommand = userdefine.getFamily().equalsIgnoreCase("GCC");\r
         File workdir;\r
@@ -222,30 +220,48 @@ public class CommandLineUserDefine {
 \r
         Environment newEnv = new Environment();\r
         \r
+        //\r
+        // Prepare for environment variable PATH\r
+        //\r
         if (userdefine.getDpath() != null && userdefine.getDpath().trim().length() != 0) {\r
-            String existPath = System.getenv(getPathName("PATH"));\r
+            String pathName = getPathName("PATH");\r
+            String existPath = System.getenv(pathName);\r
             \r
             Variable var = new Variable();\r
-            var.setKey(getPathName("PATH"));\r
+            var.setKey(pathName);\r
             var.setPath(new Path(project, userdefine.getDpath() + ";" + existPath));\r
             newEnv.addVariable(var);\r
         }\r
         \r
+        //\r
+        // Prepare for environment variable LIB\r
+        //\r
         if (userdefine.getLibpath() != null && userdefine.getLibpath().trim().length() != 0) {\r
-            String existPath = System.getenv(getPathName("LIB"));\r
-            \r
+            String pathName = getPathName("LIB");\r
+            String existPath = System.getenv(pathName);\r
             Variable var = new Variable();\r
-            var.setKey(getPathName("LIB"));\r
-            var.setPath(new Path(project, userdefine.getLibpath() + ";" + existPath));\r
+            var.setKey(pathName);\r
+            if (existPath == null) {\r
+                var.setPath(new Path(project, userdefine.getLibpath()));\r
+            } else {\r
+                var.setPath(new Path(project, userdefine.getLibpath() + ";" + existPath));\r
+            }\r
             newEnv.addVariable(var);\r
         }\r
         \r
+        //\r
+        // Prepare for environment variable INCLUDE\r
+        //\r
         if (userdefine.getInclude() != null && userdefine.getInclude().trim().length() != 0) {\r
-            String existPath = System.getenv(getPathName("INCLUDE"));\r
-            \r
+            String pathName = getPathName("INCLUDE");\r
+            String existPath = System.getenv(pathName);\r
             Variable var = new Variable();\r
-            var.setKey(getPathName("INCLUDE"));\r
-            var.setPath(new Path(project, userdefine.getInclude() + ";" + existPath));\r
+            var.setKey(pathName);\r
+            if (existPath == null) {\r
+                var.setPath(new Path(project, userdefine.getInclude()));\r
+            } else {\r
+                var.setPath(new Path(project, userdefine.getInclude() + ";" + existPath));\r
+            }\r
             newEnv.addVariable(var);\r
         }\r
         \r
@@ -259,19 +275,15 @@ public class CommandLineUserDefine {
     }\r
     \r
     private String getPathName(String variableName) {\r
-        if (pathName != null) {\r
-            return pathName;\r
-        }\r
         Map allEnv = System.getenv();\r
         Iterator iter = allEnv.keySet().iterator();\r
         while (iter.hasNext()) {\r
             String key = (String)iter.next();\r
             if(key.equalsIgnoreCase(variableName)) {\r
-                pathName = key;\r
-                break ;\r
+                return key;\r
             }\r
         }\r
-        return pathName;\r
+        return variableName;\r
     }\r
 \r
     protected int runCommand(CCTask task, File workingDir, String[] cmdline, Environment env)\r
index 7ce975a..9a84717 100644 (file)
@@ -543,6 +543,28 @@ public class GenBuildTask extends Ant {
             } else {\r
                 getProject().setProperty(cmd[m] + "_DPATH", "");\r
             }\r
+            \r
+            //\r
+            // Set CC_LIBPATH\r
+            //\r
+            key[4] = ToolDefinitions.TOOLS_DEF_ATTRIBUTE_LIBPATH;\r
+            String libpath = GlobalData.getCommandSetting(key, fpdModuleId);\r
+            if (libpath != null) {\r
+                getProject().setProperty(cmd[m] + "_LIBPATH", libpath.replaceAll("(\\\\)", "/"));\r
+            } else {\r
+                getProject().setProperty(cmd[m] + "_LIBPATH", "");\r
+            }\r
+            \r
+            //\r
+            // Set CC_INCLUDEPATH\r
+            //\r
+            key[4] = ToolDefinitions.TOOLS_DEF_ATTRIBUTE_INCLUDEPATH;\r
+            String includepath = GlobalData.getCommandSetting(key, fpdModuleId);\r
+            if (dpath != null) {\r
+                getProject().setProperty(cmd[m] + "_INCLUDEPATH", includepath.replaceAll("(\\\\)", "/"));\r
+            } else {\r
+                getProject().setProperty(cmd[m] + "_INCLUDEPATH", "");\r
+            }\r
         }\r
     }\r
 \r