Skip to content

include build system changes in the binary cache#80

Closed
strega-nil wants to merge 4 commits intomicrosoft:mainfrom
strega-nil:include-vcpkg.cmake-hash
Closed

include build system changes in the binary cache#80
strega-nil wants to merge 4 commits intomicrosoft:mainfrom
strega-nil:include-vcpkg.cmake-hash

Conversation

@strega-nil
Copy link
Copy Markdown
Contributor

No description provided.

@strega-nil strega-nil force-pushed the include-vcpkg.cmake-hash branch from dd4561d to 1025e9b Compare May 21, 2021 17:38
{
continue;
}
auto relative_file = this->scripts.lexically_relative(file);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lexically_relative doesn't exist in experimental filesystem so this will blow up on some of our supported platforms.

Comment on lines +68 to +70
StringView content() const { return content_; }
StringView hash() const { return hash_; }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these should return const string& since all the places are doing to_string making StringView a pessimization.

}

const std::map<std::string, std::string>& VcpkgPaths::get_cmake_script_hashes() const
ContentAndHash::ContentAndHash(std::string&& ctnt, Hash::Algorithm algo) : content_(ctnt)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be:

    ContentAndHash::ContentAndHash(std::string&& ctnt, Hash::Algorithm algo)
        : content_(ctnt), hash_(Hash::get_string_hash(ctnt, algo))
    {
    }


struct ContentAndHash
{
ContentAndHash(std::string&& content, Hash::Algorithm algo);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ContentAndHash(std::string&& content, Hash::Algorithm algo);
ContentAndHash(std::string&& content, Hash::Algorithm algo = Hash::Algorithm::Sha1);

... and then remove naming Sha1 in all the call sites?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should remove all uses of Sha1; use Sha256 instead.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point

{
helpers.emplace(fs::u8string(file.stem()),
Hash::get_file_hash(VCPKG_LINE_INFO, fs, file, Hash::Algorithm::Sha1));
auto content = fs.read_contents(file, VCPKG_LINE_INFO);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mild preference to not name the return of read_contents so that you don't need an explicit move. With SHA1 default suggestion above it should still fit under 120?

fs::u8string(this->scripts));
Checks::exit_fail(VCPKG_LINE_INFO);
}
auto content = fs.read_contents(file, VCPKG_LINE_INFO);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto would prefer to see no explicit move.

}
auto content = fs.read_contents(file, VCPKG_LINE_INFO);

buildsystem_scripts.emplace(fs::u8string(file.stem()),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this was preexisting, but is there a good reason to use stem() here instead of filename? I ask because stem() is one of the things that changed between filesystem and experimental filesystem

Comment on lines +1130 to +1154
struct
{
const std::map<std::string, ContentAndHash>& helpers;
std::vector<Build::AbiEntry>& abi_tag_entries;
std::set<char const*> helpers_added; // pointers to helpers keys
void operator()(StringView contents, const std::string& helper_name, const ContentAndHash& content_and_hash)
{
abi_tag_entries.emplace_back(helper.first, helper.second);
auto helpers_added_it = helpers_added.lower_bound(helper_name.c_str());
if (helpers_added_it != helpers_added.end() && *helpers_added_it == helper_name.c_str())
{
return;
}
if (!Strings::case_insensitive_ascii_contains(contents, helper_name))
{
return;
}

abi_tag_entries.emplace_back(helper_name, content_and_hash.hash().to_string());
helpers_added.insert(helpers_added_it, helper_name.c_str());
for (const auto& helper : helpers)
{
(*this)(content_and_hash.content().to_string(), helper.first, helper.second);
}
}
} add_helper_hash{helpers, abi_tag_entries, {}};
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kinda would like to see this 'add hashes of helpers and helpers of helpers' extracted into its own function and tests added.

@ras0219-msft
Copy link
Copy Markdown
Collaborator

Moving to draft since no changes since June.

@BillyONeal
Copy link
Copy Markdown
Member

This hasn't been looked at in over 6 months, so I'm closing.

@BillyONeal BillyONeal closed this Feb 10, 2022
@strega-nil strega-nil deleted the include-vcpkg.cmake-hash branch March 29, 2025 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants