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: support builtin-baseline without git #329939

Merged
merged 2 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pkgs/by-name/vc/vcpkg-tool/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ stdenv.mkDerivation (finalAttrs: {

patches = [
./change-lock-location.patch
./read-bundle-info-from-root.patch
];

cmakeFlags = [
Expand Down
43 changes: 43 additions & 0 deletions pkgs/by-name/vc/vcpkg-tool/read-bundle-info-from-root.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
diff --git a/include/vcpkg/vcpkgpaths.h b/include/vcpkg/vcpkgpaths.h
index 90fd4d09..ebc6342b 100644
--- a/include/vcpkg/vcpkgpaths.h
+++ b/include/vcpkg/vcpkgpaths.h
@@ -28,6 +28,8 @@

namespace vcpkg
{
+ Path exported_determine_root(const ReadOnlyFilesystem& fs, const Path& original_cwd, const VcpkgCmdArguments& args);
+
struct ToolsetArchOption
{
ZStringView name;
diff --git a/src/vcpkg.cpp b/src/vcpkg.cpp
index 2b62cb55..d7b8ead5 100644
--- a/src/vcpkg.cpp
+++ b/src/vcpkg.cpp
@@ -296,7 +296,8 @@ int main(const int argc, const char* const* const argv)
Debug::println("To include the environment variables in debug output, pass --debug-env");
}
args.check_feature_flag_consistency();
- const auto current_exe_path = get_exe_path_of_current_process();
+ const auto current_exe_path =
+ exported_determine_root(real_filesystem, real_filesystem.current_path(VCPKG_LINE_INFO), args) / "vcpkg";

bool to_enable_metrics = true;
{
diff --git a/src/vcpkg/vcpkgpaths.cpp b/src/vcpkg/vcpkgpaths.cpp
index 77e107f5..132050ba 100644
--- a/src/vcpkg/vcpkgpaths.cpp
+++ b/src/vcpkg/vcpkgpaths.cpp
@@ -518,6 +518,11 @@ namespace

namespace vcpkg
{
+ Path exported_determine_root(const ReadOnlyFilesystem& fs, const Path& original_cwd, const VcpkgCmdArguments& args)
+ {
+ return determine_root(fs, original_cwd, args);
+ }
+
Path InstalledPaths::listfile_path(const BinaryParagraph& pgh) const
{
return this->vcpkg_dir_info() / (pgh.fullstem() + ".list");
23 changes: 20 additions & 3 deletions pkgs/by-name/vc/vcpkg/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,24 @@ stdenvNoCC.mkDerivation (finalAttrs: {
owner = "microsoft";
repo = "vcpkg";
rev = finalAttrs.version;
hash = "sha256-HT7IcznN5W+Innzg0aeOvZnpVUTf/uJFlYflE91YJQA=";
hash = "sha256-WE+BeF9BYR9/Gmi60g6ApXsWQ2vch2N6XhH1A9HAHsc=";
leaveDotGit = true;
postFetch = ''
cd "$out"
VCPKG_BASELINE_COMMIT_SHA=$(git rev-parse --verify HEAD)
# We only needed the .git folder for that previous command, so we can safely delete it now.
# If we don’t delete it, then we might run into problems (see #8567).
rm -r .git
# Here's the code that Creates this json file in Visual Studio deployment and the code that reads it:
# https://github.com/microsoft/vcpkg-tool/blob/f098d3e0aaa7e46ea84a1f7079586e1ec5af8ab5/vcpkg-init/mint-standalone-bundle.ps1#L21
# https://github.com/microsoft/vcpkg-tool/blob/f098d3e0aaa7e46ea84a1f7079586e1ec5af8ab5/src/vcpkg/bundlesettings.cpp#L87
#
# Here's the code that we target with this setting. If we use embeddedsha combined with usegitregistry, vcpkg
# will checkout a remote instead of trying to do git operation in the vcpkg root
# https://github.com/microsoft/vcpkg-tool/blob/d272c0d4f5175b26bd56c6109d4c4935b791a157/src/vcpkg/vcpkgpaths.cpp#L920
# https://github.com/microsoft/vcpkg-tool/blob/d272c0d4f5175b26bd56c6109d4c4935b791a157/src/vcpkg/configuration.cpp#L718
echo '{ "readonly": true, "usegitregistry": true, "deployment": "Git", "embeddedsha": "'"$VCPKG_BASELINE_COMMIT_SHA"'" }' > vcpkg-bundle.json
'';
};

nativeBuildInputs = [ makeWrapper ];
Expand All @@ -36,7 +53,7 @@ stdenvNoCC.mkDerivation (finalAttrs: {
runHook preInstall

mkdir -p "$out/bin" "$out/share/vcpkg/scripts/buildsystems"
cp --preserve=mode -r ./{docs,ports,triplets,scripts,.vcpkg-root,versions,LICENSE.txt} "$out/share/vcpkg/"
cp --preserve=mode -r ./{docs,ports,triplets,scripts,.vcpkg-root,versions,LICENSE.txt,vcpkg-bundle.json} "$out/share/vcpkg/"

${lib.optionalString doWrap ''
makeWrapper "${vcpkg-tool}/bin/vcpkg" "$out/bin/vcpkg" \
Expand All @@ -50,7 +67,7 @@ stdenvNoCC.mkDerivation (finalAttrs: {
'';

meta = {
description = "C++ Library Manager";
description = "C++ Library Manager for Windows, Linux, and macOS";
mainProgram = "vcpkg";
homepage = "https://vcpkg.io/";
license = lib.licenses.mit;
Expand Down