2021SC@SDUSC
今天分析的是src/mapleall/maple_driver/src/driver_option_common.cpp的代码。
首先在namespace为maple里写了两个方法:
DriverOptionCommon &DriverOptionCommon::GetInstance() {
static DriverOptionCommon instance;
return instance;
}
DriverOptionCommon::DriverOptionCommon() {
CreateUsages(kUsages);
}
这两个方法在另一个namespace中会被用到。
在另一个namespace中定义了一个const的数组kUsages[]:
const mapleOption::Descriptor kUsages[] = {
// index, type, shortOption, longOption, enableBuildType, checkPolicy, help, exeName, extra bins
{ kUnknown,
0,
"",
"",
kBuildTypeAll,
kArgCheckPolicyNone,
"USAGE: maple [options]\n\n"
" Example 1: <Maple bin path>/maple --run=me:mpl2mpl:mplcg --option=\"[MEOPT]:[MPL2MPLOPT]:[MPLCGOPT]\"\n"
" --mplt=MPLTPATH inputFile.mpl\n"
" Example 2: <Maple bin path>/maple -O2 --mplt=mpltPath inputFile.dex\n\n"
"==============================\n"
" Options:\n",
"all",
{} },
{ kHelp,
0,
"h",
"help",
kBuildTypeProduct,
kArgCheckPolicyOptional,
" -h --help [COMPILERNAME] \tPrint usage and exit.\n"
" \tTo print the help info of specified compiler,\n"
" \tyou can use jbc2mpl, me, mpl2mpl, mplcg... as the COMPILERNAME\n"
" \teg: --help=mpl2mpl\n",
"all",
{} },
{ kVersion,
0,
"",
"version",
kBuildTypeProduct,
kArgCheckPolicyOptional,
" --version [command] \tPrint version and exit.\n",
"all",
{} },
{ kInFile,
0,
"",
"infile",
kBuildTypeProduct,
kArgCheckPolicyRequired,
" --infile file1,file2,file3 \tInput files.\n",
"all",
{} },
{ kInMplt,
0,
"",
"mplt",
kBuildTypeProduct,
kArgCheckPolicyRequired,
" --mplt=file1,file2,file3 \tImport mplt files.\n",
"all",
{ "jbc2mpl",
"dex2mpl"
} },
{ kOptimization0,
0,
"O0",
"",
kBuildTypeProduct,
kArgCheckPolicyNone,
" -O0 \tNo optimization.\n",
"all",
{} },
{ kOptimization1,
0,
"O1",
"",
kBuildTypeExperimental,
kArgCheckPolicyNone,
" -O1