From c2f57c48045b24fc63b50863bcbec978ba7e45b5 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sun, 18 Dec 2022 13:03:50 +0200 Subject: [PATCH] Detect the latest MSVC tools version --- source/microsofttools.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/source/microsofttools.cpp b/source/microsofttools.cpp index 05edda5..9d3f1da 100644 --- a/source/microsofttools.cpp +++ b/source/microsofttools.cpp @@ -42,7 +42,17 @@ void MicrosoftTools::find_vc_bin_dir(Builder &builder, const Architecture &arch) builder.get_logger().log("tools", format("Visual Studio found in %s", vs_path)); - FS::Path vc_version_fn = vs_path/"VC"/"Auxiliary"/"Build"/"Microsoft.VCToolsVersion.v142.default.txt"; + FS::Path vc_aux_build_dir = vs_path/"VC"/"Auxiliary"/"Build"; + builder.get_logger().log("files", format("Traversing %s", vc_aux_build_dir)); + vector vc_version_files = FS::list_filtered(vc_aux_build_dir, "^Microsoft\\.VCToolsVersion\\."); + if(vc_version_files.empty()) + { + builder.get_logger().log("problems", "MSVC tools version not found"); + return; + } + + sort(vc_version_files); + FS::Path vc_version_fn = vc_aux_build_dir/vc_version_files.back(); builder.get_logger().log("files", format("Reading %s", vc_version_fn)); char buffer[256]; unsigned len = IO::File(vc_version_fn.str()).read(buffer, sizeof(buffer)); -- 2.45.2