mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-27 18:31:15 +08:00
[vcpkg] Improve handling of external toolchain files
This commit is contained in:
parent
01ba04e9a7
commit
bad51b0462
@ -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()
|
||||
|
||||
|
@ -17,7 +17,9 @@ namespace vcpkg::CoffFileReader
|
||||
std::vector<MachineType> machine_types;
|
||||
};
|
||||
|
||||
#if defined(_WIN32)
|
||||
DllInfo read_dll(const fs::path& path);
|
||||
|
||||
LibInfo read_lib(const fs::path& path);
|
||||
#endif
|
||||
}
|
||||
|
@ -306,8 +306,5 @@ namespace vcpkg::CoffFileReader
|
||||
|
||||
return {std::vector<MachineType>(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
|
||||
}
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -391,6 +391,7 @@ namespace vcpkg::PostBuildLint
|
||||
static LintStatus check_dll_architecture(const std::string& expected_architecture,
|
||||
const std::vector<fs::path>& files)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
std::vector<FileAndArch> 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<fs::path>& files)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
std::vector<FileAndArch> 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);
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user