diff --git a/src/mapleall/maple_driver/include/mpl_options.h b/src/mapleall/maple_driver/include/mpl_options.h index 526e7277466f794b349c521e1814aa53a149e0d2..d724e7518e201aea954b51727b812dd1ca3d93ec 100644 --- a/src/mapleall/maple_driver/include/mpl_options.h +++ b/src/mapleall/maple_driver/include/mpl_options.h @@ -394,9 +394,13 @@ class MplOptions { ErrorCode AppendCombOptions(MIRSrcLang srcLang); ErrorCode AppendMplcgOptions(MIRSrcLang srcLang); - void PrintCommand(); + 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); - void PrintDetailCommand(); + void PrintDetailCommand(const Action * const action, bool isBeforeParse); + inline void PrintDetailCommand(bool isBeforeParse) { + PrintDetailCommand(nullptr, isBeforeParse); + } private: bool Init(const std::string &inputFile); ErrorCode HandleGeneralOptions(); diff --git a/src/mapleall/maple_driver/src/compiler_factory.cpp b/src/mapleall/maple_driver/src/compiler_factory.cpp index ce965b3eecf24dc8e3abaf6c7330ad51c4425447..fecbce0c69eb65ff42758249746d72890deb6373 100644 --- a/src/mapleall/maple_driver/src/compiler_factory.cpp +++ b/src/mapleall/maple_driver/src/compiler_factory.cpp @@ -137,7 +137,7 @@ ErrorCode CompilerFactory::Compile(MplOptions &mplOptions) { } } if (mplOptions.HasSetDebugFlag()) { - mplOptions.PrintDetailCommand(); + mplOptions.PrintDetailCommand(false); } // Compiler finished compileFinished = true; diff --git a/src/mapleall/maple_driver/src/maple_comb_compiler.cpp b/src/mapleall/maple_driver/src/maple_comb_compiler.cpp index 0c0a64afd90f005c25d42c7371bc382b3cb32d29..5794a1f5371e76e57fb4fd4b3688c7d5a5e9ce4c 100644 --- a/src/mapleall/maple_driver/src/maple_comb_compiler.cpp +++ b/src/mapleall/maple_driver/src/maple_comb_compiler.cpp @@ -171,6 +171,7 @@ ErrorCode MapleCombCompiler::Compile(MplOptions &options, const Action &action, theModule = std::make_unique(fileName); fileParsed = false; } + options.PrintCommand(&action); LogInfo::MapleLogger() << "Starting maplecomb\n"; theModule->InitPartO2List(options.GetPartO2List()); DriverRunner runner(theModule.get(), options.GetSelectedExes(), action.GetInputFileType(), fileName, diff --git a/src/mapleall/maple_driver/src/mpl_options.cpp b/src/mapleall/maple_driver/src/mpl_options.cpp index 8606d77e25cf742864f1f27c870d25d3896b27da..efa8efba48b7b65a9aa0d16961a66d9f9da33799 100644 --- a/src/mapleall/maple_driver/src/mpl_options.cpp +++ b/src/mapleall/maple_driver/src/mpl_options.cpp @@ -852,6 +852,50 @@ void MplOptions::UpdateRunningExe(const std::string &args) { } } +std::string MplOptions::GetInputFileNameForPrint(const Action * const action) const { + if (!runningExes.empty()) { + if (runningExes[0] == kBinNameMe || runningExes[0] == kBinNameMpl2mpl + || runningExes[0] == kBinNameMplcg) { + return inputFiles; + } + } + + if (action == nullptr) { + return GetInputFiles(); + } + + if (action->GetInputFileType() == InputFileType::kFileTypeVtableImplMpl) { + return action->GetFullOutputName() + ".VtableImpl.mpl"; + } + if (action->GetInputFileType() == InputFileType::kFileTypeBpl) { + return action->GetFullOutputName() + ".bpl"; + } + return action->GetFullOutputName() + ".mpl"; +} + +void MplOptions::PrintCommand(const Action * const action) { + if (hasPrinted) { + return; + } + std::ostringstream optionStr; + if (runMode == RunMode::kAutoRun) { + if (optimizationLevel == kO0) { + optionStr << " -O0"; + } else if (optimizationLevel == kO2) { + optionStr << " -O2"; + } + + auto inputs = (action == nullptr) ? GetInputFiles() : GetInputFileNameForPrint(action); + + LogInfo::MapleLogger() << "Starting:" << exeFolder << "maple " << optionStr.str() << " " + << printExtraOptStr.str() << printCommandStr << " " << inputs << '\n'; + } + if (runMode == RunMode::kCustomRun) { + PrintDetailCommand(action, true); + } + hasPrinted = true; +} + void MplOptions::connectOptStr(std::string &optionStr, const std::string &exeName, bool &firstComb, std::string &runStr) { std::string connectSym = ""; @@ -870,7 +914,8 @@ void MplOptions::connectOptStr(std::string &optionStr, const std::string &exeNam } } } -void MplOptions::PrintDetailCommand() { + +void MplOptions::PrintDetailCommand(const Action * const action, bool isBeforeParse) { if (exeOptions.find(kBinNameMe) == exeOptions.end() && exeOptions.find(kBinNameMpl2mpl) == exeOptions.end() && exeOptions.find(kBinNameMplcg) == exeOptions.end()) { return; @@ -884,8 +929,14 @@ void MplOptions::PrintDetailCommand() { connectOptStr(optionStr, kBinNameMplcg, firstComb, runStr); optionStr += "\""; - LogInfo::MapleLogger() << "Finished:" << exeFolder << "maple " - << runStr << " " << optionStr << " " - << printCommandStr << " " << GetInputFiles() << '\n'; + auto inputs = (action == nullptr) ? GetInputFiles() : GetInputFileNameForPrint(action); + + if (isBeforeParse) { + LogInfo::MapleLogger() << "Starting:" << exeFolder << "maple " << runStr << " " << optionStr << " " + << printExtraOptStr.str() << printCommandStr << " " << inputs << '\n'; + } else { + LogInfo::MapleLogger() << "Finished:" << exeFolder << "maple " << runStr << " " << optionStr << " " + << printCommandStr << " " << inputs << '\n'; + } } } // namespace maple