summaryrefslogtreecommitdiff
path: root/rebuild.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2021-08-27 21:43:42 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2021-08-27 21:43:42 +0200
commitba5fbfe36fd9934398e8030253c4d0b87c81fd03 (patch)
tree6e020cbde8acc900ed041127e8373e8af2e33e29 /rebuild.cc
parent9955c843e4795cdb6145e803caa6db7387796694 (diff)
Make re-builds work even if binary name is not cppbuild. Block re-launch non-build args are given, such as -a or -d.
Diffstat (limited to 'rebuild.cc')
-rw-r--r--rebuild.cc18
1 files changed, 11 insertions, 7 deletions
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<std::string> args;
- for(int i = 1; i < argc; ++i)
+ if(relaunch_allowed)
{
- args.push_back(argv[i]);
+ std::cout << "Re-launch\n";
+ std::vector<std::string> 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));
}
}
}