vcpkg{,-tool}: move large part of the wrapper to vcpkg-tool
This commit is contained in:
parent
fb42a63593
commit
336e65d4a8
@ -7,7 +7,6 @@
|
||||
, fmt
|
||||
, git
|
||||
, gzip
|
||||
, makeWrapper
|
||||
, meson
|
||||
, ninja
|
||||
, openssh
|
||||
@ -30,7 +29,6 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
nativeBuildInputs = [
|
||||
cmake
|
||||
ninja
|
||||
makeWrapper
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
@ -47,7 +45,11 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
"-DVCPKG_DEPENDENCY_CMAKERC=ON"
|
||||
];
|
||||
|
||||
postFixup = let
|
||||
|
||||
# vcpkg needs two directories to write to that is independent of installation directory.
|
||||
# Since vcpkg already creates $HOME/.vcpkg/ we use that to create a root where vcpkg can write into.
|
||||
passAsFile = [ "vcpkgWrapper" ];
|
||||
vcpkgWrapper = let
|
||||
# These are the most common binaries used by vcpkg
|
||||
# Extra binaries can be added via overlay when needed
|
||||
runtimeDeps = [
|
||||
@ -63,7 +65,20 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
zstd
|
||||
] ++ extraRuntimeDeps;
|
||||
in ''
|
||||
wrapProgram $out/bin/vcpkg --prefix PATH ${lib.makeBinPath runtimeDeps}
|
||||
vcpkg_writable_path="$HOME/.vcpkg/root/"
|
||||
|
||||
export PATH="${lib.makeBinPath runtimeDeps}''${PATH:+":$PATH"}"
|
||||
|
||||
"${placeholder "out"}/bin/vcpkg" \
|
||||
--x-downloads-root="$vcpkg_writable_path"/downloads \
|
||||
--x-buildtrees-root="$vcpkg_writable_path"/buildtrees \
|
||||
--x-packages-root="$vcpkg_writable_path"/packages \
|
||||
"$@"
|
||||
'';
|
||||
|
||||
postFixup = ''
|
||||
mv "$out/bin/vcpkg" "$out/bin/.vcpkg-wrapped"
|
||||
install -Dm555 "$vcpkgWrapperPath" "$out/bin/vcpkg"
|
||||
'';
|
||||
|
||||
meta = {
|
||||
|
@ -2,7 +2,7 @@
|
||||
, stdenvNoCC
|
||||
, lib
|
||||
, vcpkg-tool
|
||||
, writeShellScript
|
||||
, makeWrapper
|
||||
}:
|
||||
|
||||
stdenvNoCC.mkDerivation (finalAttrs: {
|
||||
@ -16,25 +16,17 @@ stdenvNoCC.mkDerivation (finalAttrs: {
|
||||
hash = "sha256-eDpMGDtC44eh0elLWV0r1H/WbpVdZ5qMedKh7Ct50Cs=";
|
||||
};
|
||||
|
||||
installPhase = let
|
||||
# vcpkg needs two directories to write to that is independent of installation directory.
|
||||
# Since vcpkg already creates $HOME/.vcpkg/ we use that to create a root where vcpkg can write into.
|
||||
vcpkgScript = writeShellScript "vcpkg" ''
|
||||
vcpkg_writable_path="$HOME/.vcpkg/root/"
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
|
||||
VCPKG_ROOT="@out@/share/vcpkg" ${vcpkg-tool}/bin/vcpkg \
|
||||
--x-downloads-root="$vcpkg_writable_path"/downloads \
|
||||
--x-buildtrees-root="$vcpkg_writable_path"/buildtrees \
|
||||
--x-packages-root="$vcpkg_writable_path"/packages \
|
||||
"$@"
|
||||
'';
|
||||
in ''
|
||||
installPhase = ''
|
||||
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/
|
||||
substitute ${vcpkgScript} $out/bin/vcpkg --subst-var-by out $out
|
||||
chmod +x $out/bin/vcpkg
|
||||
|
||||
makeWrapper "${vcpkg-tool}/bin/vcpkg" "$out/bin/vcpkg" \
|
||||
--set-default VCPKG_ROOT "$out/share/vcpkg"
|
||||
|
||||
ln -s $out/bin/vcpkg $out/share/vcpkg/vcpkg
|
||||
touch $out/share/vcpkg/vcpkg.disable-metrics
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user