X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=Tools%2FJava%2FSource%2FContextTool%2Forg%2Ftianocore%2Fcontext%2FParseParameter.java;h=4d9c6de3a07c1f014f451f325e288a7b2e150793;hp=8f1c8b2f779a666e611532311d9557a99837b97d;hb=2f96bdd1b9358bb1b14e6c6c7399756dbbb9f222;hpb=f15e135965c25cb17c3711e45837a2ddd1c7c696 diff --git a/Tools/Java/Source/ContextTool/org/tianocore/context/ParseParameter.java b/Tools/Java/Source/ContextTool/org/tianocore/context/ParseParameter.java index 8f1c8b2f77..4d9c6de3a0 100644 --- a/Tools/Java/Source/ContextTool/org/tianocore/context/ParseParameter.java +++ b/Tools/Java/Source/ContextTool/org/tianocore/context/ParseParameter.java @@ -29,13 +29,12 @@ public class ParseParameter { return false; } else { if( (args[0].compareToIgnoreCase("-h") == 0) || (args[0].compareToIgnoreCase("/h") == 0) || - (args[0].compareToIgnoreCase("-?") == 0) || (args[0].compareToIgnoreCase("/?") == 0) || - (args[0].compareToIgnoreCase("-help") == 0) || (args[0].compareToIgnoreCase("/help") == 0) ){ + (args[0].compareToIgnoreCase("--help") == 0) || (args[0].compareToIgnoreCase("/help") == 0) ){ HelpInfo.outputUsageInfo(); return false; } if( args[0].charAt(0) != '-' ){ - System.out.printf("%s\n", "Error arguments! Please type \"ContextTool -h\" for helpinfo."); + System.out.printf("%s\n", "Error Parameters! Please type \"ContextTool -h\" for helpinfo."); return false; } for(int i=0; i 2){ + System.out.printf( "%s\n", "There should be none or only one ACTIVE_PLATFORM. Please check the number of value which follow \"-p\"."); + return 3; } + curpstr = pstr.concat(argstr.substring(2)); npflag = true; } else if (argstr.charAt(1) == 't') { if(argstr.length() < 4 && argstr.charAt(2) == ' '){ - System.out.printf("%s\n", curtstr); + if (curtstr != null) { + System.out.printf("%s\n", curtstr); + } else { + System.out.printf("No TARGET defined\n"); + } return 1; } if(argstr.length() < 6 && argstr.charAt(3) == '?'){ - System.out.printf( "%s\n", "What kind of the version is the binary target, such as DEBUG, RELEASE" ); + System.out.printf( "%s\n", "What kind of the version is the binary target, such as DEBUG, RELEASE." ); return 2; } if(argstr.length() < 6 && argstr.charAt(3) == '0'){ @@ -117,19 +126,19 @@ public class ParseParameter { ntflag = true; continue; } - if(curtstr == null){ - curtstr = tstr.concat(argstr.substring(2)); - }else{ - curtstr = mergeSetting(curtstr, argstr); - } + curtstr = tstr.concat(argstr.substring(2)); ntflag = true; } else if (argstr.charAt(1) == 'a') { if(argstr.length() < 4 && argstr.charAt(2) == ' '){ - System.out.printf("%s\n", curastr); + if (curastr != null) { + System.out.printf("%s\n", curastr); + } else { + System.out.printf("No TARGET_ARCH defined\n"); + } return 1; } if(argstr.length() < 6 && argstr.charAt(3) == '?'){ - System.out.printf( "%s\n", "What kind of architechure is the binary target, such as IA32, IA64, X64, EBC, or ARM" ); + System.out.printf( "%s\n", "What kind of architechure is the binary target, such as IA32, IA64, X64, EBC, or ARM." ); return 2; } if(argstr.length() < 6 && argstr.charAt(3) == '0'){ @@ -137,19 +146,20 @@ public class ParseParameter { naflag = true; continue; } - if(curastr == null){ - curastr = astr.concat(argstr.substring(2)); - }else{ - curastr = mergeSetting(curastr, argstr); - } + curastr = astr.concat(argstr.substring(2)); naflag = true; } else if (argstr.charAt(1) == 'c') { if(argstr.length() < 4 && argstr.charAt(2) == ' '){ - System.out.printf("%s\n", curcstr); + if (curcstr != null) { + System.out.printf("%s\n", curcstr); + } else { + System.out.printf("No TOOL_CHAIN_CONF defined\n"); + } return 1; } if(argstr.length() < 6 && argstr.charAt(3) == '?'){ - 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/" ); + String workspacePath = System.getenv("WORKSPACE"); + System.out.printf( "%s\n", "Assign a txt file with relative path to " + workspacePath + ", which specify the tools to use for the build and must be located in the path:" + workspacePath + "\\Tools\\Conf" ); return 2; } if(argstr.length() < 6 && argstr.charAt(3) == '0'){ @@ -157,19 +167,24 @@ public class ParseParameter { ncflag = true; continue; } - if(curcstr == null){ - curcstr = pstr.concat(argstr.substring(2)); - }else{ - curcstr = mergeSetting(curcstr, argstr); + String[] S = argstr.split(" "); + if(S.length > 2){ + System.out.printf( "%s\n", "There should be one and only one TOOL_CHAIN_CONF. Please check the number of value which follow \"-c\"."); + return 3; } + curcstr = cstr.concat(argstr.substring(2)); ncflag = true; } else if (argstr.charAt(1) == 'n') { if(argstr.length() < 4 && argstr.charAt(2) == ' '){ - System.out.printf("%s\n", curnstr); + if (curnstr != null) { + System.out.printf("%s\n", curnstr); + } else { + System.out.printf("No TOOL_CHAIN_TAG defined\n"); + } return 1; } if(argstr.length() < 6 && argstr.charAt(3) == '?'){ - System.out.printf( "%s\n", "Specify the TagName, such as GCC, MSFT" ); + System.out.printf( "%s\n", "Specify the TagName, such as GCC, MSFT." ); return 2; } if(argstr.length() < 6 && argstr.charAt(3) == '0'){ @@ -177,21 +192,26 @@ public class ParseParameter { nnflag = true; continue; } - if(curnstr == null){ - curnstr = nstr.concat(argstr.substring(2)); - }else{ - curnstr = mergeSetting(curnstr, argstr); - } + curnstr = nstr.concat(argstr.substring(2)); nnflag = true; } else if (argstr.charAt(1) == 'm') { if(argstr.length() < 4 && argstr.charAt(2) == ' '){ - System.out.printf("%s\n", curmstr); + if (curmstr != null) { + System.out.printf("%s\n", curmstr); + } else { + System.out.printf("No MAX_CONCURRENT_THREAD_NUMBER defined\n"); + } return 1; } if(argstr.length() < 6 && argstr.charAt(3) == '?'){ 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." ); return 2; } + String[] S = argstr.split(" "); + if(S.length > 2){ + System.out.printf( "%s\n", "There should be one and only one integer, which doesn't include space."); + return 3; + } mstr += argstr.substring(2); curmstr = mstr; nmflag = true; @@ -207,36 +227,28 @@ public class ParseParameter { } return 0; } - - - public static String mergeSetting( String S1, String S2){ - - String[] S = S2.split(" "); - for(int i = 1; i < S.length; i++){ - if(S1.contains(S[i]) == false){ - S1 = S1.concat(" ").concat(S[i]); - } - } - - return S1; - } public static boolean outputCurSetting(){ System.out.printf( "%s\n", "The current setting is:" ); - System.out.printf( "%s\n", curpstr ); - System.out.printf( "%s\n", curtstr ); - System.out.printf( "%s\n", curastr ); - System.out.printf( "%s\n", curcstr ); - System.out.printf( "%s\n", curnstr ); - System.out.printf( "%s\n", curmstr ); - System.out.printf( "%s\n", curmestr ); + String[] A = { pstr, tstr, astr, cstr, nstr, mstr, mestr }; + String[] B = { curpstr, curtstr, curastr, curcstr, curnstr, curmstr, curmestr }; + + for(int i=0; i