Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vcpkg] Avoid computing triplet ABIs for editable packages #13446

Merged
merged 8 commits into from
Oct 6, 2020
29 changes: 28 additions & 1 deletion scripts/azure-pipelines/end-to-end-tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
Expand Down
5 changes: 0 additions & 5 deletions toolsrc/include/vcpkg/binarycaching.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ namespace vcpkg::Dependencies
struct InstallPlanAction;
struct ActionPlan;
}
namespace vcpkg::Build
{
struct AbiTagAndFile;
struct BuildPackageOptions;
}

namespace vcpkg
{
Expand Down
6 changes: 0 additions & 6 deletions toolsrc/include/vcpkg/build.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,6 @@ namespace vcpkg::Build
}
};

struct AbiTagAndFile
{
std::string tag;
fs::path tag_file;
};

struct CompilerInfo
{
std::string id;
Expand Down
47 changes: 38 additions & 9 deletions toolsrc/src/vcpkg/build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -869,16 +867,49 @@ 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)
{
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
Expand Down Expand Up @@ -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 =
Expand All @@ -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};
}

Expand Down Expand Up @@ -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);
}
Expand Down