summaryrefslogtreecommitdiff
path: root/src/rebuild.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/rebuild.cc')
-rw-r--r--src/rebuild.cc48
1 files changed, 28 insertions, 20 deletions
diff --git a/src/rebuild.cc b/src/rebuild.cc
index f0d52d9..52245fe 100644
--- a/src/rebuild.cc
+++ b/src/rebuild.cc
@@ -8,6 +8,7 @@
#include <algorithm>
#include <source_location>
#include <cstring>
+#include <span>
#include "configure.h"
#include "ctor.h"
@@ -70,7 +71,7 @@ int reg(const char* location)
int unreg(const char* location)
{
- std::size_t found{0};
+ int found{0};
for(std::size_t i = 0; i < numConfigFiles;)
{
if(std::string(location) == configFiles[i].file)
@@ -150,6 +151,8 @@ bool contains(const std::vector<ctor::source>& sources, const std::string& file)
bool recompileCheck(const ctor::settings& global_settings, int argc, char* argv[],
bool relaunch_allowed)
{
+ auto args_span = std::span(argv, static_cast<std::size_t>(argc));
+
using namespace std::string_literals;
if(global_settings.verbose > 1)
@@ -163,36 +166,40 @@ bool recompileCheck(const ctor::settings& global_settings, int argc, char* argv[
config.name = "ctor";
config.system = ctor::output_system::build;
- config.flags.cxxflags.push_back({ctor::cxx_opt::optimization, "3"});
- config.flags.cxxflags.push_back({ctor::cxx_opt::cpp_std, "c++20"});
+ config.flags.cxxflags.emplace_back(ctor::cxx_opt::optimization, "3");
+ config.flags.cxxflags.emplace_back(ctor::cxx_opt::cpp_std, "c++20");
const auto& c = ctor::get_configuration();
if(c.has(ctor::cfg::ctor_includedir))
{
- config.flags.cxxflags.push_back({ctor::cxx_opt::include_path,
- c.get(ctor::cfg::ctor_includedir)});
+ config.flags.cxxflags.emplace_back(ctor::cxx_opt::include_path,
+ c.get(ctor::cfg::ctor_includedir));
}
if(c.has(ctor::cfg::ctor_libdir))
{
- config.flags.ldflags.push_back({ctor::ld_opt::library_path, c.get(ctor::cfg::ctor_libdir)});
+ config.flags.ldflags.emplace_back(ctor::ld_opt::library_path,
+ c.get(ctor::cfg::ctor_libdir));
}
- config.flags.ldflags.push_back({ctor::ld_opt::link, "ctor"});
- config.flags.ldflags.push_back({ctor::ld_opt::strip});
- config.flags.ldflags.push_back({ctor::ld_opt::threads});
+ config.flags.ldflags.emplace_back(ctor::ld_opt::link, "ctor");
+ config.flags.ldflags.emplace_back(ctor::ld_opt::strip);
+ config.flags.ldflags.emplace_back(ctor::ld_opt::threads);
ctor::settings settings{global_settings};
settings.verbose = -1; // Make check completely silent.
- settings.builddir += "/ctor"; // override builddir to use ctor subdir
+
+ // override builddir to use ctor subdir
+ auto ctor_builddir = std::filesystem::path(settings.builddir) / "ctor";
+ settings.builddir = ctor_builddir.string();
{
std::filesystem::path buildfile = settings.builddir;
- std::filesystem::path currentfile = argv[0];
+ std::filesystem::path currentfile = args_span[0];
config.target = std::filesystem::relative(currentfile, buildfile).string();
}
if(std::filesystem::exists(configurationFile))
{
- config.sources.push_back(configurationFile.string());
+ config.sources.emplace_back(configurationFile.string());
}
for(std::size_t i = 0; i < numConfigFiles; ++i)
@@ -206,7 +213,7 @@ bool recompileCheck(const ctor::settings& global_settings, int argc, char* argv[
// Ensure that files containing multiple configurations are only added once.
if(!contains(config.sources, location))
{
- config.sources.push_back(location);
+ config.sources.emplace_back(location);
}
}
@@ -221,11 +228,11 @@ bool recompileCheck(const ctor::settings& global_settings, int argc, char* argv[
// Ensure that files containing multiple configurations are only added once.
if(!contains(config.sources, location))
{
- config.sources.push_back(location);
+ config.sources.emplace_back(location);
}
}
- auto tasks = taskFactory({config}, settings, {});
+ auto tasks = taskFactory({config}, settings, {}, true);
for(auto task : tasks)
{
@@ -261,16 +268,17 @@ bool recompileCheck(const ctor::settings& global_settings, int argc, char* argv[
if(reconfigure)
{
std::vector<std::string> args;
- args.push_back("reconfigure");
+ args.emplace_back("reconfigure");
if(!relaunch_allowed)
{
- args.push_back("--no-rerun");
+ args.emplace_back("--no-rerun");
}
- for(int i = 1; i < argc; ++i)
+ for(std::size_t i = 1; i < args_span.size(); ++i)
{
- args.push_back(argv[i]);
+ args.emplace_back(args_span[i]);
}
- auto ret = execute(argv[0], args);
+
+ auto ret = execute(settings, args_span[0], args);
//if(ret != 0)
{
exit(ret);