From f2eb782080a74a7d789dea154e17e18cf5121af4 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sun, 28 Dec 2025 21:48:09 +0100 Subject: WIP --- src/configure.cc | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'src/configure.cc') diff --git a/src/configure.cc b/src/configure.cc index 1b8caa6..fc68e81 100644 --- a/src/configure.cc +++ b/src/configure.cc @@ -10,6 +10,8 @@ #include #include #include +#include +#include #include "execute.h" #include "ctor.h" @@ -26,7 +28,11 @@ const std::filesystem::path configHeaderFile("config.h"); std::map external_includedir; std::map external_libdir; +#if !defined(_WIN32) const ctor::configuration& __attribute__((weak)) ctor::get_configuration() +#else +const ctor::configuration& default_get_configuration() +#endif { static ctor::configuration cfg; static bool initialised{false}; @@ -41,6 +47,14 @@ const ctor::configuration& __attribute__((weak)) ctor::get_configuration() } return cfg; } +#if defined(_WIN32) +// Hack to make ctor::get_configuration "weak" linked +// See: +// https://stackoverflow.com/questions/2290587/gcc-style-weak-linking-in-visual-studio +// and +// https://stackoverflow.com/questions/11849853/how-to-list-functions-present-in-object-file +#pragma comment(linker, "/alternatename:?get_configuration@ctor@@YAABUconfiguration@1@XZ=?default_get_configuration@@YAABUconfiguration@ctor@@XZ") +#endif namespace ctor { std::optional includedir; @@ -175,6 +189,9 @@ std::ostream& operator<<(std::ostream& stream, const ctor::toolchain& toolchain) case ctor::toolchain::gcc: stream << "ctor::toolchain::gcc"; break; + case ctor::toolchain::msvc: + stream << "ctor::toolchain::msvc"; + break; case ctor::toolchain::clang: stream << "ctor::toolchain::clang"; break; @@ -983,6 +1000,27 @@ int configure(const ctor::settings& global_settings, int argc, char* argv[]) env["PATH"] = value; } + // Env vars for msvc + if(get_env("CL", value)) + { + env["CL"] = value; + } + + if(get_env("LIB", value)) + { + env["LIB"] = value; + } + + if(get_env("LINK", value)) + { + env["LINK"] = value; + } + + if(get_env("INCLUDE", value)) + { + env["INCLUDE"] = value; + } + auto ret = regenerateCache(settings, args_span[0], args, env); if(ret != 0) { -- cgit v1.2.3