]>
Commit | Line | Data |
---|---|---|
987912ad | 1 | /** @file\r |
2 | File is HelpInfo class which is used to output the usage info. \r | |
3 | \r | |
4 | Copyright (c) 2006, Intel Corporation\r | |
5 | All rights reserved. This program and the accompanying materials\r | |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | **/\r | |
13 | \r | |
c74c7a43 | 14 | package org.tianocore.context;\r |
15 | \r | |
67ce7c51 | 16 | import java.util.LinkedList;\r |
17 | \r | |
c74c7a43 | 18 | public class HelpInfo {\r |
19 | \r | |
20 | \r | |
21 | /** \r | |
22 | * output the tools usage guide\r | |
23 | * @param no input parameter\r | |
24 | * @return no return value\r | |
25 | **/\r | |
26 | public static void outputUsageInfo() {\r | |
2c71f6e5 | 27 | System.out.printf("\n%s", DescripationString);\r |
c74c7a43 | 28 | System.out.printf("\n%s", UsageInfoString);\r |
29 | System.out.printf("\n%s", DetailOfOptionString);\r | |
30 | \r | |
2c71f6e5 | 31 | for (int i = 0; i < settingnum; i++) {\r |
c74c7a43 | 32 | outputSubUsageInfo(UsageString[i], UsageStringInfo[i]);\r |
33 | }\r | |
91f560c1 | 34 | \r |
35 | System.out.printf("\n%s", ExampleString);\r | |
c81f5d44 | 36 | System.out.printf("\n%s", str1);\r |
37 | System.out.printf("\n%s", str2);\r | |
38 | System.out.printf("\n%s", str3);\r | |
39 | System.out.printf("\n%s", str4);\r | |
c74c7a43 | 40 | }\r |
41 | \r | |
42 | /** \r | |
43 | * output the usage info which bases on cmd option \r | |
44 | * @param String str1 : the cmd option\r | |
45 | * String str2 : the detail of cmd option\r | |
46 | * @return no return value\r | |
47 | **/\r | |
48 | private static void outputSubUsageInfo(String str1, String str2) {\r | |
67ce7c51 | 49 | \r |
c74c7a43 | 50 | splitString(str2);\r |
67ce7c51 | 51 | System.out.printf("\n%4s %-30s %s", "", str1, List.get(0));\r |
52 | for (int i=1; i<List.size(); i++){\r | |
53 | System.out.printf("\n%4s %-30s %s", "", "", List.get(i));\r | |
c74c7a43 | 54 | }\r |
67ce7c51 | 55 | List.clear();\r |
c74c7a43 | 56 | }\r |
57 | \r | |
58 | /** \r | |
59 | * according to the output width, split the detail info \r | |
60 | * @param String str :the detail info\r | |
61 | * @return no return value\r | |
62 | **/\r | |
63 | private static void splitString(String str) {\r | |
64 | int strlength = str.length();\r | |
65 | if (strlength > MaxSrtingLength) {\r | |
c74c7a43 | 66 | String[] tokens = str.split("[ ]", 0);\r |
67ce7c51 | 67 | String tempstr = null;\r |
c74c7a43 | 68 | int templength = 0;\r |
c74c7a43 | 69 | int start = 0;\r |
70 | int end = 0;\r | |
71 | for (int i = 0; i < tokens.length; i++) {\r | |
72 | if ((templength = end + tokens[i].length() + 1) < (MaxSrtingLength + start)) {\r | |
73 | end = templength;\r | |
74 | } else {\r | |
67ce7c51 | 75 | tempstr = str.substring(start, end);\r |
76 | List.add(tempstr);\r | |
c74c7a43 | 77 | start = end;\r |
78 | i = i - 1;\r | |
79 | }\r | |
80 | }\r | |
67ce7c51 | 81 | tempstr = str.substring(start, end - 1);\r |
82 | List.add(tempstr);\r | |
83 | } else {\r | |
84 | List.add(str);\r | |
c74c7a43 | 85 | }\r |
86 | }\r | |
87 | \r | |
67ce7c51 | 88 | \r |
89 | private static LinkedList<String> List = new LinkedList<String>();\r | |
c74c7a43 | 90 | \r |
91 | private static final int MaxSrtingLength = 40;\r | |
2c71f6e5 | 92 | \r |
93 | private static final int settingnum = 7;\r | |
94 | \r | |
95 | private static final String DescripationString = "The purpose of this tool is modifying the settings in target.txt";\r | |
96 | \r | |
91f560c1 | 97 | private static final String UsageInfoString = "Usage: ContextTool [-option1] [args] [-option2] [args] ...";\r |
c74c7a43 | 98 | \r |
99 | private static final String DetailOfOptionString = "Where options include:";\r | |
91f560c1 | 100 | \r |
2c71f6e5 | 101 | private static final String ExampleString = "Example: ContextTool -a IA32 IA64 EBC -c Tools/Conf/tools_def.txt -t DEBUG -n GCC -p EdkNt32Pkg/Nt32.fpd -m 2\n";\r |
c74c7a43 | 102 | \r |
c81f5d44 | 103 | private static final String str1 = "show current sub setting: ContextTool -x";\r |
104 | \r | |
105 | private static final String str2 = "show possible sub setting: ContextTool -x ?";\r | |
106 | \r | |
107 | private static final String str3 = "clean current sub setting: ContextTool -x 0";\r | |
108 | \r | |
109 | private static final String str4 = "x is the sub setting option, such as p, a, n, m, t, c.\n";\r | |
110 | \r | |
c74c7a43 | 111 | private static final String HString = "-h";\r |
112 | \r | |
2c71f6e5 | 113 | private static final String HStringInfo = "print usage info";\r |
c74c7a43 | 114 | \r |
115 | private static final String AString = "-a <list of Arch>";\r | |
116 | \r | |
f337986f | 117 | 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 |
c74c7a43 | 118 | \r |
119 | private static final String CString = "-c <tool_definition_file.txt>";\r | |
120 | \r | |
2c71f6e5 | 121 | private static final String CStringInfo = "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/. If no file is specified, the default filename is \"tools_def.txt\"";\r |
c74c7a43 | 122 | \r |
123 | private static final String NString = "-n <list of TagNames>";\r | |
124 | \r | |
125 | private static final String NStringInfo = "Specify the TagName, such as GCC, MSFT, which are defined in the \"tool_definition_file.txt\"";\r | |
126 | \r | |
127 | private static final String PString = "-p <*.fpd>";\r | |
128 | \r | |
129 | private static final String PStringInfo = "Specify the WORKSPACE relative Path and Filename of platform FPD file that will be used for the build.";\r | |
130 | \r | |
131 | private static final String TString = "-t <list of Build Targets>";\r | |
132 | \r | |
133 | private static final String TStringInfo = "What kind of the version is the binary target, such as DEBUG, RELEASE. Multiple values can be specified on a single line, using space to separate the values.";\r | |
134 | \r | |
2c71f6e5 | 135 | private static final String MString = "-m <num of Threads>";\r |
136 | \r | |
f337986f | 137 | 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 |
2c71f6e5 | 138 | \r |
c74c7a43 | 139 | private static final String[] UsageString = { HString, AString, CString,\r |
2c71f6e5 | 140 | NString, PString, TString, MString };\r |
c74c7a43 | 141 | \r |
142 | private static final String[] UsageStringInfo = { HStringInfo, AStringInfo,\r | |
2c71f6e5 | 143 | CStringInfo, NStringInfo, PStringInfo, TStringInfo, MStringInfo };\r |
c74c7a43 | 144 | }\r |