]>
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 if ( curpstr
!= null ) {
82 System
. out
. printf ( "%s \n " , curpstr
);
84 System
. out
. printf ( "No ACTIVE_PLATFORM defined \n " );
89 //argstr is "-p ? ", display possible setting
91 if ( argstr
. length () < 6 && argstr
. charAt ( 3 ) == '?' ){
92 String workspacePath
= System
. getenv ( "WORKSPACE" );
93 System
. out
. printf ( "%s \n " , "Assign a platform FPD file with relative path to " + workspacePath
);
97 //argstr is "-p 0 ", clean current setting
99 if ( argstr
. length () < 6 && argstr
. charAt ( 3 ) == '0' ){
104 String
[] S
= argstr
. split ( " " );
106 System
. out
. printf ( "%s \n " , "There should be none or only one ACTIVE_PLATFORM. Please check the number of value which follow \" -p \" ." );
109 curpstr
= pstr
. concat ( argstr
. substring ( 2 ));
111 } else if ( argstr
. charAt ( 1 ) == 't' ) {
112 if ( argstr
. length () < 4 && argstr
. charAt ( 2 ) == ' ' ){
113 if ( curtstr
!= null ) {
114 System
. out
. printf ( "%s \n " , curtstr
);
116 System
. out
. printf ( "No TARGET defined \n " );
120 if ( argstr
. length () < 6 && argstr
. charAt ( 3 ) == '?' ){
121 System
. out
. printf ( "%s \n " , "What kind of the version is the binary target, such as DEBUG, RELEASE." );
124 if ( argstr
. length () < 6 && argstr
. charAt ( 3 ) == '0' ){
129 curtstr
= tstr
. concat ( argstr
. substring ( 2 ));
131 } else if ( argstr
. charAt ( 1 ) == 'a' ) {
132 if ( argstr
. length () < 4 && argstr
. charAt ( 2 ) == ' ' ){
133 if ( curastr
!= null ) {
134 System
. out
. printf ( "%s \n " , curastr
);
136 System
. out
. printf ( "No TARGET_ARCH defined \n " );
140 if ( argstr
. length () < 6 && argstr
. charAt ( 3 ) == '?' ){
141 System
. out
. printf ( "%s \n " , "What kind of architechure is the binary target, such as IA32, IA64, X64, EBC, or ARM." );
144 if ( argstr
. length () < 6 && argstr
. charAt ( 3 ) == '0' ){
149 curastr
= astr
. concat ( argstr
. substring ( 2 ));
151 } else if ( argstr
. charAt ( 1 ) == 'c' ) {
152 if ( argstr
. length () < 4 && argstr
. charAt ( 2 ) == ' ' ){
153 if ( curcstr
!= null ) {
154 System
. out
. printf ( "%s \n " , curcstr
);
156 System
. out
. printf ( "No TOOL_CHAIN_CONF defined \n " );
160 if ( argstr
. length () < 6 && argstr
. charAt ( 3 ) == '?' ){
161 String workspacePath
= System
. getenv ( "WORKSPACE" );
162 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" );
165 if ( argstr
. length () < 6 && argstr
. charAt ( 3 ) == '0' ){
170 String
[] S
= argstr
. split ( " " );
172 System
. out
. printf ( "%s \n " , "There should be one and only one TOOL_CHAIN_CONF. Please check the number of value which follow \" -c \" ." );
175 curcstr
= cstr
. concat ( argstr
. substring ( 2 ));
177 } else if ( argstr
. charAt ( 1 ) == 'n' ) {
178 if ( argstr
. length () < 4 && argstr
. charAt ( 2 ) == ' ' ){
179 if ( curnstr
!= null ) {
180 System
. out
. printf ( "%s \n " , curnstr
);
182 System
. out
. printf ( "No TOOL_CHAIN_TAG defined \n " );
186 if ( argstr
. length () < 6 && argstr
. charAt ( 3 ) == '?' ){
187 System
. out
. printf ( "%s \n " , "Specify the TagName, such as GCC, MSFT." );
190 if ( argstr
. length () < 6 && argstr
. charAt ( 3 ) == '0' ){
195 curnstr
= nstr
. concat ( argstr
. substring ( 2 ));
197 } else if ( argstr
. charAt ( 1 ) == 'm' ) {
198 if ( argstr
. length () < 4 && argstr
. charAt ( 2 ) == ' ' ){
199 if ( curmstr
!= null ) {
200 System
. out
. printf ( "%s \n " , curmstr
);
202 System
. out
. printf ( "No MAX_CONCURRENT_THREAD_NUMBER defined \n " );
206 if ( argstr
. length () < 6 && argstr
. charAt ( 3 ) == '?' ){
207 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." );
210 String
[] S
= argstr
. split ( " " );
212 System
. out
. printf ( "%s \n " , "There should be one and only one integer, which doesn't include space." );
215 mstr
+= argstr
. substring ( 2 );
218 if ( argstr
. charAt ( 3 ) == '0' ){
232 public static boolean outputCurSetting (){
234 System
. out
. printf ( "%s \n " , "The current setting is:" );
235 String
[] A
= { pstr
, tstr
, astr
, cstr
, nstr
, mstr
, mestr
};
236 String
[] B
= { curpstr
, curtstr
, curastr
, curcstr
, curnstr
, curmstr
, curmestr
};
238 for ( int i
= 0 ; i
< A
. length
; i
++){
240 System
. out
. printf ( "%s \n " , B
[ i
] );
243 System
. out
. printf ( "%s \n " , A
[ i
] );
252 public static String pstr
= new String ( "ACTIVE_PLATFORM = " );
253 public static String tstr
= new String ( "TARGET = " );
254 public static String astr
= new String ( "TARGET_ARCH = " );
255 public static String cstr
= new String ( "TOOL_CHAIN_CONF = " );
256 public static String nstr
= new String ( "TOOL_CHAIN_TAG = " );
257 public static String mstr
= new String ( "MAX_CONCURRENT_THREAD_NUMBER = " );
258 public static String mestr
= new String ( "MULTIPLE_THREAD = " );
260 public static String curpstr
= null ;
261 public static String curtstr
= null ;
262 public static String curastr
= null ;
263 public static String curcstr
= null ;
264 public static String curnstr
= null ;
265 public static String curmstr
= null ;
266 public static String curmestr
= null ;
268 public static boolean npflag
= false ;
269 public static boolean ntflag
= false ;
270 public static boolean naflag
= false ;
271 public static boolean ncflag
= false ;
272 public static boolean nnflag
= false ;
273 public static boolean nmflag
= false ;
274 public static boolean nmeflag
= false ;