aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src/vcpkg_Environment.cpp
diff options
context:
space:
mode:
authorAlexander Karatarakis <alkarata@microsoft.com>2017-01-23 15:15:26 -0800
committerAlexander Karatarakis <alkarata@microsoft.com>2017-01-23 15:15:26 -0800
commit79a00367390dd974170b3abb5ad357d3db8ff5e3 (patch)
tree7517ad57844f4b2e68000e72e2cc95347147149d /toolsrc/src/vcpkg_Environment.cpp
parent3a6571a0191df8ff000384937a6254f378ca23cf (diff)
downloadvcpkg-79a00367390dd974170b3abb5ad357d3db8ff5e3.tar.gz
vcpkg-79a00367390dd974170b3abb5ad357d3db8ff5e3.zip
[VS2017] Add function do get dumpbin.exe
Diffstat (limited to 'toolsrc/src/vcpkg_Environment.cpp')
-rw-r--r--toolsrc/src/vcpkg_Environment.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/toolsrc/src/vcpkg_Environment.cpp b/toolsrc/src/vcpkg_Environment.cpp
index c7eec3bd0..1cbd60341 100644
--- a/toolsrc/src/vcpkg_Environment.cpp
+++ b/toolsrc/src/vcpkg_Environment.cpp
@@ -4,6 +4,7 @@
#include "vcpkg_Commands.h"
#include "metrics.h"
#include "vcpkg_System.h"
+#include "vcpkg_Strings.h"
namespace vcpkg::Environment
{
@@ -83,4 +84,53 @@ namespace vcpkg::Environment
// TODO: switch out ExecutionPolicy Bypass with "Remove Mark Of The Web" code and restore RemoteSigned
ensure_on_path(nuget_version, L"nuget 2>&1", L"powershell -ExecutionPolicy Bypass scripts\\fetchDependency.ps1 -Dependency nuget");
}
+
+ static std::vector<std::string> get_VS2017_installation_instances(const vcpkg_paths& paths)
+ {
+ const fs::path script = paths.scripts / "findVisualStudioInstallationInstances.ps1";
+ const std::wstring cmd = Strings::wformat(L"powershell -ExecutionPolicy Bypass %s", script.native());
+ System::exit_code_and_output ec_data = System::cmd_execute_and_capture_output(cmd);
+ Checks::check_exit(ec_data.exit_code == 0, "Could not run script to detect VS 2017 instances");
+ return Strings::split(ec_data.output, "\n");
+ }
+
+ static fs::path find_dumpbin_exe(const vcpkg_paths& paths)
+ {
+ const std::vector<std::string> vs2017_installation_instances = get_VS2017_installation_instances(paths);
+ std::vector<fs::path> paths_examined;
+
+ // VS2017
+ for (const std::string& instance : vs2017_installation_instances)
+ {
+ const fs::path dumpbin_path = Strings::format(R"(%s\VC\Tools\MSVC\14.10.24911\bin\HostX86\x86\dumpbin.exe)", instance);
+ paths_examined.push_back(dumpbin_path);
+ if (fs::exists(dumpbin_path))
+ {
+ return dumpbin_path;
+ }
+ }
+
+ // VS2015
+ const fs::path vs2015_cmntools = fs::path(System::wdupenv_str(L"VS140COMNTOOLS")).parent_path(); // TODO: Check why this requires parent_path() call
+ const fs::path vs2015_dumpbin_exe = vs2015_cmntools.parent_path().parent_path() / "VC" / "bin" / "dumpbin.exe";
+ paths_examined.push_back(vs2015_dumpbin_exe);
+ if (fs::exists(vs2015_dumpbin_exe))
+ {
+ return vs2015_dumpbin_exe;
+ }
+
+ System::println(System::color::error, "Could not detect dumpbin.exe.");
+ System::println("The following paths were examined:");
+ for (const fs::path& path : paths_examined)
+ {
+ System::println(path.generic_string());
+ }
+ exit(EXIT_FAILURE);
+ }
+
+ const fs::path& get_dumpbin_exe(const vcpkg_paths& paths)
+ {
+ static const fs::path dumpbin_exe = find_dumpbin_exe(paths);
+ return dumpbin_exe;
+ }
}