]>
git.proxmox.com Git - mirror_edk2.git/blob - Tools/Java/Source/ContextTool/org/tianocore/context/ParseParameter.java
d58d28b01087103bf5961c638df294766dd91aef
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 ( "-?" ) == 0 ) || ( args
[ 0 ]. compareToIgnoreCase ( "/?" ) == 0 ) ||
33 ( args
[ 0 ]. compareToIgnoreCase ( "-help" ) == 0 ) || ( args
[ 0 ]. compareToIgnoreCase ( "/help" ) == 0 ) ){
34 HelpInfo
. outputUsageInfo ();
37 if ( args
[ 0 ]. charAt ( 0 ) != '-' ){
38 System
. out
. printf ( "%s \n " , "Error Parameters! Please type \" ContextTool -h \" for helpinfo." );
41 for ( int i
= 0 ; i
< args
. length
; i
++){
42 if ( ( args
[ i
]. startsWith ( "-" ) &&
43 (( args
[ i
]. compareTo ( "-a" ) != 0 ) && ( args
[ i
]. compareTo ( "-c" ) != 0 ) &&
44 ( args
[ i
]. compareTo ( "-n" ) != 0 ) && ( args
[ i
]. compareTo ( "-p" ) != 0 ) &&
45 ( args
[ i
]. compareTo ( "-t" ) != 0 ) && ( args
[ i
]. compareTo ( "-m" ) != 0 )))){
46 System
. out
. printf ( "%s \n " , "Error Parameters! Please type \" ContextTool -h \" for helpinfo." );
56 * standardize user's input args
57 * @param args -- user's input
58 * @return no return value
60 public static int standardizeParameter ( String
[] args
) {
63 StringBuffer InputData
= new StringBuffer ();
64 for ( int i
= 0 ; i
< args
. length
; i
++) {
65 InputData
. append ( args
[ i
]);
66 InputData
. append ( " " );
70 while ( i
< InputData
. length ()) {
71 int j
= InputData
. indexOf ( "-" , i
+ 1 );
73 j
= InputData
. length ();
75 String argstr
= InputData
. substring ( i
, j
);
77 if ( argstr
. charAt ( 1 ) == 'p' ) {
79 // argstr is "-p ", display current setting
81 if ( argstr
. length () < 4 && argstr
. charAt ( 2 ) == ' ' ){
82 System
. out
. printf ( "%s \n " , curpstr
);
86 //argstr is "-p ? ", display possible setting
88 if ( argstr
. length () < 6 && argstr
. charAt ( 3 ) == '?' ){
89 String workspacePath
= System
. getenv ( "WORKSPACE" );
90 System
. out
. printf ( "%s \n " , "Assign a platform FPD file with relative path to " + workspacePath
);
94 //argstr is "-p 0 ", clean current setting
96 if ( argstr
. length () < 6 && argstr
. charAt ( 3 ) == '0' ){
101 String
[] S
= argstr
. split ( " " );
103 System
. out
. printf ( "%s \n " , "There should be none or only one ACTIVE_PLATFORM. Please check the number of value which follow \" -p \" ." );
106 curpstr
= pstr
. concat ( argstr
. substring ( 2 ));
108 } else if ( argstr
. charAt ( 1 ) == 't' ) {
109 if ( argstr
. length () < 4 && argstr
. charAt ( 2 ) == ' ' ){
110 System
. out
. printf ( "%s \n " , curtstr
);
113 if ( argstr
. length () < 6 && argstr
. charAt ( 3 ) == '?' ){
114 System
. out
. printf ( "%s \n " , "What kind of the version is the binary target, such as DEBUG, RELEASE." );
117 if ( argstr
. length () < 6 && argstr
. charAt ( 3 ) == '0' ){
122 curtstr
= tstr
. concat ( argstr
. substring ( 2 ));
124 } else if ( argstr
. charAt ( 1 ) == 'a' ) {
125 if ( argstr
. length () < 4 && argstr
. charAt ( 2 ) == ' ' ){
126 System
. out
. printf ( "%s \n " , curastr
);
129 if ( argstr
. length () < 6 && argstr
. charAt ( 3 ) == '?' ){
130 System
. out
. printf ( "%s \n " , "What kind of architechure is the binary target, such as IA32, IA64, X64, EBC, or ARM." );
133 if ( argstr
. length () < 6 && argstr
. charAt ( 3 ) == '0' ){
138 curastr
= astr
. concat ( argstr
. substring ( 2 ));
140 } else if ( argstr
. charAt ( 1 ) == 'c' ) {
141 if ( argstr
. length () < 4 && argstr
. charAt ( 2 ) == ' ' ){
142 System
. out
. printf ( "%s \n " , curcstr
);
145 if ( argstr
. length () < 6 && argstr
. charAt ( 3 ) == '?' ){
146 String workspacePath
= System
. getenv ( "WORKSPACE" );
147 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" );
150 if ( argstr
. length () < 6 && argstr
. charAt ( 3 ) == '0' ){
155 String
[] S
= argstr
. split ( " " );
157 System
. out
. printf ( "%s \n " , "There should be one and only one TOOL_CHAIN_CONF. Please check the number of value which follow \" -c \" ." );
160 curcstr
= cstr
. concat ( argstr
. substring ( 2 ));
162 } else if ( argstr
. charAt ( 1 ) == 'n' ) {
163 if ( argstr
. length () < 4 && argstr
. charAt ( 2 ) == ' ' ){
164 System
. out
. printf ( "%s \n " , curnstr
);
167 if ( argstr
. length () < 6 && argstr
. charAt ( 3 ) == '?' ){
168 System
. out
. printf ( "%s \n " , "Specify the TagName, such as GCC, MSFT." );
171 if ( argstr
. length () < 6 && argstr
. charAt ( 3 ) == '0' ){
176 curnstr
= nstr
. concat ( argstr
. substring ( 2 ));
178 } else if ( argstr
. charAt ( 1 ) == 'm' ) {
179 if ( argstr
. length () < 4 && argstr
. charAt ( 2 ) == ' ' ){
180 System
. out
. printf ( "%s \n " , curmstr
);
183 if ( argstr
. length () < 6 && argstr
. charAt ( 3 ) == '?' ){
184 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." );
187 String
[] S
= argstr
. split ( " " );
189 System
. out
. printf ( "%s \n " , "There should be one and only one integer, which doesn't include space." );
192 mstr
+= argstr
. substring ( 2 );
195 if ( argstr
. charAt ( 3 ) == '0' ){
209 public static boolean outputCurSetting (){
211 System
. out
. printf ( "%s \n " , "The current setting is:" );
214 System
. out
. printf ( "%s \n " , curpstr
);
217 System
. out
. printf ( "%s \n " , pstr
);
221 System
. out
. printf ( "%s \n " , curtstr
);
224 System
. out
. printf ( "%s \n " , tstr
);
228 System
. out
. printf ( "%s \n " , curastr
);
231 System
. out
. printf ( "%s \n " , astr
);
235 System
. out
. printf ( "%s \n " , curcstr
);
238 System
. out
. printf ( "%s \n " , cstr
);
242 System
. out
. printf ( "%s \n " , curnstr
);
245 System
. out
. printf ( "%s \n " , nstr
);
249 System
. out
. printf ( "%s \n " , curmstr
);
252 System
. out
. printf ( "%s \n " , mstr
);
256 System
. out
. printf ( "%s \n " , curmestr
);
259 System
. out
. printf ( "%s \n " , mestr
);
265 public static String pstr
= new String ( "ACTIVE_PLATFORM = " );
266 public static String tstr
= new String ( "TARGET = " );
267 public static String astr
= new String ( "TARGET_ARCH = " );
268 public static String cstr
= new String ( "TOOL_CHAIN_CONF = " );
269 public static String nstr
= new String ( "TOOL_CHAIN_TAG = " );
270 public static String mstr
= new String ( "MAX_CONCURRENT_THREAD_NUMBER = " );
271 public static String mestr
= new String ( "MULTIPLE_THREAD = " );
273 public static String curpstr
= null ;
274 public static String curtstr
= null ;
275 public static String curastr
= null ;
276 public static String curcstr
= null ;
277 public static String curnstr
= null ;
278 public static String curmstr
= null ;
279 public static String curmestr
= null ;
281 public static boolean npflag
= false ;
282 public static boolean ntflag
= false ;
283 public static boolean naflag
= false ;
284 public static boolean ncflag
= false ;
285 public static boolean nnflag
= false ;
286 public static boolean nmflag
= false ;
287 public static boolean nmeflag
= false ;