diff --git a/src/mapleall/maple_driver/include/mpl_options.h b/src/mapleall/maple_driver/include/mpl_options.h index d724e7518e201aea954b51727b812dd1ca3d93ec..6324fa8e68e8106030b435d7a25989bd21615d57 100644 --- a/src/mapleall/maple_driver/include/mpl_options.h +++ b/src/mapleall/maple_driver/include/mpl_options.h @@ -336,10 +336,6 @@ class MplOptions { return selectedExes; } - const std::string &GetPrintCommandStr() const { - return printCommandStr; - } - bool HasSetDebugFlag() const { return debugFlag; } @@ -397,6 +393,7 @@ class MplOptions { std::string GetInputFileNameForPrint(const Action * const action) const; void PrintCommand(const Action * const action); void connectOptStr(std::string &optionStr, const std::string &exeName, bool &firstComb, std::string &runStr); + std::string GetCommonOptionsStr() const; void PrintDetailCommand(const Action * const action, bool isBeforeParse); inline void PrintDetailCommand(bool isBeforeParse) { PrintDetailCommand(nullptr, isBeforeParse); @@ -442,7 +439,6 @@ class MplOptions { std::vector runningExes = {}; std::vector selectedExes = {}; bool isWithIpa = false; - std::string printCommandStr; std::ostringstream printExtraOptStr; bool debugFlag = false; bool withDwarf = false; diff --git a/src/mapleall/maple_driver/include/option_descriptor.h b/src/mapleall/maple_driver/include/option_descriptor.h index 223ab308c026b6086c2dfb632e1c0d134f4d4a71..f1e83553e8a7c79c674959c3dfe8c7f56e8d5b44 100644 --- a/src/mapleall/maple_driver/include/option_descriptor.h +++ b/src/mapleall/maple_driver/include/option_descriptor.h @@ -111,6 +111,10 @@ class Option { return descriptor.type; } + const std::string &GetExeName() const { + return descriptor.exeName; + } + OptionPrefixType GetPrefixType() const { return prefixType; } diff --git a/src/mapleall/maple_driver/src/maple_comb_compiler.cpp b/src/mapleall/maple_driver/src/maple_comb_compiler.cpp index 5794a1f5371e76e57fb4fd4b3688c7d5a5e9ce4c..e7384c1006edeecc9d50e403f7a68c9eecd44a29 100644 --- a/src/mapleall/maple_driver/src/maple_comb_compiler.cpp +++ b/src/mapleall/maple_driver/src/maple_comb_compiler.cpp @@ -94,9 +94,12 @@ void MapleCombCompiler::PrintCommand(const MplOptions &options, const Action &ac optionStr << " --" << opt.OptionKey() << connectSym << opt.Args(); } } + + std::string driverOptions = options.GetCommonOptionsStr(); + optionStr << "\""; LogInfo::MapleLogger() << "Starting:" << options.GetExeFolder() << "maple " << runStr << " " << optionStr.str() << " " - << GetInputFileName(options, action) << options.GetPrintCommandStr() << '\n'; + << driverOptions << " " << GetInputFileName(options, action) << '\n'; } ErrorCode MapleCombCompiler::MakeMeOptions(const MplOptions &options, DriverRunner &runner) { diff --git a/src/mapleall/maple_driver/src/mpl_options.cpp b/src/mapleall/maple_driver/src/mpl_options.cpp index efa8efba48b7b65a9aa0d16961a66d9f9da33799..733fce8311733a100b709f6a0607c1f5e9a1071f 100644 --- a/src/mapleall/maple_driver/src/mpl_options.cpp +++ b/src/mapleall/maple_driver/src/mpl_options.cpp @@ -199,22 +199,18 @@ ErrorCode MplOptions::HandleGeneralOptions() { break; case kTimePhases: timePhases = true; - printCommandStr += " -time-phases"; break; case kGenMeMpl: genMeMpl = true; - printCommandStr += " --genmempl"; break; case kGenVtableImpl: genVtableImpl = true; - printCommandStr += " --genVtableImpl"; break; case kSaveTemps: isSaveTmps = true; genMeMpl = true; genVtableImpl = true; StringUtils::Split(opt.Args(), saveFiles, ','); - printCommandStr += " --save-temps"; break; case kOption: if (UpdateExtraOptionOpt(opt.Args()) != kErrorNoError) { @@ -317,7 +313,6 @@ ErrorCode MplOptions::DecideRunType() { break; case kGenObj: genObj = true; - printCommandStr += " -c"; break; case kMaplePhaseOnly: runMaplePhaseOnly = (opt.Type() == kEnable) ? true : false; @@ -636,6 +631,12 @@ ErrorCode MplOptions::CheckFileExits() { ErrorCode MplOptions::AddOption(const mapleOption::Option &option) { if (!option.HasExtra()) { + if (option.GetExeName() == "all") { + /* If it doesn't have extra options and it's a common option for driver, + * set this option in exeOptions as "all"" to use this info in debug print. + */ + exeOptions[option.GetExeName()].push_back(option); + } return kErrorNoError; } for (const auto &exeName : option.GetExtras()) { @@ -649,6 +650,19 @@ ErrorCode MplOptions::AddOption(const mapleOption::Option &option) { return kErrorNoError; } +std::string MplOptions::GetCommonOptionsStr() const { + std::string driverOptions; + auto it = exeOptions.find("all"); + if (it != exeOptions.end()) { + for (const mapleOption::Option &opt : it->second) { + auto connectSym = !opt.Args().empty() ? "=" : ""; + driverOptions += " --" + opt.OptionKey() + connectSym + opt.Args(); + } + } + + return driverOptions; +} + InputInfo *MplOptions::AllocateInputInfo(const std::string &inputFile) { auto inputInfo = std::make_unique(inputFile); InputInfo *ret = inputInfo.get(); @@ -885,10 +899,11 @@ void MplOptions::PrintCommand(const Action * const action) { optionStr << " -O2"; } + std::string driverOptions = GetCommonOptionsStr(); auto inputs = (action == nullptr) ? GetInputFiles() : GetInputFileNameForPrint(action); LogInfo::MapleLogger() << "Starting:" << exeFolder << "maple " << optionStr.str() << " " - << printExtraOptStr.str() << printCommandStr << " " << inputs << '\n'; + << printExtraOptStr.str() << driverOptions << " " << inputs << '\n'; } if (runMode == RunMode::kCustomRun) { PrintDetailCommand(action, true); @@ -929,14 +944,15 @@ void MplOptions::PrintDetailCommand(const Action * const action, bool isBeforePa connectOptStr(optionStr, kBinNameMplcg, firstComb, runStr); optionStr += "\""; + std::string driverOptions = GetCommonOptionsStr(); auto inputs = (action == nullptr) ? GetInputFiles() : GetInputFileNameForPrint(action); if (isBeforeParse) { LogInfo::MapleLogger() << "Starting:" << exeFolder << "maple " << runStr << " " << optionStr << " " - << printExtraOptStr.str() << printCommandStr << " " << inputs << '\n'; + << printExtraOptStr.str() << driverOptions << " " << inputs << '\n'; } else { LogInfo::MapleLogger() << "Finished:" << exeFolder << "maple " << runStr << " " << optionStr << " " - << printCommandStr << " " << inputs << '\n'; + << driverOptions << " " << inputs << '\n'; } } } // namespace maple