From 87aad8c76eb2371720c9aceef7516ecb0859ecdf Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sun, 10 Oct 2021 19:02:54 +0200 Subject: Improve initial bootstrap speed. --- src/bootstrap.cc | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 src/bootstrap.cc (limited to 'src/bootstrap.cc') diff --git a/src/bootstrap.cc b/src/bootstrap.cc new file mode 100644 index 0000000..9b8e029 --- /dev/null +++ b/src/bootstrap.cc @@ -0,0 +1,83 @@ +// -*- c++ -*- +// Distributed under the BSD 2-Clause License. +// See accompanying file LICENSE for details. +#include +#include + +#define BOOTSTRAP + +#include "libctor.h" +#include "settings.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" + + +std::filesystem::path configurationFile("configuration.cc"); +std::filesystem::path configHeaderFile("config.h"); + +const std::map default_configuration{}; +const std::map& configuration() +{ + return default_configuration; +} + +bool hasConfiguration(const std::string& key) +{ + return false; +} + +const std::string& getConfiguration(const std::string& key, + const std::string& defaultValue) +{ + return defaultValue; +} + +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; + } + + Settings settings{}; + + settings.builddir = getConfiguration(cfg::builddir, "build"); + settings.parallel_processes = + std::max(1u, std::thread::hardware_concurrency() * 2 - 1); + settings.verbose = 0; + auto all_tasks = getTasks(settings); + 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 != TargetType::UnitTest) + { + non_unittest_targets.push_back(target); + } + } + + auto ret = build(settings, "all", non_unittest_targets, all_tasks); + if(ret != 0) + { + return ret; + } + + return 0; +} -- cgit v1.2.3