diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2021-10-10 19:02:54 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2021-10-10 19:02:54 +0200 |
commit | 87aad8c76eb2371720c9aceef7516ecb0859ecdf (patch) | |
tree | 8068578c0cd986837757b1d8f8193b01aac01656 | |
parent | 922412f5dc975b423757c1e248eac2813e48acb2 (diff) |
Improve initial bootstrap speed.
-rwxr-xr-x | bootstrap.sh | 6 | ||||
-rw-r--r-- | src/bootstrap.cc | 83 | ||||
-rw-r--r-- | src/tasks.cc | 6 |
3 files changed, 92 insertions, 3 deletions
diff --git a/bootstrap.sh b/bootstrap.sh index 815c12f..fd9b605 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -1,4 +1,6 @@ #!/bin/sh echo "Bootstrapping..." -g++ -std=c++17 -O3 -Isrc -pthread src/*.cc ctor.cc test/ctor.cc -o ctor && \ -echo "Done. Now run ./ctor to build." +g++ -std=c++17 -O3 -Isrc -pthread src/bootstrap.cc ctor.cc test/ctor.cc -o ctor && \ +./ctor && \ +g++ -std=c++17 -O3 -Isrc -pthread ctor.cc test/ctor.cc -Lbuild -lctor -o ctor && \ +echo "Done. Now run ./ctor to (re)build." 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 <iostream> +#include <array> + +#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<std::string, std::string> default_configuration{}; +const std::map<std::string, std::string>& 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<Target> 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; +} diff --git a/src/tasks.cc b/src/tasks.cc index 254404e..c280fb2 100644 --- a/src/tasks.cc +++ b/src/tasks.cc @@ -93,7 +93,7 @@ std::list<std::shared_ptr<Task>> taskFactory(const BuildConfiguration& config, tasks.emplace_back(std::make_shared<TaskAR>(config, settings, config.target, objects, sourceDir)); break; - +#ifndef BOOTSTRAP case TargetType::DynamicLibrary: // TODO: Use C++20 starts_with if(targetFile.stem().string().substr(0, 3) != "lib") @@ -113,6 +113,10 @@ std::list<std::shared_ptr<Task>> taskFactory(const BuildConfiguration& config, case TargetType::Object: break; +#else + default: + break; +#endif } return tasks; |