]> git.tdb.fi Git - builder.git/blobdiff - plugins/msvc/microsofttools.cpp
Move the VS project and solution generators to the MSVC plugin
[builder.git] / plugins / msvc / microsofttools.cpp
index af435bb2e85d73380343cd3f101bf61d119205e5..03905b6584aeebbebd2ef473e35b5148b50f4e4c 100644 (file)
@@ -4,11 +4,14 @@
 #include <msp/builder/sysutils.h>
 #include <msp/core/algorithm.h>
 #include <msp/fs/dir.h>
+#include <msp/fs/stat.h>
 #include <msp/strings/utils.h>
 #include "microsofttools.h"
 #include "msvcarchiver.h"
 #include "msvccompiler.h"
 #include "msvclinker.h"
+#include "vcxprojectgenerator.h"
+#include "vssolutiongenerator.h"
 
 using namespace std;
 using namespace Msp;
@@ -17,20 +20,28 @@ MicrosoftTools::MicrosoftTools(Builder &builder, const Architecture &arch):
        Toolchain("msvc", get_priority(arch))
 {
        find_vc_bin_dir(builder, arch);
-       find_windows_sdk_dir(builder);
+       if(!vc_base_dir.empty())
+               find_windows_sdk_dir(builder);
 
        add_tool(new MsvcCompiler(builder, arch, "CC", *this));
        add_tool(new MsvcCompiler(builder, arch, "CXX", *this));
        add_tool(new MsvcLinker(builder, arch, *this));
        add_tool(new MsvcArchiver(builder, arch, *this));
+
+       add_tool(new VcxProjectGenerator(builder));
+       add_tool(new VsSolutionGenerator(builder));
 }
 
 void MicrosoftTools::find_vc_bin_dir(Builder &builder, const Architecture &arch)
 {
        FS::Path program_files_x86 = get_program_files_x86_dir();
 
+       FS::Path vswhere = program_files_x86/"Microsoft Visual Studio"/"Installer"/"vswhere.exe";
+       if(!FS::exists(vswhere))
+               return;
+
        ExternalTask::Arguments argv;
-       argv.push_back((program_files_x86/"Microsoft Visual Studio"/"Installer"/"vswhere.exe").str());
+       argv.push_back(vswhere.str());
        argv.push_back("-latest");
        argv.push_back("-property");
        argv.push_back("installationPath");
@@ -39,6 +50,12 @@ void MicrosoftTools::find_vc_bin_dir(Builder &builder, const Architecture &arch)
 
        string output = ExternalTask::run_and_capture_output(argv, FS::Path(), true);
        FS::Path vs_path = strip(output);
+       if(!vs_path.is_absolute())
+       {
+               string drive = vs_path[1];
+               if(drive.size()==2 && drive[0]>='A' && drive[0]<='Z' && drive[1]==':')
+                       vs_path = FS::Path("/mnt")/string(1, tolower(drive[0]))/vs_path.subpath(2);
+       }
 
        builder.get_logger().log("tools", "Visual Studio found in %s", vs_path);