From ba5fbfe36fd9934398e8030253c4d0b87c81fd03 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 27 Aug 2021 21:43:42 +0200 Subject: Make re-builds work even if binary name is not cppbuild. Block re-launch non-build args are given, such as -a or -d. --- rebuild.cc | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'rebuild.cc') diff --git a/rebuild.cc b/rebuild.cc index b4564de..43c4c98 100644 --- a/rebuild.cc +++ b/rebuild.cc @@ -54,7 +54,8 @@ int unreg(const char* location) return found; } -void recompileCheck(const Settings& settings, int argc, char* argv[], bool force) +void recompileCheck(const Settings& settings, int argc, char* argv[], + bool force, bool relaunch_allowed) { bool dirty{force}; @@ -64,7 +65,7 @@ void recompileCheck(const Settings& settings, int argc, char* argv[], bool force args.push_back("-std=c++17"); args.push_back("-pthread"); - std::filesystem::path binFile("cppbuild"); + std::filesystem::path binFile(argv[0]); if(std::filesystem::exists(configurationFile)) { @@ -125,13 +126,16 @@ void recompileCheck(const Settings& settings, int argc, char* argv[], bool force } else { - std::cout << "Re-launch\n"; - std::vector args; - for(int i = 1; i < argc; ++i) + if(relaunch_allowed) { - args.push_back(argv[i]); + std::cout << "Re-launch\n"; + std::vector args; + for(int i = 1; i < argc; ++i) + { + args.push_back(argv[i]); + } + exit(execute(argv[0], args, settings.verbose > 0)); } - exit(execute(argv[0], args, settings.verbose > 0)); } } } -- cgit v1.2.3