gprbuild: fix rpath only when targeting darwin

This commit is contained in:
Weijia Wang 2023-05-10 22:26:38 +03:00 committed by sternenseemann
parent a8eea70935
commit 6034ebb9ff
4 changed files with 19 additions and 15 deletions

View file

@ -53,7 +53,14 @@ stdenv.mkDerivation {
# introducing a wrapper for it in the future remains TODO.
# For the moment this doesn't matter since we have no situation
# were gprbuild is used to build something used at build time.
setupHook = ./gpr-project-path-hook.sh;
setupHooks = [
./gpr-project-path-hook.sh
] ++ lib.optionals stdenv.targetPlatform.isDarwin [
# This setupHook replaces the paths of shared libraries starting
# with @rpath with the absolute paths on Darwin, so that the
# binaries can be run without additional setup.
./gpr-project-darwin-rpath-hook.sh
];
installPhase = ''
runHook preInstall

View file

@ -17,7 +17,7 @@ stdenv.mkDerivation {
inherit (gprbuild-boot)
version
src
setupHook
setupHooks
meta
;

View file

@ -0,0 +1,10 @@
fixGprProjectDarwinRpath() {
for f in $(find $out -type f -executable); do
install_name_tool -id $f $f || true
for rpath in $(otool -L $f | grep @rpath | awk '{print $1}'); do
install_name_tool -change $rpath ${!outputLib}/lib/$(basename $rpath) $f || true
done
done
}
preFixupPhases+=" fixGprProjectDarwinRpath"

View file

@ -6,16 +6,3 @@ addAdaObjectsPath() {
}
addEnvHooks "$targetOffset" addAdaObjectsPath
fixDarwinRpath() {
for f in $(find $out -type f -executable); do
install_name_tool -id $f $f || true
for rpath in $(otool -L $f | grep rpath | awk '{print $1}'); do
install_name_tool -change $rpath $out/lib/$(basename $rpath) $f || true
done
done
}
if [ "$(uname)" = "Darwin" ]; then
preFixupPhases+=" fixDarwinRpath"
fi