diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2021-09-24 18:06:14 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2021-09-24 21:47:42 +0200 |
commit | ef7ab06044c155e4728e5e30e3262de2bb40cb29 (patch) | |
tree | 3277f3c95f36565c960c968c1bd9ec8e4d63c9e2 /src/configure.cc | |
parent | ecfc610acff6a9359ae5e7f0b225c5b26b189591 (diff) |
Fix re-compilation of library itself after boostrap. Add support for supplying libctor lib and include paths.
Diffstat (limited to 'src/configure.cc')
-rw-r--r-- | src/configure.cc | 58 |
1 files changed, 57 insertions, 1 deletions
diff --git a/src/configure.cc b/src/configure.cc index b3517dc..9eca0d6 100644 --- a/src/configure.cc +++ b/src/configure.cc @@ -6,6 +6,7 @@ #include <iostream> #include <filesystem> #include <fstream> +#include <optional> #include <getoptpp/getoptpp.hpp> @@ -13,6 +14,7 @@ #include "execute.h" #include "libctor.h" #include "tasks.h" +#include "rebuild.h" std::filesystem::path configurationFile("configuration.cc"); std::filesystem::path configHeaderFile("config.h"); @@ -23,8 +25,24 @@ const std::map<std::string, std::string>& __attribute__((weak)) configuration() return default_configuration; } +namespace ctor +{ +std::optional<std::string> includedir; +std::optional<std::string> libdir; +} + bool hasConfiguration(const std::string& key) { + if(key == cfg::ctor_includedir && ctor::includedir) + { + return true; + } + + if(key == cfg::ctor_libdir && ctor::libdir) + { + return true; + } + const auto& c = configuration(); return c.find(key) != c.end(); } @@ -32,6 +50,16 @@ bool hasConfiguration(const std::string& key) const std::string& getConfiguration(const std::string& key, const std::string& defaultValue) { + if(key == cfg::ctor_includedir && ctor::includedir) + { + return *ctor::includedir; + } + + if(key == cfg::ctor_libdir && ctor::libdir) + { + return *ctor::libdir; + } + const auto& c = configuration(); if(hasConfiguration(key)) { @@ -119,6 +147,8 @@ int configure(int argc, char* argv[]) std::string cxx_prog = "g++"; std::string ar_prog = "ar"; std::string ld_prog = "ld"; + std::string ctor_includedir; + std::string ctor_libdir; opt.add("build-dir", required_argument, 'b', "Set output directory for build files (default: '" + @@ -191,6 +221,20 @@ int configure(int argc, char* argv[]) return 0; }); + opt.add("ctor-includedir", required_argument, key++, + "Set path to ctor header file, used for re-compiling.", + [&]() { + ctor_includedir = optarg; + return 0; + }); + + opt.add("ctor-libdir", required_argument, key++, + "Set path to ctor library file, used for re-compiling.", + [&]() { + ctor_libdir = optarg; + return 0; + }); + opt.add("help", no_argument, 'h', "Print this help text.", [&]() { @@ -273,7 +317,7 @@ int configure(int argc, char* argv[]) std::cout << "Writing results to: " << configurationFile.string() << "\n"; { std::ofstream istr(configurationFile); - istr << "#include \"libctor.h\"\n\n"; + istr << "#include <libctor.h>\n\n"; istr << "const std::map<std::string, std::string>& configuration()\n"; istr << "{\n"; istr << " static std::map<std::string, std::string> c =\n"; @@ -288,6 +332,16 @@ int configure(int argc, char* argv[]) istr << " { \"" << cfg::build_cxx << "\", \"" << build_cxx << "\" },\n"; istr << " { \"" << cfg::build_ar << "\", \"" << build_ar << "\" },\n"; istr << " { \"" << cfg::build_ld << "\", \"" << build_ld << "\" },\n"; + if(!ctor_includedir.empty()) + { + istr << " { \"" << cfg::ctor_includedir << "\", \"" << ctor_includedir << "\" },\n"; + ctor::includedir = ctor_includedir; + } + if(!ctor_libdir.empty()) + { + istr << " { \"" << cfg::ctor_libdir << "\", \"" << ctor_libdir << "\" },\n"; + ctor::libdir = ctor_libdir; + } istr << " };\n"; istr << " return c;\n"; istr << "}\n"; @@ -300,5 +354,7 @@ int configure(int argc, char* argv[]) istr << "//#define HAS_BAR 1\n"; } + recompileCheck(settings, 1, argv, true, false); + return 0; } |