From ef7ab06044c155e4728e5e30e3262de2bb40cb29 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 24 Sep 2021 18:06:14 +0200 Subject: Fix re-compilation of library itself after boostrap. Add support for supplying libctor lib and include paths. --- src/configure.cc | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) (limited to 'src/configure.cc') 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 #include #include +#include #include @@ -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& __attribute__((weak)) configuration() return default_configuration; } +namespace ctor +{ +std::optional includedir; +std::optional 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 \n\n"; istr << "const std::map& configuration()\n"; istr << "{\n"; istr << " static std::map 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; } -- cgit v1.2.3