]> git.proxmox.com Git - mirror_edk2.git/commitdiff
add some features:
authorjjin9 <jjin9@6f19259b-4bc3-4df7-8a09-765794883524>
Sat, 14 Oct 2006 08:22:12 +0000 (08:22 +0000)
committerjjin9 <jjin9@6f19259b-4bc3-4df7-8a09-765794883524>
Sat, 14 Oct 2006 08:22:12 +0000 (08:22 +0000)
1. display current settings in target.txt by ContextTool
2. display help information with arguments, such as: ContextTool -h, arguments include -h, /h, -?, /?, -help, /help
3. display current setting by ContextTool -x
4. display possible setting by ContextTool -x ?
5. clean current setting by ContextTool -x 0
6. merge new setting to current setting by ContextTool -x new
x is the setting argument, such as p, a, n, m, t, c.

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

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

index ec2e5b9996baca4914d29167931fd8ceb5f35bce..7ee7d6c7c962efbc901fb3b3c29ec1031685717f 100644 (file)
@@ -16,11 +16,28 @@ public class ContextMain {
     \r
     public static void main(String[] args) {\r
 \r
     \r
     public static void main(String[] args) {\r
 \r
+        if (TargetFile.validateFilename("target.txt") == false) {\r
+            System.out.printf("%n%s", "Target.txt can't be found in WorkSpace. Please check it!");\r
+            System.exit(0);\r
+        }\r
+        \r
         if(ParseParameter.checkParameter(args) == false){\r
             System.exit(0);\r
         }\r
         if(ParseParameter.checkParameter(args) == false){\r
             System.exit(0);\r
         }\r
-\r
-        if (TargetFile.parsePath("target.txt") == false) {\r
+        \r
+        if (TargetFile.readFile() == false){\r
+            System.exit(0);\r
+        }\r
+        \r
+        if (ParseParameter.standardizeParameter(args) > 0){\r
+            System.exit(0);\r
+        }\r
+        \r
+        if (TargetFile.createTempFile("target.txt") == false){\r
+            System.exit(0);\r
+        }\r
+        \r
+        if (TargetFile.readwriteFile() == false){\r
             System.exit(0);\r
         }\r
         \r
             System.exit(0);\r
         }\r
         \r
index b65ee0a131898de3720a16679a95b489d7a676a0..ca9b099883cbb66a833468d724fbb47b4258a6ac 100644 (file)
@@ -102,7 +102,7 @@ public class HelpInfo {
 \r
     private static final String AString = "-a  <list of Arch>";\r
 \r
 \r
     private static final String AString = "-a  <list of Arch>";\r
 \r
-    private static final String AStringInfo = "what kind of architechure is the binary target, such as IA32, IA64, X64, EBC, or ARM. Multiple values can be specified on a single line, using space to separate the values.";\r
+    private static final String AStringInfo = "What kind of architechure is the binary target, such as IA32, IA64, X64, EBC, or ARM. Multiple values can be specified on a single line, using space to separate the values.";\r
 \r
     private static final String CString = "-c  <tool_definition_file.txt>";\r
 \r
 \r
     private static final String CString = "-c  <tool_definition_file.txt>";\r
 \r
@@ -122,7 +122,7 @@ public class HelpInfo {
 \r
     private static final String MString = "-m  <num of Threads>";\r
     \r
 \r
     private static final String MString = "-m  <num of Threads>";\r
     \r
-    private static final String MStringInfo = "number should GE 0. 0 clears both MULTIPLE_THREAD and MAX_CONCURRENT_THREAD_NUMBER, others enable MULTIPLE_THREAD and set MAX_CONCURRENT_THREAD_NUMBER.";\r
+    private static final String MStringInfo = "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. 0 will disable MULTIPLE_THREAD and clean MAX_CONCURRENT_THREAD_NUMBER.";\r
     \r
     private static final String[] UsageString = { HString, AString, CString,\r
             NString, PString, TString, MString };\r
     \r
     private static final String[] UsageString = { HString, AString, CString,\r
             NString, PString, TString, MString };\r
index 2285f2142d796ae82e394a9d30dad3d5117f280e..8b818059d5a4dfaea33f173540ac5af15f4d367f 100644 (file)
@@ -24,24 +24,31 @@ public class ParseParameter {
     public static boolean checkParameter(String[] args) {\r
         \r
         if(args.length == 0){\r
     public static boolean checkParameter(String[] args) {\r
         \r
         if(args.length == 0){\r
-            HelpInfo.outputUsageInfo();\r
+            TargetFile.readFile();\r
+            outputCurSetting();\r
             return false;\r
         } else {\r
             return false;\r
         } else {\r
-            if( args[0].charAt(0) != '-' ){\r
+            if( (args[0].compareToIgnoreCase("-h") == 0) || (args[0].compareToIgnoreCase("/h") == 0) || \r
+                (args[0].compareToIgnoreCase("-?") == 0) || (args[0].compareToIgnoreCase("/?") == 0) || \r
+                (args[0].compareToIgnoreCase("-help") == 0) || (args[0].compareToIgnoreCase("/help") == 0) ){\r
                 HelpInfo.outputUsageInfo();\r
                 return false;\r
             }\r
                 HelpInfo.outputUsageInfo();\r
                 return false;\r
             }\r
+            if( args[0].charAt(0) != '-' ){\r
+                System.out.printf("%s\n", "Error arguments! Please type \"ContextTool -h\" for helpinfo.");\r
+                return false;\r
+            }\r
             for(int i=0; i<args.length; i++){\r
             for(int i=0; i<args.length; i++){\r
-                if( (args[i].compareToIgnoreCase("-h") == 0) || \r
-                    (args[i].startsWith("-") && ((args[i].charAt(1) != 'a') && (args[i].charAt(1) != 'c') \r
-                    && (args[i].charAt(1) != 'n') && (args[i].charAt(1) != 'p') && (args[i].charAt(1) != 't') && (args[i].charAt(1) != 'm')))){\r
-                    HelpInfo.outputUsageInfo();\r
+                if( (args[i].startsWith("-") && \r
+                    ((args[i].compareTo("-a") != 0) && (args[i].compareTo("-c") != 0) && \r
+                    (args[i].compareTo("-n") != 0) && (args[i].compareTo("-p") != 0) && \r
+                    (args[i].compareTo("-t") != 0) && (args[i].compareTo("-m") != 0)))){\r
+                    System.out.printf("%s\n", "Error arguments! Please type \"ContextTool -h\" for helpinfo.");                                                                                                                                                            \r
                     return false;\r
                 }\r
             }\r
         }\r
         \r
                     return false;\r
                 }\r
             }\r
         }\r
         \r
-        standardizeParameter(args);\r
         return true; \r
     }\r
     \r
         return true; \r
     }\r
     \r
@@ -50,12 +57,8 @@ public class ParseParameter {
      * @param args -- user's input\r
      * @return no return value\r
      **/\r
      * @param args -- user's input\r
      * @return no return value\r
      **/\r
-    private static void standardizeParameter(String[] args) {\r
+    public static int standardizeParameter(String[] args) {\r
         \r
         \r
-        //\r
-        // the parameters's length are same.\r
-        //\r
-        length  = pstr.length();\r
         \r
         StringBuffer InputData = new StringBuffer();\r
         for (int i = 0; i < args.length; i++) {\r
         \r
         StringBuffer InputData = new StringBuffer();\r
         for (int i = 0; i < args.length; i++) {\r
@@ -70,34 +73,138 @@ public class ParseParameter {
                 j = InputData.length();\r
 \r
             String argstr = InputData.substring(i, j);\r
                 j = InputData.length();\r
 \r
             String argstr = InputData.substring(i, j);\r
-\r
+            i = j;\r
             if (argstr.charAt(1) == 'p') {\r
             if (argstr.charAt(1) == 'p') {\r
-                pstr += argstr.substring(2);\r
- //               pstr += "\n";\r
+                //\r
+                // argstr is "-p ", display current setting\r
+                //\r
+                if(argstr.length() < 4 && argstr.charAt(2) == ' '){\r
+                    System.out.printf("%s\n", curpstr);\r
+                    return 1;\r
+                }\r
+                //\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
+                //\r
+                if(argstr.length() < 6 && argstr.charAt(3) == '0'){\r
+                    curpstr = pstr;\r
+                    continue;\r
+                }\r
+                curpstr = mergeSetting(curpstr, argstr);\r
             } else if (argstr.charAt(1) == 't') {\r
             } else if (argstr.charAt(1) == 't') {\r
-                tstr += argstr.substring(2);\r
- //               tstr += "\n";\r
+                if(argstr.length() < 4 && argstr.charAt(2) == ' '){\r
+                    System.out.printf("%s\n", curtstr);\r
+                    return 1;\r
+                }\r
+                if(argstr.length() < 6 && argstr.charAt(3) == '?'){\r
+                    System.out.printf( "%s\n", "What kind of the version is the binary target, such as DEBUG, RELEASE" );\r
+                    return 2;\r
+                }\r
+                if(argstr.length() < 6 && argstr.charAt(3) == '0'){\r
+                    curtstr = tstr;\r
+                    continue;\r
+                }\r
+                curtstr = mergeSetting(curtstr, argstr);\r
             } else if (argstr.charAt(1) == 'a') {\r
             } else if (argstr.charAt(1) == 'a') {\r
-                astr += argstr.substring(2);\r
-//                astr += "\n";\r
+                if(argstr.length() < 4 && argstr.charAt(2) == ' '){\r
+                    System.out.printf("%s\n", curastr);\r
+                    return 1;\r
+                }\r
+                if(argstr.length() < 6 && argstr.charAt(3) == '?'){\r
+                    System.out.printf( "%s\n", "What kind of architechure is the binary target, such as IA32, IA64, X64, EBC, or ARM" );\r
+                    return 2;\r
+                }\r
+                if(argstr.length() < 6 && argstr.charAt(3) == '0'){\r
+                    curastr = astr;\r
+                    continue;\r
+                }\r
+                curastr = mergeSetting(curastr, argstr);\r
             } else if (argstr.charAt(1) == 'c') {\r
             } else if (argstr.charAt(1) == 'c') {\r
-                cstr += argstr.substring(2);\r
-//                cstr += "\n";\r
+                if(argstr.length() < 4 && argstr.charAt(2) == ' '){\r
+                    System.out.printf("%s\n", curcstr);\r
+                    return 1;\r
+                }\r
+                if(argstr.length() < 6 && argstr.charAt(3) == '?'){\r
+                    System.out.printf( "%s\n", "Assign a txt file with the relative path to WORKSPACE, which specify the tools to use for the build and must be located in the path: WORKSPACE/Tools/Conf/" );\r
+                    return 2;\r
+                }\r
+                if(argstr.length() < 6 && argstr.charAt(3) == '0'){\r
+                    curcstr = cstr;\r
+                    continue;\r
+                }\r
+                curcstr = mergeSetting(curcstr, argstr);\r
             } else if (argstr.charAt(1) == 'n') {\r
             } else if (argstr.charAt(1) == 'n') {\r
-                nstr += argstr.substring(2);\r
-//                nstr += "\n";\r
+                if(argstr.length() < 4 && argstr.charAt(2) == ' '){\r
+                    System.out.printf("%s\n", curnstr);\r
+                    return 1;\r
+                }\r
+                if(argstr.length() < 6 && argstr.charAt(3) == '?'){\r
+                    System.out.printf( "%s\n", "Specify the TagName, such as GCC, MSFT" );\r
+                    return 2;\r
+                }\r
+                if(argstr.length() < 6 && argstr.charAt(3) == '0'){\r
+                    curnstr = nstr;\r
+                    continue;\r
+                }\r
+                curnstr = mergeSetting(curnstr, argstr);\r
             } else if (argstr.charAt(1) == 'm') {\r
             } else if (argstr.charAt(1) == 'm') {\r
+                if(argstr.length() < 4 && argstr.charAt(2) == ' '){\r
+                    System.out.printf("%s\n", curmstr);\r
+                    return 1;\r
+                }\r
+                if(argstr.length() < 6 && argstr.charAt(3) == '?'){\r
+                    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
                 mstr += argstr.substring(2);\r
                 mstr += argstr.substring(2);\r
-//              mstr += "\n";\r
+                curmstr = mstr;\r
                 if (argstr.charAt(3) == '0'){\r
                     mestr += " Disable";\r
                 } else {\r
                     mestr += " Enable";\r
                 }\r
                 if (argstr.charAt(3) == '0'){\r
                     mestr += " Disable";\r
                 } else {\r
                     mestr += " Enable";\r
                 }\r
-          }\r
-            i = j;\r
+                curmestr = mestr;\r
+            }\r
+            \r
         }\r
         }\r
-\r
+        return 0;\r
+    }\r
+    \r
+    \r
+    public static String mergeSetting( String S1, String S2){\r
+        \r
+        String[] S = S2.split(" ");\r
+        if(S1 == null){\r
+            S1 = tstr.concat(S2.substring(2));\r
+        }else{\r
+            for(int i = 1; i < S.length; i++){\r
+                if( S1.contains(S[i]) == false ){\r
+                    S1 = S1.concat(S[i]).concat(" ");\r
+                }\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
+        return true;\r
     }\r
      \r
     public static int length  = 0;\r
     }\r
      \r
     public static int length  = 0;\r
@@ -108,5 +215,21 @@ public class ParseParameter {
     public static String nstr = new String("TOOL_CHAIN_TAG                      = ");\r
     public static String mstr = new String("MAX_CONCURRENT_THREAD_NUMBER        = ");\r
     public static String mestr = new String("MULTIPLE_THREAD                     = ");\r
     public static String nstr = new String("TOOL_CHAIN_TAG                      = ");\r
     public static String mstr = new String("MAX_CONCURRENT_THREAD_NUMBER        = ");\r
     public static String mestr = new String("MULTIPLE_THREAD                     = ");\r
+    \r
+    public static String curpstr = null;\r
+    public static String curtstr = null;\r
+    public static String curastr = null;\r
+    public static String curcstr = null;\r
+    public static String curnstr = null;\r
+    public static String curmstr = null;\r
+    public static String curmestr = null;\r
+    \r
+    public static int plength = 0;\r
+    public static int tlength = 0;\r
+    public static int alength = 0;\r
+    public static int clength = 0;\r
+    public static int nlength = 0;\r
+    public static int mlength = 0;\r
+    public static int melength = 0;\r
 \r
 }\r
 \r
 }\r
index 3143b8c86d5062de23527f3f2bb46d1a35fdffb0..adde59b8437fc3bfc1f4595edd9bbce3942535cf 100644 (file)
@@ -30,7 +30,7 @@ public class TargetFile {
      * @param String filename : the name of target file\r
      * @return true or false\r
      **/\r
      * @param String filename : the name of target file\r
      * @return true or false\r
      **/\r
-    public static boolean parsePath(String filename) {\r
+    public static boolean setFile(String filename) {\r
 \r
         String workspacePath = System.getenv("WORKSPACE");\r
         \r
 \r
         String workspacePath = System.getenv("WORKSPACE");\r
         \r
@@ -55,17 +55,37 @@ public class TargetFile {
         TargetFile.writeFile(Fd);\r
         return true;\r
     }\r
         TargetFile.writeFile(Fd);\r
         return true;\r
     }\r
+    \r
+    \r
+    /** \r
+     * validate the filename\r
+     * @param String filename : the name of target file\r
+     * \r
+     * @return true or false\r
+     **/\r
+    public static boolean validateFilename(String filename) {\r
+        \r
+        String workspacePath = System.getenv("WORKSPACE");\r
+        \r
+        Fd = new File(workspacePath + File.separator + "Tools" + File.separator + "Conf" + File.separator + filename);\r
+        \r
+        if (Fd.exists() == true && Fd.canRead() == true)\r
+            return true;\r
+        else\r
+            return false;\r
+    }\r
+    \r
 \r
     /**\r
      * create a empty temp file, which is located at the same directory with target file\r
      * @param String filename : the name of target temp file\r
      * @return true or false\r
      **/\r
 \r
     /**\r
      * create a empty temp file, which is located at the same directory with target file\r
      * @param String filename : the name of target temp file\r
      * @return true or false\r
      **/\r
-    private static boolean createTempFile(String filename) {\r
+    public static boolean createTempFile(String filename) {\r
 \r
         String workspacePath = System.getenv("WORKSPACE");\r
         \r
 \r
         String workspacePath = System.getenv("WORKSPACE");\r
         \r
-        TempFd = new File(workspacePath + File.separator + "Tools" + File.separator + "Conf" + File.separator + filename);\r
+        TempFd = new File(workspacePath + File.separator + "Tools" + File.separator + "Conf" + File.separator + filename + "tmp");\r
 \r
         if (TempFd.exists() == true) {\r
             if (TempFd.delete() == false) {\r
 \r
         if (TempFd.exists() == true) {\r
             if (TempFd.delete() == false) {\r
@@ -89,7 +109,7 @@ public class TargetFile {
      * @param no paremeter\r
      * @return true or false\r
      **/\r
      * @param no paremeter\r
      * @return true or false\r
      **/\r
-    private static boolean readwriteFile() {\r
+    public static boolean readwriteFile() {\r
 \r
         if (Fd.canRead() != true)\r
             return false;\r
 \r
         if (Fd.canRead() != true)\r
             return false;\r
@@ -137,15 +157,15 @@ public class TargetFile {
                     if (textLine.indexOf("ACTIVE_PLATFORM") != -1) {\r
                         if(pflag == true){\r
                             if(textLine.trim().charAt(0) == '#'){\r
                     if (textLine.indexOf("ACTIVE_PLATFORM") != -1) {\r
                         if(pflag == true){\r
                             if(textLine.trim().charAt(0) == '#'){\r
-                                if(ParseParameter.pstr.length() > ParseParameter.length) {\r
-                                    bw.write(ParseParameter.pstr);\r
+                                if(ParseParameter.curpstr.length() >= ParseParameter.plength) {\r
+                                    bw.write(ParseParameter.curpstr);\r
                                     bw.newLine();\r
                                     pflag = false;\r
                                 }\r
                                 continue;\r
                             }\r
                                     bw.newLine();\r
                                     pflag = false;\r
                                 }\r
                                 continue;\r
                             }\r
-                            if(ParseParameter.pstr.length() > ParseParameter.length) {\r
-                                bw.write(ParseParameter.pstr);\r
+                            if(ParseParameter.curpstr.length() >= ParseParameter.plength) {\r
+                                bw.write(ParseParameter.curpstr);\r
                             } else {\r
                                 bw.write(textLine);\r
                             }\r
                             } else {\r
                                 bw.write(textLine);\r
                             }\r
@@ -155,15 +175,15 @@ public class TargetFile {
                     } else if (textLine.indexOf("TARGET_ARCH") != -1) {\r
                         if(aflag == true){\r
                             if(textLine.trim().charAt(0) == '#'){\r
                     } else if (textLine.indexOf("TARGET_ARCH") != -1) {\r
                         if(aflag == true){\r
                             if(textLine.trim().charAt(0) == '#'){\r
-                                if(ParseParameter.astr.length() > ParseParameter.length) {\r
-                                    bw.write(ParseParameter.astr);\r
+                                if(ParseParameter.curastr.length() >= ParseParameter.alength) {\r
+                                    bw.write(ParseParameter.curastr);\r
                                     bw.newLine();\r
                                     aflag = false;\r
                                 }\r
                                 continue;\r
                             }\r
                                     bw.newLine();\r
                                     aflag = false;\r
                                 }\r
                                 continue;\r
                             }\r
-                            if(ParseParameter.astr.length() > ParseParameter.length) {\r
-                                bw.write(ParseParameter.astr);\r
+                            if(ParseParameter.curastr.length() >= ParseParameter.alength) {\r
+                                bw.write(ParseParameter.curastr);\r
                             } else {\r
                                 bw.write(textLine);\r
                             }\r
                             } else {\r
                                 bw.write(textLine);\r
                             }\r
@@ -173,15 +193,15 @@ public class TargetFile {
                     } else if (textLine.indexOf("TARGET") != -1) {\r
                         if(tflag == true){\r
                             if(textLine.trim().charAt(0) == '#'){\r
                     } else if (textLine.indexOf("TARGET") != -1) {\r
                         if(tflag == true){\r
                             if(textLine.trim().charAt(0) == '#'){\r
-                                if(ParseParameter.tstr.length() > ParseParameter.length) {\r
-                                    bw.write(ParseParameter.tstr);\r
+                                if(ParseParameter.curtstr.length() >= ParseParameter.tlength) {\r
+                                    bw.write(ParseParameter.curtstr);\r
                                     bw.newLine();\r
                                     tflag = false;\r
                                 }\r
                                 continue;\r
                             }\r
                                     bw.newLine();\r
                                     tflag = false;\r
                                 }\r
                                 continue;\r
                             }\r
-                            if(ParseParameter.tstr.length() > ParseParameter.length) {\r
-                                bw.write(ParseParameter.tstr);\r
+                            if(ParseParameter.curtstr.length() >= ParseParameter.tlength) {\r
+                                bw.write(ParseParameter.curtstr);\r
                             } else {\r
                                 bw.write(textLine);\r
                             }\r
                             } else {\r
                                 bw.write(textLine);\r
                             }\r
@@ -191,15 +211,15 @@ public class TargetFile {
                     } else if (textLine.indexOf("TOOL_CHAIN_CONF") != -1) {\r
                         if(cflag == true){\r
                             if(textLine.trim().charAt(0) == '#'){\r
                     } else if (textLine.indexOf("TOOL_CHAIN_CONF") != -1) {\r
                         if(cflag == true){\r
                             if(textLine.trim().charAt(0) == '#'){\r
-                                if(ParseParameter.cstr.length() > ParseParameter.length) {\r
-                                    bw.write(ParseParameter.cstr);\r
+                                if(ParseParameter.curcstr.length() >= ParseParameter.clength) {\r
+                                    bw.write(ParseParameter.curcstr);\r
                                     bw.newLine();\r
                                     cflag = false;\r
                                 }\r
                                 continue;\r
                             }\r
                                     bw.newLine();\r
                                     cflag = false;\r
                                 }\r
                                 continue;\r
                             }\r
-                            if(ParseParameter.cstr.length() > ParseParameter.length) {\r
-                                bw.write(ParseParameter.cstr);\r
+                            if(ParseParameter.curcstr.length() >= ParseParameter.clength) {\r
+                                bw.write(ParseParameter.curcstr);\r
                             } else {\r
                                 bw.write(textLine);\r
                             }\r
                             } else {\r
                                 bw.write(textLine);\r
                             }\r
@@ -209,15 +229,15 @@ public class TargetFile {
                     } else if (textLine.indexOf("TOOL_CHAIN_TAG") != -1) {\r
                         if(nflag == true){\r
                             if(textLine.trim().charAt(0) == '#'){\r
                     } else if (textLine.indexOf("TOOL_CHAIN_TAG") != -1) {\r
                         if(nflag == true){\r
                             if(textLine.trim().charAt(0) == '#'){\r
-                                if(ParseParameter.nstr.length() > ParseParameter.length) {\r
-                                    bw.write(ParseParameter.nstr);\r
+                                if(ParseParameter.curnstr.length() >= ParseParameter.nlength) {\r
+                                    bw.write(ParseParameter.curnstr);\r
                                     bw.newLine();\r
                                     nflag = false;\r
                                 }\r
                                 continue;\r
                             }\r
                                     bw.newLine();\r
                                     nflag = false;\r
                                 }\r
                                 continue;\r
                             }\r
-                            if(ParseParameter.nstr.length() > ParseParameter.length) {\r
-                                bw.write(ParseParameter.nstr);\r
+                            if(ParseParameter.curnstr.length() >= ParseParameter.nlength) {\r
+                                bw.write(ParseParameter.curnstr);\r
                             } else {\r
                                 bw.write(textLine);\r
                             }\r
                             } else {\r
                                 bw.write(textLine);\r
                             }\r
@@ -227,15 +247,15 @@ public class TargetFile {
                     } else if (textLine.indexOf("MAX_CONCURRENT_THREAD_NUMBER") != -1) {\r
                         if(mflag == true){\r
                             if(textLine.trim().charAt(0) == '#'){\r
                     } else if (textLine.indexOf("MAX_CONCURRENT_THREAD_NUMBER") != -1) {\r
                         if(mflag == true){\r
                             if(textLine.trim().charAt(0) == '#'){\r
-                                if(ParseParameter.mstr.length() > ParseParameter.length) {\r
-                                    bw.write(ParseParameter.mstr);\r
+                                if(ParseParameter.curmstr.length() >= ParseParameter.mlength) {\r
+                                    bw.write(ParseParameter.curmstr);\r
                                     bw.newLine();\r
                                     mflag = false;\r
                                 }\r
                                 continue;\r
                             }\r
                                     bw.newLine();\r
                                     mflag = false;\r
                                 }\r
                                 continue;\r
                             }\r
-                            if(ParseParameter.mstr.length() > ParseParameter.length) {\r
-                                bw.write(ParseParameter.mstr);\r
+                            if(ParseParameter.curmstr.length() >= ParseParameter.mlength) {\r
+                                bw.write(ParseParameter.curmstr);\r
                             } else {\r
                                 bw.write(textLine);\r
                             }\r
                             } else {\r
                                 bw.write(textLine);\r
                             }\r
@@ -245,15 +265,15 @@ public class TargetFile {
                     }else if (textLine.indexOf("MULTIPLE_THREAD") != -1) {\r
                         if(meflag == true){\r
                             if(textLine.trim().charAt(0) == '#'){\r
                     }else if (textLine.indexOf("MULTIPLE_THREAD") != -1) {\r
                         if(meflag == true){\r
                             if(textLine.trim().charAt(0) == '#'){\r
-                                if(ParseParameter.mestr.length() > ParseParameter.length) {\r
-                                    bw.write(ParseParameter.mestr);\r
+                                if(ParseParameter.curmestr.length() >= ParseParameter.melength) {\r
+                                    bw.write(ParseParameter.curmestr);\r
                                     bw.newLine();\r
                                     meflag = false;\r
                                 }\r
                                 continue;\r
                             }\r
                                     bw.newLine();\r
                                     meflag = false;\r
                                 }\r
                                 continue;\r
                             }\r
-                            if(ParseParameter.mestr.length() > ParseParameter.length) {\r
-                                bw.write(ParseParameter.mestr);\r
+                            if(ParseParameter.curmestr.length() >= ParseParameter.melength) {\r
+                                bw.write(ParseParameter.curmestr);\r
                             } else {\r
                                 bw.write(textLine);\r
                             }\r
                             } else {\r
                                 bw.write(textLine);\r
                             }\r
@@ -266,26 +286,26 @@ public class TargetFile {
             //\r
             //user maybe delete the line *ACTIVE_PLATFORM*=*\r
             //\r
             //\r
             //user maybe delete the line *ACTIVE_PLATFORM*=*\r
             //\r
-            if( (pflag == true) && (ParseParameter.pstr.length() > ParseParameter.length) ){\r
-                bw.write(ParseParameter.pstr);\r
+            if( (pflag == true) && (ParseParameter.curpstr.length() >= ParseParameter.plength) ){\r
+                bw.write(ParseParameter.curpstr);\r
                 bw.newLine();\r
                 bw.newLine();\r
-            } else if ( (tflag == true) && (ParseParameter.tstr.length() > ParseParameter.length) ){\r
-                bw.write(ParseParameter.tstr);\r
+            } else if ( (tflag == true) && (ParseParameter.curtstr.length() >= ParseParameter.tlength) ){\r
+                bw.write(ParseParameter.curtstr);\r
                 bw.newLine();\r
                 bw.newLine();\r
-            } else if ( (aflag == true) && (ParseParameter.astr.length() > ParseParameter.length) ){\r
-                bw.write(ParseParameter.astr);\r
+            } else if ( (aflag == true) && (ParseParameter.curastr.length() >= ParseParameter.alength) ){\r
+                bw.write(ParseParameter.curastr);\r
                 bw.newLine();\r
                 bw.newLine();\r
-            } else if ( (cflag == true) && (ParseParameter.cstr.length() > ParseParameter.length) ){\r
-                bw.write(ParseParameter.cstr);\r
+            } else if ( (cflag == true) && (ParseParameter.curcstr.length() >= ParseParameter.clength) ){\r
+                bw.write(ParseParameter.curcstr);\r
                 bw.newLine();\r
                 bw.newLine();\r
-            } else if ( (nflag == true) && (ParseParameter.nstr.length() > ParseParameter.length) ){\r
-                bw.write(ParseParameter.nstr);\r
+            } else if ( (nflag == true) && (ParseParameter.curnstr.length() >= ParseParameter.nlength) ){\r
+                bw.write(ParseParameter.curnstr);\r
                 bw.newLine();\r
                 bw.newLine();\r
-            } else if ( (meflag == true) && (ParseParameter.mestr.length() > ParseParameter.length) ){\r
-                bw.write(ParseParameter.mestr);\r
+            } else if ( (meflag == true) && (ParseParameter.curmestr.length() >= ParseParameter.melength) ){\r
+                bw.write(ParseParameter.curmestr);\r
                 bw.newLine();\r
                 bw.newLine();\r
-            } else if ( (mflag == true) && (ParseParameter.mstr.length() > ParseParameter.length) ){\r
-                bw.write(ParseParameter.mstr);\r
+            } else if ( (mflag == true) && (ParseParameter.curmstr.length() >= ParseParameter.mlength) ){\r
+                bw.write(ParseParameter.curmstr);\r
                 bw.newLine();\r
             }\r
         } catch (IOException e) {\r
                 bw.newLine();\r
             }\r
         } catch (IOException e) {\r
@@ -313,6 +333,97 @@ public class TargetFile {
 \r
         return true;\r
     }\r
 \r
         return true;\r
     }\r
+    \r
+    /**\r
+     * read the file and output the lines which include setting\r
+     * @param File fd : the File of the target file\r
+     * @return String: the current setting\r
+     **/\r
+    public static boolean readFile() {\r
+        \r
+        BufferedReader br = null;\r
+        String textLine = null;\r
+\r
+        try {\r
+            br = new BufferedReader(new FileReader(Fd));\r
+        } catch (FileNotFoundException e) {\r
+            System.out\r
+                    .println("\n# create the BufferedReader failed, because can't find the file:target.txt!");\r
+            return false;\r
+        }\r
+        try {\r
+            while ((textLine = br.readLine()) != null) {\r
+                //\r
+                // the line is composed of Space\r
+                //\r
+                if (textLine.trim().compareToIgnoreCase("") == 0) {\r
+                    continue;\r
+                } \r
+                //\r
+                // the line starts with "#"\r
+                //\r
+                else if ((textLine.trim().charAt(0) == '#')){\r
+                    continue;\r
+                } else {\r
+                    if (textLine.indexOf("ACTIVE_PLATFORM") != -1) {\r
+                        ParseParameter.curpstr = textLine;\r
+                        ParseParameter.plength = textLine.indexOf('=');\r
+                    } else if (textLine.indexOf("TARGET_ARCH") != -1) {\r
+                        ParseParameter.curastr = textLine;\r
+                        ParseParameter.alength = textLine.indexOf('=');\r
+                    } else if (textLine.indexOf("TARGET") != -1) {\r
+                        ParseParameter.curtstr = textLine;\r
+                        ParseParameter.tlength = textLine.indexOf('=');\r
+                    } else if (textLine.indexOf("TOOL_CHAIN_CONF") != -1) {\r
+                        ParseParameter.curcstr = textLine;\r
+                        ParseParameter.clength = textLine.indexOf('=');\r
+                    } else if (textLine.indexOf("TOOL_CHAIN_TAG") != -1) {\r
+                        ParseParameter.curnstr = textLine;\r
+                        ParseParameter.nlength = textLine.indexOf('=');\r
+                    } else if (textLine.indexOf("MAX_CONCURRENT_THREAD_NUMBER") != -1) {\r
+                        ParseParameter.curmstr = textLine;\r
+                        ParseParameter.mlength = textLine.indexOf('=');\r
+                    } else if (textLine.indexOf("MULTIPLE_THREAD") != -1) {\r
+                        ParseParameter.curmestr = textLine;\r
+                        ParseParameter.melength = textLine.indexOf('=');\r
+                    }\r
+                }\r
+            }\r
+        } catch (IOException e) {\r
+            System.out.println("\n#  read file error!");\r
+            return false;\r
+        }\r
+\r
+        try {\r
+            br.close();\r
+        } catch (IOException e) {\r
+            System.out\r
+                    .println("\n#  close BufferedReader error");\r
+            return false;\r
+        }\r
+        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
 \r
     /**\r
      * according to user's input args, write the file directly\r