commit
268d510024
@ -24,7 +24,8 @@ bintoolsWrapper_addLDVars () {
|
|||||||
# Python and Haskell packages often only have directories like $out/lib/ghc-8.4.3/ or
|
# Python and Haskell packages often only have directories like $out/lib/ghc-8.4.3/ or
|
||||||
# $out/lib/python3.6/, so having them in LDFLAGS just makes the linker search unnecessary
|
# $out/lib/python3.6/, so having them in LDFLAGS just makes the linker search unnecessary
|
||||||
# directories and bloats the size of the environment variable space.
|
# directories and bloats the size of the environment variable space.
|
||||||
if [[ -n "$(echo $1/lib/lib*)" ]]; then
|
local -a glob=( $1/lib/lib* )
|
||||||
|
if [ "${#glob[*]}" -gt 0 ]; then
|
||||||
export NIX_${role_pre}LDFLAGS+=" -L$1/lib"
|
export NIX_${role_pre}LDFLAGS+=" -L$1/lib"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -61,9 +62,8 @@ do
|
|||||||
if
|
if
|
||||||
PATH=$_PATH type -p "@targetPrefix@${cmd}" > /dev/null
|
PATH=$_PATH type -p "@targetPrefix@${cmd}" > /dev/null
|
||||||
then
|
then
|
||||||
upper_case="$(echo "$cmd" | tr "[:lower:]" "[:upper:]")"
|
export "${role_pre}${cmd^^}=@targetPrefix@${cmd}";
|
||||||
export "${role_pre}${upper_case}=@targetPrefix@${cmd}";
|
export "${cmd^^}${role_post}=@targetPrefix@${cmd}";
|
||||||
export "${upper_case}${role_post}=@targetPrefix@${cmd}";
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -17,7 +17,8 @@ fi
|
|||||||
# code). The hooks for <hookName> are the shell function or variable
|
# code). The hooks for <hookName> are the shell function or variable
|
||||||
# <hookName>, and the values of the shell array ‘<hookName>Hooks’.
|
# <hookName>, and the values of the shell array ‘<hookName>Hooks’.
|
||||||
runHook() {
|
runHook() {
|
||||||
local oldOpts="$(shopt -po nounset)"
|
local oldOpts="-u"
|
||||||
|
shopt -qo nounset || oldOpts="+u"
|
||||||
set -u # May be called from elsewhere, so do `set -u`.
|
set -u # May be called from elsewhere, so do `set -u`.
|
||||||
|
|
||||||
local hookName="$1"
|
local hookName="$1"
|
||||||
@ -32,7 +33,7 @@ runHook() {
|
|||||||
set -u # To balance `_eval`
|
set -u # To balance `_eval`
|
||||||
done
|
done
|
||||||
|
|
||||||
eval "${oldOpts}"
|
set "$oldOpts"
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,7 +41,8 @@ runHook() {
|
|||||||
# Run all hooks with the specified name, until one succeeds (returns a
|
# Run all hooks with the specified name, until one succeeds (returns a
|
||||||
# zero exit code). If none succeed, return a non-zero exit code.
|
# zero exit code). If none succeed, return a non-zero exit code.
|
||||||
runOneHook() {
|
runOneHook() {
|
||||||
local oldOpts="$(shopt -po nounset)"
|
local oldOpts="-u"
|
||||||
|
shopt -qo nounset || oldOpts="+u"
|
||||||
set -u # May be called from elsewhere, so do `set -u`.
|
set -u # May be called from elsewhere, so do `set -u`.
|
||||||
|
|
||||||
local hookName="$1"
|
local hookName="$1"
|
||||||
@ -57,7 +59,7 @@ runOneHook() {
|
|||||||
set -u # To balance `_eval`
|
set -u # To balance `_eval`
|
||||||
done
|
done
|
||||||
|
|
||||||
eval "${oldOpts}"
|
set "$oldOpts"
|
||||||
return "$ret"
|
return "$ret"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,21 +73,18 @@ _callImplicitHook() {
|
|||||||
set -u
|
set -u
|
||||||
local def="$1"
|
local def="$1"
|
||||||
local hookName="$2"
|
local hookName="$2"
|
||||||
case "$(type -t "$hookName")" in
|
if declare -F "$hookName" > /dev/null; then
|
||||||
(function|alias|builtin)
|
|
||||||
set +u
|
set +u
|
||||||
"$hookName";;
|
"$hookName"
|
||||||
(file)
|
elif type -p "$hookName" > /dev/null; then
|
||||||
set +u
|
set +u
|
||||||
source "$hookName";;
|
source "$hookName"
|
||||||
(keyword) :;;
|
elif [ -n "${!hookName:-}" ]; then
|
||||||
(*) if [ -z "${!hookName:-}" ]; then
|
|
||||||
return "$def";
|
|
||||||
else
|
|
||||||
set +u
|
set +u
|
||||||
eval "${!hookName}"
|
eval "${!hookName}"
|
||||||
fi;;
|
else
|
||||||
esac
|
return "$def"
|
||||||
|
fi
|
||||||
# `_eval` expects hook to need nounset disable and leave it
|
# `_eval` expects hook to need nounset disable and leave it
|
||||||
# disabled anyways, so Ok to to delegate. The alternative of a
|
# disabled anyways, so Ok to to delegate. The alternative of a
|
||||||
# return trap is no good because it would affect nested returns.
|
# return trap is no good because it would affect nested returns.
|
||||||
@ -96,7 +95,7 @@ _callImplicitHook() {
|
|||||||
# hooks exits the hook, not the caller. Also will only pass args if
|
# hooks exits the hook, not the caller. Also will only pass args if
|
||||||
# command can take them
|
# command can take them
|
||||||
_eval() {
|
_eval() {
|
||||||
if [ "$(type -t "$1")" = function ]; then
|
if declare -F "$1" > /dev/null 2>&1; then
|
||||||
set +u
|
set +u
|
||||||
"$@" # including args
|
"$@" # including args
|
||||||
else
|
else
|
||||||
@ -401,6 +400,7 @@ findInputs() {
|
|||||||
# The current package's host and target offset together
|
# The current package's host and target offset together
|
||||||
# provide a <=-preserving homomorphism from the relative
|
# provide a <=-preserving homomorphism from the relative
|
||||||
# offsets to current offset
|
# offsets to current offset
|
||||||
|
local -i mapOffsetResult
|
||||||
function mapOffset() {
|
function mapOffset() {
|
||||||
local -ri inputOffset="$1"
|
local -ri inputOffset="$1"
|
||||||
if (( "$inputOffset" <= 0 )); then
|
if (( "$inputOffset" <= 0 )); then
|
||||||
@ -408,7 +408,7 @@ findInputs() {
|
|||||||
else
|
else
|
||||||
local -ri outputOffset="$inputOffset - 1 + $targetOffset"
|
local -ri outputOffset="$inputOffset - 1 + $targetOffset"
|
||||||
fi
|
fi
|
||||||
echo "$outputOffset"
|
mapOffsetResult="$outputOffset"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Host offset relative to that of the package whose immediate
|
# Host offset relative to that of the package whose immediate
|
||||||
@ -420,8 +420,8 @@ findInputs() {
|
|||||||
|
|
||||||
# Host offset relative to the package currently being
|
# Host offset relative to the package currently being
|
||||||
# built---as absolute an offset as will be used.
|
# built---as absolute an offset as will be used.
|
||||||
local -i hostOffsetNext
|
mapOffset relHostOffset
|
||||||
hostOffsetNext="$(mapOffset relHostOffset)"
|
local -i hostOffsetNext="$mapOffsetResult"
|
||||||
|
|
||||||
# Ensure we're in bounds relative to the package currently
|
# Ensure we're in bounds relative to the package currently
|
||||||
# being built.
|
# being built.
|
||||||
@ -439,8 +439,8 @@ findInputs() {
|
|||||||
|
|
||||||
# Target offset relative to the package currently being
|
# Target offset relative to the package currently being
|
||||||
# built.
|
# built.
|
||||||
local -i targetOffsetNext
|
mapOffset relTargetOffset
|
||||||
targetOffsetNext="$(mapOffset relTargetOffset)"
|
local -i targetOffsetNext="$mapOffsetResult"
|
||||||
|
|
||||||
# Once again, ensure we're in bounds relative to the
|
# Once again, ensure we're in bounds relative to the
|
||||||
# package currently being built.
|
# package currently being built.
|
||||||
@ -449,7 +449,8 @@ findInputs() {
|
|||||||
[[ -f "$pkg/nix-support/$file" ]] || continue
|
[[ -f "$pkg/nix-support/$file" ]] || continue
|
||||||
|
|
||||||
local pkgNext
|
local pkgNext
|
||||||
for pkgNext in $(< "$pkg/nix-support/$file"); do
|
read -r -d '' pkgNext < "$pkg/nix-support/$file" || true
|
||||||
|
for pkgNext in $pkgNext; do
|
||||||
findInputs "$pkgNext" "$hostOffsetNext" "$targetOffsetNext"
|
findInputs "$pkgNext" "$hostOffsetNext" "$targetOffsetNext"
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
@ -500,10 +501,11 @@ activatePackage() {
|
|||||||
(( "$hostOffset" <= "$targetOffset" )) || exit -1
|
(( "$hostOffset" <= "$targetOffset" )) || exit -1
|
||||||
|
|
||||||
if [ -f "$pkg" ]; then
|
if [ -f "$pkg" ]; then
|
||||||
local oldOpts="$(shopt -po nounset)"
|
local oldOpts="-u"
|
||||||
|
shopt -qo nounset || oldOpts="+u"
|
||||||
set +u
|
set +u
|
||||||
source "$pkg"
|
source "$pkg"
|
||||||
eval "$oldOpts"
|
set "$oldOpts"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Only dependencies whose host platform is guaranteed to match the
|
# Only dependencies whose host platform is guaranteed to match the
|
||||||
@ -522,10 +524,11 @@ activatePackage() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -f "$pkg/nix-support/setup-hook" ]]; then
|
if [[ -f "$pkg/nix-support/setup-hook" ]]; then
|
||||||
local oldOpts="$(shopt -po nounset)"
|
local oldOpts="-u"
|
||||||
|
shopt -qo nounset || oldOpts="+u"
|
||||||
set +u
|
set +u
|
||||||
source "$pkg/nix-support/setup-hook"
|
source "$pkg/nix-support/setup-hook"
|
||||||
eval "$oldOpts"
|
set "$oldOpts"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1273,17 +1276,19 @@ showPhaseHeader() {
|
|||||||
|
|
||||||
genericBuild() {
|
genericBuild() {
|
||||||
if [ -f "${buildCommandPath:-}" ]; then
|
if [ -f "${buildCommandPath:-}" ]; then
|
||||||
local oldOpts="$(shopt -po nounset)"
|
local oldOpts="-u"
|
||||||
|
shopt -qo nounset || oldOpts="+u"
|
||||||
set +u
|
set +u
|
||||||
source "$buildCommandPath"
|
source "$buildCommandPath"
|
||||||
eval "$oldOpts"
|
set "$oldOpts"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
if [ -n "${buildCommand:-}" ]; then
|
if [ -n "${buildCommand:-}" ]; then
|
||||||
local oldOpts="$(shopt -po nounset)"
|
local oldOpts="-u"
|
||||||
|
shopt -qo nounset || oldOpts="+u"
|
||||||
set +u
|
set +u
|
||||||
eval "$buildCommand"
|
eval "$buildCommand"
|
||||||
eval "$oldOpts"
|
set "$oldOpts"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -1313,10 +1318,11 @@ genericBuild() {
|
|||||||
|
|
||||||
# Evaluate the variable named $curPhase if it exists, otherwise the
|
# Evaluate the variable named $curPhase if it exists, otherwise the
|
||||||
# function named $curPhase.
|
# function named $curPhase.
|
||||||
local oldOpts="$(shopt -po nounset)"
|
local oldOpts="-u"
|
||||||
|
shopt -qo nounset || oldOpts="+u"
|
||||||
set +u
|
set +u
|
||||||
eval "${!curPhase:-$curPhase}"
|
eval "${!curPhase:-$curPhase}"
|
||||||
eval "$oldOpts"
|
set "$oldOpts"
|
||||||
|
|
||||||
if [ "$curPhase" = unpackPhase ]; then
|
if [ "$curPhase" = unpackPhase ]; then
|
||||||
cd "${sourceRoot:-.}"
|
cd "${sourceRoot:-.}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user