diff --git a/scripts/buildsystems/vcpkg.cmake b/scripts/buildsystems/vcpkg.cmake index 7b738bd5ea..50001e97d5 100644 --- a/scripts/buildsystems/vcpkg.cmake +++ b/scripts/buildsystems/vcpkg.cmake @@ -59,7 +59,9 @@ if(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" OR CMAKE_SYSTEM_NAME STREQUAL "Wind set(_VCPKG_TARGET_TRIPLET_PLAT uwp) elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux") set(_VCPKG_TARGET_TRIPLET_PLAT linux) -elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") +elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin") + set(_VCPKG_TARGET_TRIPLET_PLAT osx) +else() set(_VCPKG_TARGET_TRIPLET_PLAT windows) endif() diff --git a/toolsrc/include/vcpkg/base/cofffilereader.h b/toolsrc/include/vcpkg/base/cofffilereader.h index ad2cc7b129..e0ad69b336 100644 --- a/toolsrc/include/vcpkg/base/cofffilereader.h +++ b/toolsrc/include/vcpkg/base/cofffilereader.h @@ -17,7 +17,9 @@ namespace vcpkg::CoffFileReader std::vector machine_types; }; +#if defined(_WIN32) DllInfo read_dll(const fs::path& path); LibInfo read_lib(const fs::path& path); +#endif } diff --git a/toolsrc/src/vcpkg/base/cofffilereader.cpp b/toolsrc/src/vcpkg/base/cofffilereader.cpp index 1927e0b5e3..96d2801080 100644 --- a/toolsrc/src/vcpkg/base/cofffilereader.cpp +++ b/toolsrc/src/vcpkg/base/cofffilereader.cpp @@ -306,8 +306,5 @@ namespace vcpkg::CoffFileReader return {std::vector(machine_types.cbegin(), machine_types.cend())}; } -#else - DllInfo read_dll(const fs::path& path) { exit(-1); } - LibInfo read_lib(const fs::path& path) { exit(-1); } #endif } diff --git a/toolsrc/src/vcpkg/build.cpp b/toolsrc/src/vcpkg/build.cpp index 0486039b75..5870bd1870 100644 --- a/toolsrc/src/vcpkg/build.cpp +++ b/toolsrc/src/vcpkg/build.cpp @@ -208,9 +208,7 @@ namespace vcpkg::Build std::string make_build_env_cmd(const PreBuildInfo& pre_build_info, const Toolset& toolset) { - if (pre_build_info.external_toolchain_file) - return Strings::format( - R"("%s" %s 2>&1)", toolset.vcvarsall.u8string(), Strings::join(" ", toolset.vcvarsall_options)); + if (pre_build_info.external_toolchain_file.has_value()) return ""; const char* tonull = " >nul"; if (GlobalState::debugging) @@ -479,8 +477,9 @@ namespace vcpkg::Build {"ALL_FEATURES", all_features}, }); - const auto cmd_set_environment = make_build_env_cmd(pre_build_info, toolset); - const std::string command = Strings::format(R"(%s && %s)", cmd_set_environment, cmd_launch_cmake); + auto command = make_build_env_cmd(pre_build_info, toolset); + if (!command.empty()) command.append(" && "); + command.append(cmd_launch_cmake); const auto timer = Chrono::ElapsedTimer::create_started(); diff --git a/toolsrc/src/vcpkg/commands.env.cpp b/toolsrc/src/vcpkg/commands.env.cpp index 6e52383d80..f3beef6cd7 100644 --- a/toolsrc/src/vcpkg/commands.env.cpp +++ b/toolsrc/src/vcpkg/commands.env.cpp @@ -21,7 +21,11 @@ namespace vcpkg::Commands::Env const auto pre_build_info = Build::PreBuildInfo::from_triplet_file(paths, default_triplet); const Toolset& toolset = paths.get_toolset(pre_build_info); - System::cmd_execute_clean(Build::make_build_env_cmd(pre_build_info, toolset) + " && cmd"); + auto env_cmd = Build::make_build_env_cmd(pre_build_info, toolset); + if (env_cmd.empty()) + System::cmd_execute_clean("cmd"); + else + System::cmd_execute_clean(env_cmd + " && cmd"); Checks::exit_success(VCPKG_LINE_INFO); } diff --git a/toolsrc/src/vcpkg/postbuildlint.cpp b/toolsrc/src/vcpkg/postbuildlint.cpp index 2b427737a8..a31518ad78 100644 --- a/toolsrc/src/vcpkg/postbuildlint.cpp +++ b/toolsrc/src/vcpkg/postbuildlint.cpp @@ -391,6 +391,7 @@ namespace vcpkg::PostBuildLint static LintStatus check_dll_architecture(const std::string& expected_architecture, const std::vector& files) { +#if defined(_WIN32) std::vector binaries_with_invalid_architecture; for (const fs::path& file : files) @@ -413,6 +414,7 @@ namespace vcpkg::PostBuildLint print_invalid_architecture_files(expected_architecture, binaries_with_invalid_architecture); return LintStatus::ERROR_DETECTED; } +#endif return LintStatus::SUCCESS; } @@ -420,6 +422,7 @@ namespace vcpkg::PostBuildLint static LintStatus check_lib_architecture(const std::string& expected_architecture, const std::vector& files) { +#if defined(_WIN32) std::vector binaries_with_invalid_architecture; for (const fs::path& file : files) @@ -451,6 +454,7 @@ namespace vcpkg::PostBuildLint print_invalid_architecture_files(expected_architecture, binaries_with_invalid_architecture); return LintStatus::ERROR_DETECTED; } +#endif return LintStatus::SUCCESS; } @@ -790,11 +794,15 @@ namespace vcpkg::PostBuildLint dlls.insert(dlls.cend(), debug_dlls.cbegin(), debug_dlls.cend()); dlls.insert(dlls.cend(), release_dlls.cbegin(), release_dlls.cend()); - error_count += check_exports_of_dlls(dlls, toolset.dumpbin); - error_count += check_uwp_bit_of_dlls(pre_build_info.cmake_system_name, dlls, toolset.dumpbin); - error_count += check_dll_architecture(pre_build_info.target_architecture, dlls); + if (!toolset.dumpbin.empty()) + { + error_count += check_exports_of_dlls(dlls, toolset.dumpbin); + error_count += check_uwp_bit_of_dlls(pre_build_info.cmake_system_name, dlls, toolset.dumpbin); + error_count += + check_outdated_crt_linkage_of_dlls(dlls, toolset.dumpbin, build_info, pre_build_info); + } - error_count += check_outdated_crt_linkage_of_dlls(dlls, toolset.dumpbin, build_info, pre_build_info); + error_count += check_dll_architecture(pre_build_info.target_architecture, dlls); break; } case Build::LinkageType::STATIC: @@ -805,17 +813,20 @@ namespace vcpkg::PostBuildLint error_count += check_bin_folders_are_not_present_in_static_build(fs, package_dir); - if (!build_info.policies.is_enabled(BuildPolicy::ONLY_RELEASE_CRT)) + if (!toolset.dumpbin.empty()) { + if (!build_info.policies.is_enabled(BuildPolicy::ONLY_RELEASE_CRT)) + { + error_count += check_crt_linkage_of_libs( + BuildType::value_of(Build::ConfigurationType::DEBUG, build_info.crt_linkage), + debug_libs, + toolset.dumpbin); + } error_count += check_crt_linkage_of_libs( - BuildType::value_of(Build::ConfigurationType::DEBUG, build_info.crt_linkage), - debug_libs, + BuildType::value_of(Build::ConfigurationType::RELEASE, build_info.crt_linkage), + release_libs, toolset.dumpbin); } - error_count += check_crt_linkage_of_libs( - BuildType::value_of(Build::ConfigurationType::RELEASE, build_info.crt_linkage), - release_libs, - toolset.dumpbin); break; } default: Checks::unreachable(VCPKG_LINE_INFO); diff --git a/toolsrc/src/vcpkg/vcpkgpaths.cpp b/toolsrc/src/vcpkg/vcpkgpaths.cpp index f2b39c1109..e62ef86626 100644 --- a/toolsrc/src/vcpkg/vcpkgpaths.cpp +++ b/toolsrc/src/vcpkg/vcpkgpaths.cpp @@ -628,13 +628,8 @@ namespace vcpkg ret.dumpbin = ""; ret.supported_architectures = { ToolsetArchOption{"", System::get_host_processor(), System::get_host_processor()}}; -#if defined(_WIN32) - ret.vcvarsall = "cmd"; - ret.vcvarsall_options = {"/c", "echo done"}; -#else - ret.vcvarsall = "true"; + ret.vcvarsall = ""; ret.vcvarsall_options = {}; -#endif ret.version = "external"; ret.visual_studio_root_path = ""; return ret;