Merge pull request #329939 from gracicot/gracicot/vcpkg-bundle

vcpkg: support builtin-baseline without git
This commit is contained in:
Sebastián Mancilla 2024-08-15 21:29:31 -04:00 committed by GitHub
commit 0da03f4801
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 64 additions and 3 deletions

View File

@ -44,6 +44,7 @@ stdenv.mkDerivation (finalAttrs: {
patches = [
./change-lock-location.patch
./read-bundle-info-from-root.patch
];
cmakeFlags = [

View File

@ -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");

View File

@ -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 dont 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 ];
@ -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" \
@ -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;