diff --git a/build/envsetup.sh b/build/envsetup.sh index 3b526916d523abd044b23ab87f4f2c72e3ee7a29..70e5e2f32172b23a4ca3aada4fc4a9a9ddebf204 100644 --- a/build/envsetup.sh +++ b/build/envsetup.sh @@ -108,6 +108,11 @@ export MAPLE_EXECUTE_BIN=${MAPLE_ROOT}/output/${MAPLE_BUILD_TYPE}/bin export TEST_BIN=${CASE_ROOT}/driver/script export PATH=$PATH:${MAPLE_EXECUTE_BIN}:${TEST_BIN} +# Enable Autocompletion for maple driver +if [ -f $MAPLE_ROOT/tools/maple_autocompletion.sh ]; then + source ${MAPLE_ROOT}/tools/maple_autocompletion.sh +fi + if [ ! -f $MAPLE_ROOT/tools/qemu/usr/bin/qemu-aarch64 ] && [ "$OLD_OS" = "0" ]; then echo " " echo "!!! please run \"make setup\" to get proper qemu-aarch64" diff --git a/src/mapleall/maple_driver/include/mpl_options.h b/src/mapleall/maple_driver/include/mpl_options.h index 6324fa8e68e8106030b435d7a25989bd21615d57..9106d06ea230eb2a8f5e5d131a5b0734c430cc71 100644 --- a/src/mapleall/maple_driver/include/mpl_options.h +++ b/src/mapleall/maple_driver/include/mpl_options.h @@ -217,6 +217,16 @@ public: compilerTool = compiler; } + bool IsItFirstRealAction() const { + /* First action is always "Input". + * But first real action will be a tool from kMapleCompilers. + */ + if (inputActions.size() > 0 && inputActions[0]->tool == "input") { + return true; + } + return false; + } + private: const InputInfo *inputInfo; diff --git a/src/mapleall/maple_driver/src/compiler_factory.cpp b/src/mapleall/maple_driver/src/compiler_factory.cpp index 4aad43864aa20a52f71f23060d352002edb54527..6167155d712ee583fac08b6adda4645a7c619104 100644 --- a/src/mapleall/maple_driver/src/compiler_factory.cpp +++ b/src/mapleall/maple_driver/src/compiler_factory.cpp @@ -92,10 +92,7 @@ ErrorCode CompilerFactory::DeleteTmpFiles(const MplOptions &mplOptions, } if (isNeedRemove == true) { - ret = FileUtils::Remove(tmpFile); - if (ret != 0) { - LogInfo::MapleLogger() << tmpFile << " File Not Found in DeleteTmpFiles\n"; - } + FileUtils::Remove(tmpFile); } } } diff --git a/src/mapleall/maple_driver/src/compiler_selector.cpp b/src/mapleall/maple_driver/src/compiler_selector.cpp index 5d5608ada83aaa1c3f191196ac7669d506c9177b..87e3fc327ebc6b5a67fdd1e4385c42572a3d5668 100644 --- a/src/mapleall/maple_driver/src/compiler_selector.cpp +++ b/src/mapleall/maple_driver/src/compiler_selector.cpp @@ -44,20 +44,36 @@ ErrorCode CompilerSelectorImpl::Select(const SupportedCompilers &supportedCompil const MplOptions &mplOptions, Action &action, std::vector &selectedActions) const { + ErrorCode ret = kErrorNoError; + /* Traverse Action tree recursively and select compilers in * "from leaf(clang) to root(ld)" order */ for (const std::unique_ptr &a : action.GetInputActions()) { - Select(supportedCompilers, mplOptions, *a, selectedActions); + ret = Select(supportedCompilers, mplOptions, *a, selectedActions); + if (ret != kErrorNoError) { + return ret; + } } Compiler *compiler = FindCompiler(supportedCompilers, action.GetTool()); if (compiler == nullptr) { - return kErrorToolNotFound; + if (action.GetTool() != "input") { + LogInfo::MapleLogger(kLlErr) << "Fatal error: " << action.GetTool() + << " tool is not supported" << "\n"; + LogInfo::MapleLogger(kLlErr) << "Supported Tool: "; + + auto print = [](auto supportedComp) { std::cout << " " << supportedComp.first; }; + std::for_each(supportedCompilers.begin(), supportedCompilers.end(), print); + LogInfo::MapleLogger(kLlErr) << "\n"; + + return kErrorToolNotFound; + } + } else { + action.SetCompiler(compiler); + selectedActions.push_back(&action); } - action.SetCompiler(compiler); - selectedActions.push_back(&action); - return kErrorNoError; + return ret; } ErrorCode CompilerSelectorImpl::Select(const SupportedCompilers &supportedCompilers, @@ -67,6 +83,9 @@ ErrorCode CompilerSelectorImpl::Select(const SupportedCompilers &supportedCompil for (const std::unique_ptr &action : mplOptions.GetActions()) { ret = Select(supportedCompilers, mplOptions, *action, selectedActions); + if (ret != kErrorNoError) { + return ret; + } } return selectedActions.empty() ? kErrorToolNotFound : kErrorNoError; diff --git a/src/mapleall/maple_driver/src/cpp2mpl_compiler.cpp b/src/mapleall/maple_driver/src/cpp2mpl_compiler.cpp index 58bf4a7ec2348b3c5fc5b67a69cf1355c6ef44a2..ffb863baa26d915932bb4cc5779de3fd2b2b78ab 100644 --- a/src/mapleall/maple_driver/src/cpp2mpl_compiler.cpp +++ b/src/mapleall/maple_driver/src/cpp2mpl_compiler.cpp @@ -28,11 +28,9 @@ const std::string &Cpp2MplCompiler::GetBinName() const { return kBinNameCpp2mpl; } -std::string Cpp2MplCompiler::GetInputFileName(const MplOptions &options, const Action &action) const { - if (!options.GetRunningExes().empty()) { - if (options.GetRunningExes()[0] == kBinNameCpp2mpl) { - return action.GetInputFile(); - } +std::string Cpp2MplCompiler::GetInputFileName(const MplOptions &, const Action &action) const { + if (action.IsItFirstRealAction()) { + return action.GetInputFile(); } // Get base file name auto idx = action.GetOutputName().find(".ast"); diff --git a/src/mapleall/maple_driver/src/driver_option_common.cpp b/src/mapleall/maple_driver/src/driver_option_common.cpp index faed5f45c673781d83f8faf23481ba0f7d2c83fd..69a22173382e6f10460bedc58cd21e4f1a537ccc 100644 --- a/src/mapleall/maple_driver/src/driver_option_common.cpp +++ b/src/mapleall/maple_driver/src/driver_option_common.cpp @@ -516,7 +516,7 @@ const mapleOption::Descriptor kUsages[] = { "maple-phase", kBuildTypeAll, kArgCheckPolicyBool, - " --maple-phase \tRun maple phase only\n", + " --maple-phase \tRun maple phase only\n --no-maple-phase\n", "all", {} }, { kMapleOut, diff --git a/src/mapleall/maple_driver/src/maple_comb_compiler.cpp b/src/mapleall/maple_driver/src/maple_comb_compiler.cpp index e7384c1006edeecc9d50e403f7a68c9eecd44a29..8c8d77a4b95d6f2a16e72544ec01beb6339185eb 100644 --- a/src/mapleall/maple_driver/src/maple_comb_compiler.cpp +++ b/src/mapleall/maple_driver/src/maple_comb_compiler.cpp @@ -25,11 +25,9 @@ namespace maple { using namespace mapleOption; -std::string MapleCombCompiler::GetInputFileName(const MplOptions &options, const Action &action) const { - if (!options.GetRunningExes().empty()) { - if (options.GetRunningExes()[0] == kBinNameMe || options.GetRunningExes()[0] == kBinNameMpl2mpl) { - return action.GetInputFile(); - } +std::string MapleCombCompiler::GetInputFileName(const MplOptions &, const Action &action) const { + if (action.IsItFirstRealAction()) { + return action.GetInputFile(); } if (action.GetInputFileType() == InputFileType::kFileTypeVtableImplMpl) { return action.GetFullOutputName() + ".VtableImpl.mpl"; diff --git a/src/mapleall/maple_driver/src/maple_comb_compiler_wrapper.cpp b/src/mapleall/maple_driver/src/maple_comb_compiler_wrapper.cpp index 886d1e8358e8a7dd036ec2aefae7c74866af22c1..7ddeaf6183b36d56860ac2e44cf961adc3c45971 100644 --- a/src/mapleall/maple_driver/src/maple_comb_compiler_wrapper.cpp +++ b/src/mapleall/maple_driver/src/maple_comb_compiler_wrapper.cpp @@ -36,6 +36,9 @@ DefaultOption MapleCombCompilerWrp::GetDefaultOptions(const MplOptions &mplOptio auto options = mplOptions.GetOptions(); std::vector