]> git.tdb.fi Git - builder.git/commitdiff
Detect the latest MSVC tools version
authorMikko Rasa <tdb@tdb.fi>
Sun, 18 Dec 2022 11:03:50 +0000 (13:03 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sun, 18 Dec 2022 11:46:24 +0000 (13:46 +0200)
source/microsofttools.cpp

index 05edda5ea5f95e55eb74bff813dabd8d63d07cc9..9d3f1da92ee8f47fc2b854c0c6d66da80f7a9eaf 100644 (file)
@@ -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<string> 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));