Fix the EDKT414, the old value should be replaced with new value.
authorjjin9 <jjin9@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 17 Oct 2006 08:29:13 +0000 (08:29 +0000)
committerjjin9 <jjin9@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 17 Oct 2006 08:29:13 +0000 (08:29 +0000)
Another modification,
For some settings, there are one and only one valid value, such as ACTIVE_PLATFORM and TOOL_CHAIN_CONF. Add a protection to ensure the valid number of these setting in this version.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1774 6f19259b-4bc3-4df7-8a09-765794883524

Tools/Java/Source/ContextTool/org/tianocore/context/ParseParameter.java
Tools/Java/Source/ContextTool/org/tianocore/context/TargetFile.java

index 8f1c8b2f779a666e611532311d9557a99837b97d..6b210ec1af265a27fef5c4dd8fc2e60ba1b0b493 100644 (file)
@@ -83,25 +83,26 @@ public class ParseParameter {
                     return 1;\r
                 }\r
                 //\r
-                //argstr is "-p ?", display possible setting\r
+                //argstr is "-p ? ", display possible setting\r
                 //\r
                 if(argstr.length() < 6 && argstr.charAt(3) == '?'){\r
                     System.out.printf( "%s\n", "assign the platform FPD file's relative path to WORKSPACE" );\r
                     return 2;\r
                 }\r
                 //\r
-                //argstr is "-p 0", clean current setting\r
+                //argstr is "-p 0 ", clean current setting\r
                 //\r
                 if(argstr.length() < 6 && argstr.charAt(3) == '0'){\r
                     curpstr = pstr;\r
                     npflag = true;\r
                     continue;\r
                 }\r
