diff options
| author | Bent Bisballe Nyeng <deva@aasimon.org> | 2025-12-28 21:48:09 +0100 |
|---|---|---|
| committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2026-02-03 08:42:10 +0100 |
| commit | f2eb782080a74a7d789dea154e17e18cf5121af4 (patch) | |
| tree | 64a3205616d496f335fd8fad3f0aaeb2aae67f42 /src/configure.cc | |
| parent | f66ab53b9380a5367e24727df620d6620ab031f7 (diff) | |
Diffstat (limited to 'src/configure.cc')
| -rw-r--r-- | src/configure.cc | 38 |
1 files changed, 38 insertions, 0 deletions
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 <optional> #include <span> #include <cstring> +#include <vector> +#include <deque> #include "execute.h" #include "ctor.h" @@ -26,7 +28,11 @@ const std::filesystem::path configHeaderFile("config.h"); std::map<std::string, std::string> external_includedir; std::map<std::string, std::string> 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<std::string> 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) { |
