Skip to content

Commit

Permalink
Add $outputStatic which defaults to $outputDev
Browse files Browse the repository at this point in the history
  • Loading branch information
Luabee committed May 18, 2023
1 parent c88f934 commit 8e61260
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
24 changes: 24 additions & 0 deletions pkgs/build-support/setup-hooks/multiple-outputs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
preConfigureHooks+=(_multioutConfig)
preFixupHooks+=(_multioutDocs)
preFixupHooks+=(_multioutDevs)
preFixupHooks+=(_multioutStatics)
postFixupHooks+=(_multioutPropagateDev)

# _assignFirst varName otherVarNames*
Expand Down Expand Up @@ -54,6 +55,10 @@ _overrideFirst outputInclude "$outputDev"
# so-libs are often among the main things to keep, and so go to $out
_overrideFirst outputLib "lib" "out"

# static library files shouldn't be installed adjacent to dynamic libs, since
# they are only ever used at build-time. Put them in $dev.
_overrideFirst outputStatic "static" "$outputDev"

_overrideFirst outputDoc "doc" "out"
_overrideFirst outputDevdoc "devdoc" REMOVE # documentation for developers
# man and info pages are small and often useful to distribute with binaries
Expand Down Expand Up @@ -179,6 +184,25 @@ _multioutDevs() {
done
}

# Move static libraries to the desired outputs.
_multioutStatics() {
if [ "$(getAllOutputNames)" = "out" ] || [ -z "${moveToStatic-1}" ]; then return; fi;

moveToOutput "lib/*.a" "${!outputStatic}"

local as=`find "${!outputStatic}/lib" -name "*.a" -type f`
local acount=`echo -n "$as" | wc -l`
if [ $acount != 0 ]; then
# Some of *.a files are linker scripts where moving broke the paths.
local output
for output in $outputs; do
if [ "${!output}" = "${!outputStatic}" ]; then continue; fi
sed "/^GROUP/s|${!output}/lib/lib|${!outputStatic}/lib/lib|g" \
-i $as
done
fi
}

# Make the "dev" propagate other outputs needed for development.
_multioutPropagateDev() {
if [ "$(getAllOutputNames)" = "out" ]; then return; fi;
Expand Down
1 change: 1 addition & 0 deletions pkgs/development/libraries/glibc/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ in
'';

separateDebugInfo = true;
moveToStatic = false; # Default $static output handling breaks things in this drv.

passthru =
(previousAttrs.passthru or {})
Expand Down

0 comments on commit 8e61260

Please sign in to comment.