mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-27 18:31:15 +08:00
[vcpkg] Avoid computing triplet ABIs for editable packages (#13446)
* [vcpkg] Avoid computing triplet ABIs for editable packages * [vcpkg] Address PR comments * [vcpkg-end-to-end-tests] Add tests for --no-binarycaching, binarycaching by default, and --editable Co-authored-by: Robert Schumacher <roschuma@microsoft.com>
This commit is contained in:
parent
88edf6f30a
commit
d8a4e63690
@ -124,7 +124,7 @@ Throw-IfFailed
|
||||
Require-FileNotExists "$installRoot/$Triplet/include/rapidjson/rapidjson.h"
|
||||
|
||||
# Test restoring from files archive
|
||||
$args = $commonArgs + @("install","rapidjson","--binarycaching","--x-binarysource=clear;files,$ArchiveRoot,read")
|
||||
$args = $commonArgs + @("install","rapidjson","--x-binarysource=clear;files,$ArchiveRoot,read")
|
||||
$CurrentTest = "./vcpkg $($args -join ' ')"
|
||||
Remove-Item -Recurse -Force $installRoot
|
||||
Remove-Item -Recurse -Force $buildtreesRoot
|
||||
@ -134,6 +134,33 @@ Throw-IfFailed
|
||||
|
||||
Require-FileExists "$installRoot/$Triplet/include/rapidjson/rapidjson.h"
|
||||
Require-FileNotExists "$buildtreesRoot/rapidjson/src"
|
||||
Require-FileExists "$buildtreesRoot/detect_compiler"
|
||||
|
||||
# Test --no-binarycaching
|
||||
$args = $commonArgs + @("install","rapidjson","--no-binarycaching","--x-binarysource=clear;files,$ArchiveRoot,read")
|
||||
$CurrentTest = "./vcpkg $($args -join ' ')"
|
||||
Remove-Item -Recurse -Force $installRoot
|
||||
Remove-Item -Recurse -Force $buildtreesRoot
|
||||
Write-Host $CurrentTest
|
||||
./vcpkg @args
|
||||
Throw-IfFailed
|
||||
|
||||
Require-FileExists "$installRoot/$Triplet/include/rapidjson/rapidjson.h"
|
||||
Require-FileExists "$buildtreesRoot/rapidjson/src"
|
||||
Require-FileExists "$buildtreesRoot/detect_compiler"
|
||||
|
||||
# Test --editable
|
||||
$args = $commonArgs + @("install","rapidjson","--editable","--x-binarysource=clear;files,$ArchiveRoot,read")
|
||||
$CurrentTest = "./vcpkg $($args -join ' ')"
|
||||
Remove-Item -Recurse -Force $installRoot
|
||||
Remove-Item -Recurse -Force $buildtreesRoot
|
||||
Write-Host $CurrentTest
|
||||
./vcpkg @args
|
||||
Throw-IfFailed
|
||||
|
||||
Require-FileExists "$installRoot/$Triplet/include/rapidjson/rapidjson.h"
|
||||
Require-FileExists "$buildtreesRoot/rapidjson/src"
|
||||
Require-FileNotExists "$buildtreesRoot/detect_compiler"
|
||||
|
||||
# Test restoring from nuget
|
||||
$args = $commonArgs + @("install","rapidjson","--binarycaching","--x-binarysource=clear;nuget,$NuGetRoot")
|
||||
|
@ -11,11 +11,6 @@ namespace vcpkg::Dependencies
|
||||
struct InstallPlanAction;
|
||||
struct ActionPlan;
|
||||
}
|
||||
namespace vcpkg::Build
|
||||
{
|
||||
struct AbiTagAndFile;
|
||||
struct BuildPackageOptions;
|
||||
}
|
||||
|
||||
namespace vcpkg
|
||||
{
|
||||
|
@ -299,12 +299,6 @@ namespace vcpkg::Build
|
||||
}
|
||||
};
|
||||
|
||||
struct AbiTagAndFile
|
||||
{
|
||||
std::string tag;
|
||||
fs::path tag_file;
|
||||
};
|
||||
|
||||
struct CompilerInfo
|
||||
{
|
||||
std::string id;
|
||||
|
@ -850,8 +850,6 @@ namespace vcpkg::Build
|
||||
|
||||
static void abi_entries_from_abi_info(const AbiInfo& abi_info, std::vector<AbiEntry>& abi_tag_entries)
|
||||
{
|
||||
abi_tag_entries.emplace_back("triplet", abi_info.triplet_abi.value_or_exit(VCPKG_LINE_INFO));
|
||||
|
||||
const auto& pre_build_info = *abi_info.pre_build_info;
|
||||
if (pre_build_info.public_abi_override)
|
||||
{
|
||||
@ -869,6 +867,13 @@ namespace vcpkg::Build
|
||||
}
|
||||
}
|
||||
|
||||
struct AbiTagAndFile
|
||||
{
|
||||
const std::string* triplet_abi;
|
||||
std::string tag;
|
||||
fs::path tag_file;
|
||||
};
|
||||
|
||||
static Optional<AbiTagAndFile> compute_abi_tag(const VcpkgPaths& paths,
|
||||
const Dependencies::InstallPlanAction& action,
|
||||
Span<const AbiEntry> dependency_abis)
|
||||
@ -876,9 +881,35 @@ namespace vcpkg::Build
|
||||
auto& fs = paths.get_filesystem();
|
||||
Triplet triplet = action.spec.triplet();
|
||||
|
||||
if (action.build_options.use_head_version == UseHeadVersion::YES)
|
||||
{
|
||||
Debug::print("Binary caching for package ", action.spec, " is disabled due to --head\n");
|
||||
return nullopt;
|
||||
}
|
||||
if (action.build_options.editable == Editable::YES)
|
||||
{
|
||||
Debug::print("Binary caching for package ", action.spec, " is disabled due to --editable\n");
|
||||
return nullopt;
|
||||
}
|
||||
for (auto&& dep_abi : dependency_abis)
|
||||
{
|
||||
if (dep_abi.value.empty())
|
||||
{
|
||||
Debug::print("Binary caching for package ",
|
||||
action.spec,
|
||||
" is disabled due to missing abi info for ",
|
||||
dep_abi.key,
|
||||
'\n');
|
||||
return nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<AbiEntry> abi_tag_entries(dependency_abis.begin(), dependency_abis.end());
|
||||
|
||||
abi_entries_from_abi_info(action.abi_info.value_or_exit(VCPKG_LINE_INFO), abi_tag_entries);
|
||||
const auto& abi_info = action.abi_info.value_or_exit(VCPKG_LINE_INFO);
|
||||
const auto& triplet_abi = paths.get_triplet_info(abi_info);
|
||||
abi_tag_entries.emplace_back("triplet", triplet_abi);
|
||||
abi_entries_from_abi_info(abi_info, abi_tag_entries);
|
||||
|
||||
// If there is an unusually large number of files in the port then
|
||||
// something suspicious is going on. Rather than hash all of them
|
||||
@ -926,9 +957,6 @@ namespace vcpkg::Build
|
||||
Util::sort(sorted_feature_list);
|
||||
abi_tag_entries.emplace_back("features", Strings::join(";", sorted_feature_list));
|
||||
|
||||
if (action.build_options.use_head_version == UseHeadVersion::YES) abi_tag_entries.emplace_back("head", "");
|
||||
if (action.build_options.editable == Editable::YES) abi_tag_entries.emplace_back("editable", "");
|
||||
|
||||
Util::sort(abi_tag_entries);
|
||||
|
||||
const std::string full_abi_info =
|
||||
@ -954,7 +982,8 @@ namespace vcpkg::Build
|
||||
const auto abi_file_path = current_build_tree / (triplet.canonical_name() + ".vcpkg_abi_info.txt");
|
||||
fs.write_contents(abi_file_path, full_abi_info, VCPKG_LINE_INFO);
|
||||
|
||||
return AbiTagAndFile{Hash::get_file_hash(VCPKG_LINE_INFO, fs, abi_file_path, Hash::Algorithm::Sha1),
|
||||
return AbiTagAndFile{&triplet_abi,
|
||||
Hash::get_file_hash(VCPKG_LINE_INFO, fs, abi_file_path, Hash::Algorithm::Sha1),
|
||||
abi_file_path};
|
||||
}
|
||||
|
||||
@ -1013,12 +1042,12 @@ namespace vcpkg::Build
|
||||
abi_info.pre_build_info = std::make_unique<PreBuildInfo>(
|
||||
paths, action.spec.triplet(), var_provider.get_tag_vars(action.spec).value_or_exit(VCPKG_LINE_INFO));
|
||||
abi_info.toolset = paths.get_toolset(*abi_info.pre_build_info);
|
||||
abi_info.compiler_info = paths.get_compiler_info(abi_info);
|
||||
abi_info.triplet_abi = paths.get_triplet_info(abi_info);
|
||||
|
||||
auto maybe_abi_tag_and_file = compute_abi_tag(paths, action, dependency_abis);
|
||||
if (auto p = maybe_abi_tag_and_file.get())
|
||||
{
|
||||
abi_info.compiler_info = paths.get_compiler_info(abi_info);
|
||||
abi_info.triplet_abi = *p->triplet_abi;
|
||||
abi_info.package_abi = std::move(p->tag);
|
||||
abi_info.abi_tag_file = std::move(p->tag_file);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user