stdenv multiple-outputs: change propagation rules

Now development stuff is propagated from the first output,
and userEnvPkgs from the one with binaries.

Also don't move *.la files (yet). It causes problems, and they're small.
This commit is contained in:
Vladimír Čunát 2015-04-18 15:46:00 +02:00
parent bf414c9d4f
commit d484c392aa
5 changed files with 55 additions and 38 deletions

View File

@ -28,6 +28,7 @@ let
libc_bin = if nativeLibc then null else libc.bin or libc;
libc_dev = if nativeLibc then null else libc.dev or libc;
libc_lib = if nativeLibc then null else libc.out or libc;
binutils_bin = if nativeTools then null else binutils.bin or binutils;
# The wrapper scripts use 'cat', so we may need coreutils.
coreutils_bin = if nativeTools then null else coreutils.bin or coreutils;
@ -40,7 +41,7 @@ stdenv.mkDerivation {
preferLocalBuild = true;
inherit cc shell libc_bin libc_dev binutils_bin coreutils_bin;
inherit cc shell libc_bin libc_dev libc_lib binutils_bin coreutils_bin;
passthru = { inherit libc nativeTools nativeLibc nativePrefix; };
@ -58,11 +59,11 @@ stdenv.mkDerivation {
''
+ optionalString (!nativeLibc) (if (!stdenv.isDarwin) then ''
dynamicLinker="${libc}/lib/$dynamicLinker"
dynamicLinker="${libc_lib}/lib/$dynamicLinker"
echo $dynamicLinker > $out/nix-support/dynamic-linker
if [ -e ${libc}/lib/32/ld-linux.so.2 ]; then
echo ${libc}/lib/32/ld-linux.so.2 > $out/nix-support/dynamic-linker-m32
if [ -e ${libc_lib}/lib/32/ld-linux.so.2 ]; then
echo ${libc_lib}/lib/32/ld-linux.so.2 > $out/nix-support/dynamic-linker-m32
fi
# The dynamic linker is passed in `ldflagsBefore' to allow
@ -87,11 +88,11 @@ stdenv.mkDerivation {
# compile, because it uses "#include_next <limits.h>" to find the
# limits.h file in ../includes-fixed. To remedy the problem,
# another -idirafter is necessary to add that directory again.
echo "-B${libc}/lib/ -idirafter ${libc_dev}/include -idirafter $cc/lib/gcc/*/*/include-fixed" > $out/nix-support/libc-cflags
echo "-B${libc_lib}/lib/ -idirafter ${libc_dev}/include -idirafter $cc/lib/gcc/*/*/include-fixed" > $out/nix-support/libc-cflags
echo "-L${libc}/lib" > $out/nix-support/libc-ldflags
echo "-L${libc_lib}/lib" > $out/nix-support/libc-ldflags
echo "${libc}" > $out/nix-support/orig-libc
echo "${libc_lib}" > $out/nix-support/orig-libc
''
+ (if nativeTools then ''

View File

@ -39,9 +39,6 @@ _overrideFirst outputDoc "doc" "out"
_overrideFirst outputMan "man" "doc" "$outputBin"
_overrideFirst outputInfo "info" "doc" "$outputMan"
# Make stdenv put propagated*BuildInputs into $outputDev instead of $out
propagateIntoOutput="${!outputDev}"
# Add standard flags to put files into the desired outputs.
_multioutConfig() {
@ -67,6 +64,7 @@ NIX_NO_SELF_RPATH=1
# Move subpaths that match pattern $1 from under any output/ to the $2 output/
# Beware: only * ? [..] patterns are accepted.
_moveToOutput() {
local patt="$1"
local dstOut="$2"
@ -108,30 +106,46 @@ _multioutDocs() {
# Move development-only stuff to the desired outputs.
_multioutDevs() {
if [ "$outputs" = "out" ] || [ -z "${moveToDev-1}" ]; then return; fi;
echo "Looking for development-only stuff to move between outputs"
echo "Looking for development-only stuff to move to $outputDev"
_moveToOutput include "${!outputInclude}"
_moveToOutput lib/pkgconfig "${!outputDev}"
_moveToOutput "lib/*.la" "${!outputDev}"
_moveToOutput share/pkgconfig "${!outputDev}"
echo "Patching *.pc includedir to output ${!outputInclude}"
for f in "${!outputDev}"/lib/pkgconfig/*.pc; do
# don't move libtool files yet
#_moveToOutput "lib/*.la" "${!outputDev}"
for f in "${!outputDev}"/{lib,share}/pkgconfig/*.pc; do
echo "Patching '$f' includedir to output ${!outputInclude}"
sed -i "/^includedir=/s,=\${prefix},=${!outputInclude}," "$f"
done
}
# Make ${!outputDev} propagate other outputs needed for development
# Make the first output (typically "dev") propagate other outputs needed for development.
# Take the first, because that's what one gets when putting the package into buildInputs.
# Note: during the build, probably only the "native" development packages are useful.
# With current cross-building setup, all packages are "native" if not cross-building.
_multioutPropagateDev() {
if [ "$outputs" = "out" ]; then return; fi;
if [ "${!outputInclude}" != "$propagateIntoOutput" ]; then
mkdir -p "$propagateIntoOutput"/nix-support
echo -n " ${!outputInclude}" >> "$propagateIntoOutput"/nix-support/propagated-native-build-inputs
fi
if [ "${!outputLib}" != "$propagateIntoOutput" ]; then
mkdir -p "$propagateIntoOutput"/nix-support
echo -n " ${!outputLib}" >> "$propagateIntoOutput"/nix-support/propagated-native-build-inputs
local outputFirst
for outputFirst in $outputs; do
break
done
# Default value: propagate binaries, includes and libraries
if [[ ! -v "$propagatedOutputs" ]]; then
local po_dirty="$outputBin $outputInclude $outputLib"
propagatedOutputs=`echo "$po_dirty" \
| tr -s ' ' '\n' | grep -v -F "$outputFirst" \
| sort -u | tr '\n' ' ' `
elif [ -z "$propagatedOutputs" ]; then
return # variable was explicitly set to empty
fi
mkdir -p "${!outputFirst}"/nix-support
for output in $propagatedOutputs; do
echo -n " ${!output}" >> "${!outputFirst}"/nix-support/propagated-native-build-inputs
done
}

View File

@ -46,8 +46,8 @@ stdenv.mkDerivation rec {
"-Uinstallusrbinperl"
"-Dinstallstyle=lib/perl5"
"-Duseshrplib"
"-Dlocincpth=${libc}/include"
"-Dloclibpth=${libc}/lib"
"-Dlocincpth=${libc.dev or libc}/include"
"-Dloclibpth=${libc.out or libc}/lib"
]
++ optional enableThreading "-Dusethreads";

View File

@ -119,7 +119,7 @@ stdenv.mkDerivation ({
installFlags = [ "sysconfdir=$(out)/etc" ];
outputs = [ "out" "dev" "bin" "static" ];
outputs = [ "dev" "out" "bin" "static" ];
buildInputs = [ ]
++ stdenv.lib.optionals (cross != null) [ gccCross ]

View File

@ -712,27 +712,29 @@ fixupPhase() {
prefix=${!output} runHook fixupOutput
done
# Multiple-output derivations mostly choose $dev instead of $out
local prOut="${propagateIntoOutput:-$out}"
# Propagate build inputs and setup hook into the development output.
if [ -n "$propagatedBuildInputs" ]; then
mkdir -p "$prOut/nix-support"
echo "$propagatedBuildInputs" > "$prOut/nix-support/propagated-build-inputs"
mkdir -p "${!outputDev}/nix-support"
echo "$propagatedBuildInputs" > "${!outputDev}/nix-support/propagated-build-inputs"
fi
if [ -n "$propagatedNativeBuildInputs" ]; then
mkdir -p "$prOut/nix-support"
echo "$propagatedNativeBuildInputs" > "$prOut/nix-support/propagated-native-build-inputs"
fi
if [ -n "$propagatedUserEnvPkgs" ]; then
mkdir -p "$prOut/nix-support"
echo "$propagatedUserEnvPkgs" > "$prOut/nix-support/propagated-user-env-packages"
mkdir -p "${!outputDev}/nix-support"
echo "$propagatedNativeBuildInputs" > "${!outputDev}/nix-support/propagated-native-build-inputs"
fi
if [ -n "$setupHook" ]; then
mkdir -p "$prOut/nix-support"
substituteAll "$setupHook" "$prOut/nix-support/setup-hook"
mkdir -p "${!outputDev}/nix-support"
substituteAll "$setupHook" "${!outputDev}/nix-support/setup-hook"
fi
# Propagate user-env packages into the output with binaries, TODO?
if [ -n "$propagatedUserEnvPkgs" ]; then
mkdir -p "${!outputBin}/nix-support"
echo "$propagatedUserEnvPkgs" > "${!outputBin}/nix-support/propagated-user-env-packages"
fi
runHook postFixup