-                if(curpstr == null){\r
-                    curpstr = pstr.concat(argstr.substring(2));\r
-                }else{\r
-                    curpstr = mergeSetting(curpstr, argstr);\r
+                String[] S = argstr.split(" ");\r
+                if(S.length > 2){\r
+                    System.out.printf( "%s\n", "The number of ACTIVE_PLATFORM can not more than 1.");\r
+                    return 3;\r
                 }\r
+                curpstr = pstr.concat(argstr.substring(2));\r
                 npflag = true;\r
             } else if (argstr.charAt(1) == 't') {\r
                 if(argstr.length() < 4 && argstr.charAt(2) == ' '){\r
@@ -117,11 +118,7 @@ public class ParseParameter {
                     ntflag = true;\r
                     continue;\r
                 }\r
-                if(curtstr == null){\r
-                    curtstr = tstr.concat(argstr.substring(2));\r
-                }else{\r
-                    curtstr = mergeSetting(curtstr, argstr);\r
-                }\r
+                curtstr = tstr.concat(argstr.substring(2));\r
                 ntflag = true;\r
             } else if (argstr.charAt(1) == 'a') {\r
                 if(argstr.length() < 4 && argstr.charAt(2) == ' '){\r
@@ -137,11 +134,7 @@ public class ParseParameter {
                     naflag = true;\r
                     continue;\r
                 }\r
-                if(curastr == null){\r
-                    curastr = astr.concat(argstr.substring(2));\r
-                }else{\r
-                    curastr = mergeSetting(curastr, argstr);\r
-                }\r
+                curastr = astr.concat(argstr.substring(2));\r
                 naflag = true;\r
             } else if (argstr.charAt(1) == 'c') {\r
                 if(argstr.length() < 4 && argstr.charAt(2) == ' '){\r
@@ -157,11 +150,12 @@ public class ParseParameter {
                     ncflag = true;\r
                     continue;\r
                 }\r
-                if(curcstr == null){\r
-                    curcstr = pstr.concat(argstr.substring(2));\r
-                }else{\r
-                    curcstr = mergeSetting(curcstr, argstr);\r
+                String[] S = argstr.split(" ");\r
+                if(S.length > 2){\r
+                    System.out.printf( "%s\n", "The number of TOOL_CHAIN_CONF can not more than 1.");\r
+                    return 3;\r
                 }\r
+                curcstr = cstr.concat(argstr.substring(2));\r
                 ncflag = true;\r
             } else if (argstr.charAt(1) == 'n') {\r
                 if(argstr.length() < 4 && argstr.charAt(2) == ' '){\r
@@ -177,11 +171,7 @@ public class ParseParameter {
                     nnflag = true;\r
                     continue;\r
                 }\r
-                if(curnstr == null){\r
-                    curnstr = nstr.concat(argstr.substring(2));\r
-                }else{\r
-                    curnstr = mergeSetting(curnstr, argstr);\r
-                }\r
+                curnstr = nstr.concat(argstr.substring(2));\r
                 nnflag = true;\r
             } else if (argstr.charAt(1) == 'm') {\r
                 if(argstr.length() < 4 && argstr.charAt(2) == ' '){\r
@@ -192,6 +182,11 @@ public class ParseParameter {
                     System.out.printf( "%s\n", "The number of concurrent threads. Default is 2. Recommend to set this value to one more than the number of your compurter cores or CPUs." );\r
                     return 2;\r
                 }\r
+                String[] S = argstr.split(" ");\r
+                if(S.length > 2){\r
+                    System.out.printf( "%s\n", "The format of number is wrong.");\r
+                    return 3;\r
+                }\r
                 mstr += argstr.substring(2);\r
                 curmstr = mstr;\r
                 nmflag = true;\r
@@ -207,31 +202,60 @@ public class ParseParameter {
         }\r
         return 0;\r
     }\r
-    \r
-    \r
-    public static String mergeSetting( String S1, String S2){\r
-        \r
-        String[] S = S2.split(" ");\r
 \r
-        for(int i = 1; i < S.length; i++){\r
-            if(S1.contains(S[i]) == false){\r
-                S1 = S1.concat(" ").concat(S[i]);\r
-            }\r
-        }\r
-        \r
-        return S1;\r
-    }\r
     \r
     public static boolean outputCurSetting(){\r
         \r
         System.out.printf( "%s\n", "The current setting is:" );\r
-        System.out.printf( "%s\n", curpstr );\r
-        System.out.printf( "%s\n", curtstr );\r
-        System.out.printf( "%s\n", curastr );\r
-        System.out.printf( "%s\n", curcstr );\r
-        System.out.printf( "%s\n", curnstr );\r
-        System.out.printf( "%s\n", curmstr );\r
-        System.out.printf( "%s\n", curmestr );\r
+        \r
+        if(curpstr != null){\r
+            System.out.printf( "%s\n", curpstr );\r
+        }\r
+        else{\r
+            System.out.printf( "%s\n", pstr );\r
+        }\r
+        \r
+        if(curtstr != null){\r
+            System.out.printf( "%s\n", curtstr );\r
+        }\r
+        else{\r
+            System.out.printf( "%s\n", tstr );\r
+        }\r
+        \r
+        if(curastr != null){\r
+            System.out.printf( "%s\n", curastr );\r
+        }\r
+        else{\r
+            System.out.printf( "%s\n", astr );\r
+        }\r
+        \r
+        if(curcstr != null){\r
+            System.out.printf( "%s\n", curcstr );\r
+        }\r
+        else{\r
+            System.out.printf( "%s\n", cstr );\r
+        }\r
+        \r
+        if(curnstr != null){\r
+            System.out.printf( "%s\n", curnstr );\r
+        }\r
+        else{\r
+            System.out.printf( "%s\n", nstr );\r
+        }\r
+        \r
+        if(curmstr != null){\r
+            System.out.printf( "%s\n", curmstr );\r
+        }\r
+        else{\r
+            System.out.printf( "%s\n", mstr );\r
+        }\r
+        \r
+        if(curmstr != null){\r
+            System.out.printf( "%s\n", curmestr );\r
+        }\r
+        else{\r
+            System.out.printf( "%s\n", mestr );\r
+        }\r
         \r
         return true;\r
     }\r
index 76c4b183d6174215c76aeba41a41ef60f6a1a975..06a031c8bb736fd01a8c831a68d9b30ba15aee61 100644 (file)
@@ -152,7 +152,7 @@ public class TargetFile {
                     bw.newLine();\r
                 } else {\r
                     //\r
-                    //modify at the first time, and there should be *ACTIVE_PLATFORM*=* in the line\r
+                    //modify at the first time, and there should be "*ACTIVE_PLATFORM*=*" in the line\r
                     //\r
                     if (textLine.indexOf("ACTIVE_PLATFORM") != -1) {\r
                         if(pflag == true){\r
@@ -418,26 +418,6 @@ public class TargetFile {
         return true;\r
     }\r
     \r
-    private static String convertStr(String str){\r
-        String convertStr = null;\r
-        \r
-        if( str.compareTo("-p") == 0 ){\r
-            convertStr =  "ACTIVE_PLATFORM";\r
-        }else if( str.compareTo("-a") == 0){\r
-            convertStr =  "TARGET_ARCH";\r
-        }else if( str.compareTo("-t") == 0){\r
-            convertStr =  "TARGET";\r
-        }else if( str.compareTo("-c") == 0){\r
-            convertStr =  "TOOL_CHAIN_CONF";\r
-        }else if( str.compareTo("-n") == 0){\r
-            convertStr =  "TOOL_CHAIN_TAG";\r
-        }else if( str.compareTo("-m") == 0){\r
-            convertStr =  "MAX_CONCURRENT_THREAD_NUMBER";\r
-        }\r
-        \r
-        return convertStr;\r
-    }\r
-    \r
 \r
     /**\r
      * according to user's input args, write the file directly\r