]>
git.proxmox.com Git - mirror_edk2.git/blob - Tools/Java/Source/ContextTool/org/tianocore/context/ParseParameter.java
2 File is ParseParameter class which is used to parse the validity of user's input args
5 Copyright (c) 2006, Intel Corporation
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14 package org
. tianocore
. context
;
16 public class ParseParameter
{
20 * check the validity of user's input args
21 * @param args -- user's input
22 * @return true or false
24 public static boolean checkParameter ( String
[] args
) {
27 TargetFile
. readFile ();
31 if ( ( args
[ 0 ]. compareToIgnoreCase ( "-h" ) == 0 ) || ( args
[ 0 ]. compareToIgnoreCase ( "/h" ) == 0 ) ||
32 ( args
[ 0 ]. compareToIgnoreCase ( "--help" ) == 0 ) || ( args
[ 0 ]. compareToIgnoreCase ( "/help" ) == 0 ) ){
33 HelpInfo
. outputUsageInfo ();
36 if ( args
[ 0 ]. charAt ( 0 ) != '-' ){
37 System
. out
. printf ( "%s \n " , "Error Parameters! Please type \" ContextTool -h \" for helpinfo." );
40 for ( int i
= 0 ; i
< args
. length
; i
++){
41 if ( ( args
[ i
]. startsWith ( "-" ) &&
42 (( args
[ i
]. compareTo ( "-a" ) != 0 ) && ( args
[ i
]. compareTo ( "-c" ) != 0 ) &&
43 ( args
[ i
]. compareTo ( "-n" ) != 0 ) && ( args
[ i
]. compareTo ( "-p" ) != 0 ) &&
44 ( args
[ i
]. compareTo ( "-t" ) != 0 ) && ( args
[ i
]. compareTo ( "-m" ) != 0 )))){
45 System
. out
. printf ( "%s \n " , "Error Parameters! Please type \" ContextTool -h \" for helpinfo." );
55 * standardize user's input args
56 * @param args -- user's input
57 * @return no return value
59 public static int standardizeParameter ( String
[] args
) {
62 StringBuffer InputData
= new StringBuffer ();
63 for ( int i
= 0 ; i
< args
. length
; i
++) {
64 InputData
. append ( args
[ i
]);
65 InputData
. append ( " " );
69 while ( i
< InputData
. length ()) {
70 int j
= InputData
. indexOf ( "-" , i
+ 1 );
72 j
= InputData
. length ();
74 String argstr
= InputData
. substring ( i
, j
);
76 if ( argstr
. charAt ( 1 ) == 'p' ) {
78 // argstr is "-p ", display current setting
80 if ( argstr
. length () < 4 && argstr
. charAt ( 2 ) == ' ' ){
81 System
. out
. printf ( "%s \n " , curpstr
);
85 //argstr is "-p ? ", display possible setting
87 if ( argstr
. length () < 6 && argstr
. charAt ( 3 ) == '?' ){
88 String workspacePath
= System
. getenv ( "WORKSPACE" );
89 System
. out
. printf ( "%s \n " , "Assign a platform FPD file with relative path to " + workspacePath
);
93 //argstr is "-p 0 ", clean current setting
95 if ( argstr
. length () < 6 && argstr
. charAt ( 3 ) == '0' ){
100 String
[] S
= argstr
. split ( " " );
102 System
. out
. printf ( "%s \n " , "There should be none or only one ACTIVE_PLATFORM. Please check the number of value which follow \" -p \" ." );
105 curpstr
= pstr
. concat ( argstr
. substring ( 2 ));
107 } else if ( argstr
. charAt ( 1 ) == 't' ) {
108 if ( argstr
. length () < 4 && argstr
. charAt ( 2 ) == ' ' ){
109 System
. out
. printf ( "%s \n " , curtstr
);
112 if ( argstr
. length () < 6 && argstr
. charAt ( 3 ) == '?' ){
113 System
. out
. printf ( "%s \n " , "What kind of the version is the binary target, such as DEBUG, RELEASE." );
116 if ( argstr
. length () < 6 && argstr
. charAt ( 3 ) == '0' ){
121 curtstr
= tstr
. concat ( argstr
. substring ( 2 ));
123 } else if ( argstr
. charAt ( 1 ) == 'a' ) {
124 if ( argstr
. length () < 4 && argstr
. charAt ( 2 ) == ' ' ){
125 System
. out
. printf ( "%s \n " , curastr
);
128 if ( argstr
. length () < 6 && argstr
. charAt ( 3 ) == '?' ){
129 System
. out
. printf ( "%s \n " , "What kind of architechure is the binary target, such as IA32, IA64, X64, EBC, or ARM." );
132 if ( argstr
. length () < 6 && argstr
. charAt ( 3 ) == '0' ){
137 curastr
= astr
. concat ( argstr
. substring ( 2 ));
139 } else if ( argstr
. charAt ( 1 ) == 'c' ) {
140 if ( argstr
. length () < 4 && argstr
. charAt ( 2 ) == ' ' ){
141 System
. out
. printf ( "%s \n " , curcstr
);
144 if ( argstr
. length () < 6 && argstr
. charAt ( 3 ) == '?' ){
145 String workspacePath
= System
. getenv ( "WORKSPACE" );
146 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" );
149 if ( argstr
. length () < 6 && argstr
. charAt ( 3 ) == '0' ){
154 String
[] S
= argstr
. split ( " " );
156 System
. out
. printf ( "%s \n " , "There should be one and only one TOOL_CHAIN_CONF. Please check the number of value which follow \" -c \" ." );
159 curcstr
= cstr
. concat ( argstr
. substring ( 2 ));
161 } else if ( argstr
. charAt ( 1 ) == 'n' ) {
162 if ( argstr
. length () < 4 && argstr
. charAt ( 2 ) == ' ' ){
163 System
. out
. printf ( "%s \n " , curnstr
);
166 if ( argstr
. length () < 6 && argstr
. charAt ( 3 ) == '?' ){
167 System
. out
. printf ( "%s \n " , "Specify the TagName, such as GCC, MSFT." );
170 if ( argstr
. length () < 6 && argstr
. charAt ( 3 ) == '0' ){
175 curnstr
= nstr
. concat ( argstr
. substring ( 2 ));
177 } else if ( argstr
. charAt ( 1 ) == 'm' ) {
178 if ( argstr
. length () < 4 && argstr
. charAt ( 2 ) == ' ' ){
179 System
. out
. printf ( "%s \n " , curmstr
);
182 if ( argstr
. length () < 6 && argstr
. charAt ( 3 ) == '?' ){
183 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." );
186 String
[] S
= argstr
. split ( " " );
188 System
. out
. printf ( "%s \n " , "There should be one and only one integer, which doesn't include space." );
191 mstr
+= argstr
. substring ( 2 );
194 if ( argstr
. charAt ( 3 ) == '0' ){
208 public static boolean outputCurSetting (){
210 System
. out
. printf ( "%s \n " , "The current setting is:" );
211 String
[] A
= { pstr
, tstr
, astr
, cstr
, nstr
, mstr
, mestr
};
212 String
[] B
= { curpstr
, curtstr
, curastr
, curcstr
, curnstr
, curmstr
, curmestr
};
214 for ( int i
= 0 ; i
< A
. length
; i
++){
216 System
. out
. printf ( "%s \n " , B
[ i
] );
219 System
. out
. printf ( "%s \n " , A
[ i
] );
228 public static String pstr
= new String ( "ACTIVE_PLATFORM = " );
229 public static String tstr
= new String ( "TARGET = " );
230 public static String astr
= new String ( "TARGET_ARCH = " );
231 public static String cstr
= new String ( "TOOL_CHAIN_CONF = " );
232 public static String nstr
= new String ( "TOOL_CHAIN_TAG = " );
233 public static String mstr
= new String ( "MAX_CONCURRENT_THREAD_NUMBER = " );
234 public static String mestr
= new String ( "MULTIPLE_THREAD = " );
236 public static String curpstr
= null ;
237 public static String curtstr
= null ;
238 public static String curastr
= null ;
239 public static String curcstr
= null ;
240 public static String curnstr
= null ;
241 public static String curmstr
= null ;
242 public static String curmestr
= null ;
244 public static boolean npflag
= false ;
245 public static boolean ntflag
= false ;
246 public static boolean naflag
= false ;
247 public static boolean ncflag
= false ;
248 public static boolean nnflag
= false ;
249 public static boolean nmflag
= false ;
250 public static boolean nmeflag
= false ;