// -*- c++ -*- // Distributed under the BSD 2-Clause License. // See accompanying file LICENSE for details. #include #include #include #define BOOTSTRAP #include "ctor.h" #include "util.cc" #include "rebuild.cc" #include "task.cc" #include "task_cc.cc" #include "task_ar.cc" #include "execute.cc" #include "tasks.cc" #include "build.cc" #include "tools.cc" const std::filesystem::path configurationFile("configuration.cc"); const std::filesystem::path configHeaderFile("config.h"); const ctor::configuration& ctor::get_configuration() { static ctor::configuration cfg; static bool initialised{false}; if(!initialised) { cfg.build_toolchain = getToolChain(cfg.get(ctor::cfg::build_cxx, "/usr/bin/g++")); initialised = true; } return cfg; } bool ctor::configuration::has(const std::string& key) const { return false; } const std::string& ctor::configuration::get(const std::string& key, const std::string& default_value) const { auto cxx_env = std::getenv("CXX"); if(key == ctor::cfg::build_cxx && cxx_env) { static std::string s = cxx_env; return s; } auto cc_env = std::getenv("CC"); if(key == ctor::cfg::build_cc && cc_env) { static std::string s = cc_env; return s; } auto ld_env = std::getenv("LD"); if(key == ctor::cfg::build_ld && ld_env) { static std::string s = ld_env; return s; } auto ar_env = std::getenv("AR"); if(key == ctor::cfg::build_ar && ar_env) { static std::string s = ar_env; return s; } auto builddir_env = std::getenv("BUILDDIR"); if(key == ctor::cfg::builddir && builddir_env) { static std::string s = builddir_env; return s; } return default_value; } int main(int argc, char* argv[]) { if(argc > 1) { std::cerr << "This is a minimal bootstrap version of " << argv[0] << " which doesn't support any arguments\n"; return 1; } ctor::settings settings{}; const auto& c = ctor::get_configuration(); settings.builddir = c.get(ctor::cfg::builddir, settings.builddir); settings.parallel_processes = std::max(1u, std::thread::hardware_concurrency() * 2 - 1); settings.verbose = 0; auto all_tasks = getTasks(settings, {}, false); for(auto task : all_tasks) { if(task->registerDepTasks(all_tasks)) { return 1; } } std::vector non_unittest_targets; auto& targets = getTargets(settings); for(const auto& target : targets) { if(target.config.type != ctor::target_type::unit_test && target.config.type != ctor::target_type::unit_test_library) { non_unittest_targets.push_back(target); } } auto ret = build(settings, "all", non_unittest_targets, all_tasks); if(ret != 0) { return ret; } return 0; }