|
|
|
@ -1,4 +1,3 @@
|
|
|
|
|
# shellcheck shell=bash
|
|
|
|
|
set -eu
|
|
|
|
|
set -o pipefail
|
|
|
|
|
|
|
|
|
@ -12,7 +11,7 @@ if (( "${NIX_DEBUG:-0}" >= 6 )); then
|
|
|
|
|
set -x
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
: "${outputs:=out}"
|
|
|
|
|
: ${outputs:=out}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
######################################################################
|
|
|
|
@ -69,8 +68,7 @@ _callImplicitHook() {
|
|
|
|
|
local hookName="$2"
|
|
|
|
|
if declare -F "$hookName" > /dev/null; then
|
|
|
|
|
"$hookName"
|
|
|
|
|
elif test -e "$hookName" ; then
|
|
|
|
|
# shellcheck disable=SC1090
|
|
|
|
|
elif type -p "$hookName" > /dev/null; then
|
|
|
|
|
source "$hookName"
|
|
|
|
|
elif [ -n "${!hookName:-}" ]; then
|
|
|
|
|
eval "${!hookName}"
|
|
|
|
@ -124,14 +122,13 @@ exitHandler() {
|
|
|
|
|
|
|
|
|
|
if [ -n "${showBuildStats:-}" ]; then
|
|
|
|
|
times > "$NIX_BUILD_TOP/.times"
|
|
|
|
|
local -a buildTimesArray
|
|
|
|
|
IFS=" " read -r -a buildTimesArray < "$NIX_BUILD_TOP/.times"
|
|
|
|
|
local -a times=($(cat "$NIX_BUILD_TOP/.times"))
|
|
|
|
|
# Print the following statistics:
|
|
|
|
|
# - user time for the shell
|
|
|
|
|
# - system time for the shell
|
|
|
|
|
# - user time for all child processes
|
|
|
|
|
# - system time for all child processes
|
|
|
|
|
echo "build time elapsed: " "${buildTimesArray[@]}"
|
|
|
|
|
echo "build time elapsed: " "${times[@]}"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if (( "$exitCode" != 0 )); then
|
|
|
|
@ -143,7 +140,6 @@ exitHandler() {
|
|
|
|
|
# normally. Otherwise, return the original exit code.
|
|
|
|
|
if [ -n "${succeedOnFailure:-}" ]; then
|
|
|
|
|
echo "build failed with exit code $exitCode (ignored)"
|
|
|
|
|
# shellcheck disable=SC2154
|
|
|
|
|
mkdir -p "$out/nix-support"
|
|
|
|
|
printf "%s" "$exitCode" > "$out/nix-support/failed"
|
|
|
|
|
exit 0
|
|
|
|
@ -236,7 +232,7 @@ printWords() {
|
|
|
|
|
# implementation uses zip archive and zip does not support dates going back to
|
|
|
|
|
# 1970.
|
|
|
|
|
export SOURCE_DATE_EPOCH
|
|
|
|
|
: "${SOURCE_DATE_EPOCH:=315532800}"
|
|
|
|
|
: ${SOURCE_DATE_EPOCH:=315532800}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Wildcard expansions that don't match should expand to an empty list.
|
|
|
|
@ -246,10 +242,8 @@ shopt -s nullglob
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Set up the initial path.
|
|
|
|
|
# shellcheck disable=SC2123
|
|
|
|
|
PATH=
|
|
|
|
|
HOST_PATH=
|
|
|
|
|
# shellcheck disable=SC2154
|
|
|
|
|
for i in $initialPath; do
|
|
|
|
|
if [ "$i" = / ]; then i=; fi
|
|
|
|
|
addToSearchPath PATH "$i/bin"
|
|
|
|
@ -312,10 +306,6 @@ declare -a pkgTargetHookVars=(envTargetTargetHook)
|
|
|
|
|
|
|
|
|
|
declare -a pkgHookVarVars=(pkgBuildHookVars pkgHostHookVars pkgTargetHookVars)
|
|
|
|
|
|
|
|
|
|
# those variables are declared here, since where and if they are used varies
|
|
|
|
|
# shellcheck disable=SC2034
|
|
|
|
|
declare -a preFixupHooks fixupOutputHooks preConfigureHooks postFixupHooks postUnpackHooks unpackCmdHooks
|
|
|
|
|
|
|
|
|
|
# Add env hooks for all sorts of deps with the specified host offset.
|
|
|
|
|
addEnvHooks() {
|
|
|
|
|
local depHostOffset="$1"
|
|
|
|
@ -357,14 +347,14 @@ declare -a allPlatOffsets=(-1 0 1)
|
|
|
|
|
# implements.
|
|
|
|
|
findInputs() {
|
|
|
|
|
local -r pkg="$1"
|
|
|
|
|
local -r hostOffset="$2"
|
|
|
|
|
local -r targetOffset="$3"
|
|
|
|
|
local -ri hostOffset="$2"
|
|
|
|
|
local -ri targetOffset="$3"
|
|
|
|
|
|
|
|
|
|
# Sanity check
|
|
|
|
|
(( "$hostOffset" <= "$targetOffset" )) || exit 1
|
|
|
|
|
(( "$hostOffset" <= "$targetOffset" )) || exit -1
|
|
|
|
|
|
|
|
|
|
local varVar="${pkgAccumVarVars[$(( hostOffset + 1 ))]}"
|
|
|
|
|
local varRef="${varVar}[$(( targetOffset - hostOffset ))]"
|
|
|
|
|
local varVar="${pkgAccumVarVars[$hostOffset + 1]}"
|
|
|
|
|
local varRef="$varVar[\$targetOffset - \$hostOffset]"
|
|
|
|
|
local var="${!varRef}"
|
|
|
|
|
unset -v varVar varRef
|
|
|
|
|
|
|
|
|
@ -372,7 +362,7 @@ findInputs() {
|
|
|
|
|
# nix-shell doesn't use impure bash. This should replace the O(n)
|
|
|
|
|
# case with an O(1) hash map lookup, assuming bash is implemented
|
|
|
|
|
# well :D.
|
|
|
|
|
local varSlice="${var}[*]"
|
|
|
|
|
local varSlice="$var[*]"
|
|
|
|
|
# ${..-} to hack around old bash empty array problem
|
|
|
|
|
case "${!varSlice-}" in
|
|
|
|
|
*" $pkg "*) return 0 ;;
|
|
|
|
@ -389,28 +379,28 @@ findInputs() {
|
|
|
|
|
# The current package's host and target offset together
|
|
|
|
|
# provide a <=-preserving homomorphism from the relative
|
|
|
|
|
# offsets to current offset
|
|
|
|
|
local mapOffsetResult
|
|
|
|
|
local -i mapOffsetResult
|
|
|
|
|
function mapOffset() {
|
|
|
|
|
local -r inputOffset="$1"
|
|
|
|
|
local -ri inputOffset="$1"
|
|
|
|
|
if (( "$inputOffset" <= 0 )); then
|
|
|
|
|
local -r outputOffset=$(( inputOffset + hostOffset ))
|
|
|
|
|
local -ri outputOffset="$inputOffset + $hostOffset"
|
|
|
|
|
else
|
|
|
|
|
local -r outputOffset=$(( inputOffset - 1 + targetOffset ))
|
|
|
|
|
local -ri outputOffset="$inputOffset - 1 + $targetOffset"
|
|
|
|
|
fi
|
|
|
|
|
mapOffsetResult="$outputOffset"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Host offset relative to that of the package whose immediate
|
|
|
|
|
# dependencies we are currently exploring.
|
|
|
|
|
local relHostOffset
|
|
|
|
|
local -i relHostOffset
|
|
|
|
|
for relHostOffset in "${allPlatOffsets[@]}"; do
|
|
|
|
|
# `+ 1` so we start at 0 for valid index
|
|
|
|
|
local files="${propagatedDepFilesVars[$(( relHostOffset + 1 ))]}"
|
|
|
|
|
local files="${propagatedDepFilesVars[$relHostOffset + 1]}"
|
|
|
|
|
|
|
|
|
|
# Host offset relative to the package currently being
|
|
|
|
|
# built---as absolute an offset as will be used.
|
|
|
|
|
mapOffset "$relHostOffset"
|
|
|
|
|
local hostOffsetNext="$mapOffsetResult"
|
|
|
|
|
mapOffset relHostOffset
|
|
|
|
|
local -i hostOffsetNext="$mapOffsetResult"
|
|
|
|
|
|
|
|
|
|
# Ensure we're in bounds relative to the package currently
|
|
|
|
|
# being built.
|
|
|
|
@ -418,18 +408,18 @@ findInputs() {
|
|
|
|
|
|
|
|
|
|
# Target offset relative to the *host* offset of the package
|
|
|
|
|
# whose immediate dependencies we are currently exploring.
|
|
|
|
|
local relTargetOffset
|
|
|
|
|
local -i relTargetOffset
|
|
|
|
|
for relTargetOffset in "${allPlatOffsets[@]}"; do
|
|
|
|
|
(( "$relHostOffset" <= "$relTargetOffset" )) || continue
|
|
|
|
|
|
|
|
|
|
local fileRef="${files}[$(( relTargetOffset - relHostOffset ))]"
|
|
|
|
|
local fileRef="${files}[$relTargetOffset - $relHostOffset]"
|
|
|
|
|
local file="${!fileRef}"
|
|
|
|
|
unset -v fileRef
|
|
|
|
|
|
|
|
|
|
# Target offset relative to the package currently being
|
|
|
|
|
# built.
|
|
|
|
|
mapOffset "$relTargetOffset"
|
|
|
|
|
local targetOffsetNext="$mapOffsetResult"
|
|
|
|
|
mapOffset relTargetOffset
|
|
|
|
|
local -i targetOffsetNext="$mapOffsetResult"
|
|
|
|
|
|
|
|
|
|
# Once again, ensure we're in bounds relative to the
|
|
|
|
|
# package currently being built.
|
|
|
|
@ -447,12 +437,12 @@ findInputs() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Make sure all are at least defined as empty
|
|
|
|
|
: "${depsBuildBuild=}" "${depsBuildBuildPropagated=}"
|
|
|
|
|
: "${nativeBuildInputs=}" "${propagatedNativeBuildInputs=}" "${defaultNativeBuildInputs=}"
|
|
|
|
|
: "${depsBuildTarget=}" "${depsBuildTargetPropagated=}"
|
|
|
|
|
: "${depsHostHost=}" "${depsHostHostPropagated=}"
|
|
|
|
|
: "${buildInputs=}" "${propagatedBuildInputs=}" "${defaultBuildInputs=}"
|
|
|
|
|
: "${depsTargetTarget=}" "${depsTargetTargetPropagated=}"
|
|
|
|
|
: ${depsBuildBuild=} ${depsBuildBuildPropagated=}
|
|
|
|
|
: ${nativeBuildInputs=} ${propagatedNativeBuildInputs=} ${defaultNativeBuildInputs=}
|
|
|
|
|
: ${depsBuildTarget=} ${depsBuildTargetPropagated=}
|
|
|
|
|
: ${depsHostHost=} ${depsHostHostPropagated=}
|
|
|
|
|
: ${buildInputs=} ${propagatedBuildInputs=} ${defaultBuildInputs=}
|
|
|
|
|
: ${depsTargetTarget=} ${depsTargetTargetPropagated=}
|
|
|
|
|
|
|
|
|
|
for pkg in $depsBuildBuild $depsBuildBuildPropagated; do
|
|
|
|
|
findInputs "$pkg" -1 -1
|
|
|
|
@ -483,14 +473,13 @@ done
|
|
|
|
|
# Add package to the future PATH and run setup hooks
|
|
|
|
|
activatePackage() {
|
|
|
|
|
local pkg="$1"
|
|
|
|
|
local -r hostOffset="$2"
|
|
|
|
|
local -r targetOffset="$3"
|
|
|
|
|
local -ri hostOffset="$2"
|
|
|
|
|
local -ri targetOffset="$3"
|
|
|
|
|
|
|
|
|
|
# Sanity check
|
|
|
|
|
(( "$hostOffset" <= "$targetOffset" )) || exit 1
|
|
|
|
|
(( "$hostOffset" <= "$targetOffset" )) || exit -1
|
|
|
|
|
|
|
|
|
|
if [ -f "$pkg" ]; then
|
|
|
|
|
# shellcheck disable=SC1090
|
|
|
|
|
source "$pkg"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
@ -514,19 +503,19 @@ activatePackage() {
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [[ -f "$pkg/nix-support/setup-hook" ]]; then
|
|
|
|
|
# shellcheck disable=SC1091
|
|
|
|
|
source "$pkg/nix-support/setup-hook"
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_activatePkgs() {
|
|
|
|
|
local hostOffset targetOffset pkg
|
|
|
|
|
local -i hostOffset targetOffset
|
|
|
|
|
local pkg
|
|
|
|
|
|
|
|
|
|
for hostOffset in "${allPlatOffsets[@]}"; do
|
|
|
|
|
local pkgsVar="${pkgAccumVarVars[$(( hostOffset + 1 ))]}"
|
|
|
|
|
local pkgsVar="${pkgAccumVarVars[$hostOffset + 1]}"
|
|
|
|
|
for targetOffset in "${allPlatOffsets[@]}"; do
|
|
|
|
|
(( "$hostOffset" <= "$targetOffset" )) || continue
|
|
|
|
|
local pkgsRef="${pkgsVar}[$(( targetOffset - hostOffset ))]"
|
|
|
|
|
local pkgsRef="${pkgsVar}[$targetOffset - $hostOffset]"
|
|
|
|
|
local pkgsSlice="${!pkgsRef}[@]"
|
|
|
|
|
for pkg in ${!pkgsSlice+"${!pkgsSlice}"}; do
|
|
|
|
|
activatePackage "$pkg" "$hostOffset" "$targetOffset"
|
|
|
|
@ -547,14 +536,15 @@ _activatePkgs
|
|
|
|
|
# with this information to the relevant env hook array, but bash
|
|
|
|
|
# doesn't have closures, so it's easier to just pass this in.
|
|
|
|
|
_addToEnv() {
|
|
|
|
|
local depHostOffset depTargetOffset pkg
|
|
|
|
|
local -i depHostOffset depTargetOffset
|
|
|
|
|
local pkg
|
|
|
|
|
|
|
|
|
|
for depHostOffset in "${allPlatOffsets[@]}"; do
|
|
|
|
|
local hookVar="${pkgHookVarVars[$(( depHostOffset + 1 ))]}"
|
|
|
|
|
local pkgsVar="${pkgAccumVarVars[$(( depHostOffset + 1 ))]}"
|
|
|
|
|
local hookVar="${pkgHookVarVars[$depHostOffset + 1]}"
|
|
|
|
|
local pkgsVar="${pkgAccumVarVars[$depHostOffset + 1]}"
|
|
|
|
|
for depTargetOffset in "${allPlatOffsets[@]}"; do
|
|
|
|
|
(( "$depHostOffset" <= "$depTargetOffset" )) || continue
|
|
|
|
|
local hookRef="${hookVar}[$(( depTargetOffset - depHostOffset ))]"
|
|
|
|
|
local hookRef="${hookVar}[$depTargetOffset - $depHostOffset]"
|
|
|
|
|
if [[ -z "${strictDeps-}" ]]; then
|
|
|
|
|
|
|
|
|
|
# Keep track of which packages we have visited before.
|
|
|
|
@ -565,12 +555,12 @@ _addToEnv() {
|
|
|
|
|
#
|
|
|
|
|
# TODO(@Ericson2314): Don't special-case native compilation
|
|
|
|
|
for pkg in \
|
|
|
|
|
"${pkgsBuildBuild[@]}" \
|
|
|
|
|
"${pkgsBuildHost[@]}" \
|
|
|
|
|
"${pkgsBuildTarget[@]}" \
|
|
|
|
|
"${pkgsHostHost[@]}" \
|
|
|
|
|
"${pkgsHostTarget[@]}" \
|
|
|
|
|
"${pkgsTargetTarget[@]}"
|
|
|
|
|
${pkgsBuildBuild+"${pkgsBuildBuild[@]}"} \
|
|
|
|
|
${pkgsBuildHost+"${pkgsBuildHost[@]}"} \
|
|
|
|
|
${pkgsBuildTarget+"${pkgsBuildTarget[@]}"} \
|
|
|
|
|
${pkgsHostHost+"${pkgsHostHost[@]}"} \
|
|
|
|
|
${pkgsHostTarget+"${pkgsHostTarget[@]}"} \
|
|
|
|
|
${pkgsTargetTarget+"${pkgsTargetTarget[@]}"}
|
|
|
|
|
do
|
|
|
|
|
if [[ "$visitedPkgs" = *"$pkg"* ]]; then
|
|
|
|
|
continue
|
|
|
|
@ -579,7 +569,7 @@ _addToEnv() {
|
|
|
|
|
visitedPkgs+=" $pkg"
|
|
|
|
|
done
|
|
|
|
|
else
|
|
|
|
|
local pkgsRef="${pkgsVar}[$(( depTargetOffset - depHostOffset ))]"
|
|
|
|
|
local pkgsRef="${pkgsVar}[$depTargetOffset - $depHostOffset]"
|
|
|
|
|
local pkgsSlice="${!pkgsRef}[@]"
|
|
|
|
|
for pkg in ${!pkgsSlice+"${!pkgsSlice}"}; do
|
|
|
|
|
runHook "${!hookRef}" "$pkg"
|
|
|
|
@ -645,7 +635,7 @@ export NIX_INDENT_MAKE=1
|
|
|
|
|
|
|
|
|
|
if [ -z "${NIX_BUILD_CORES:-}" ]; then
|
|
|
|
|
NIX_BUILD_CORES="1"
|
|
|
|
|
elif (( "$NIX_BUILD_CORES" <= 0 )); then
|
|
|
|
|
elif [ "$NIX_BUILD_CORES" -le 0 ]; then
|
|
|
|
|
NIX_BUILD_CORES=$(nproc 2>/dev/null || true)
|
|
|
|
|
if expr >/dev/null 2>&1 "$NIX_BUILD_CORES" : "^[0-9][0-9]*$"; then
|
|
|
|
|
:
|
|
|
|
@ -658,11 +648,11 @@ export NIX_BUILD_CORES
|
|
|
|
|
|
|
|
|
|
# Prevent SSL libraries from using certificates in /etc/ssl, unless set explicitly.
|
|
|
|
|
# Leave it in impure shells for convenience.
|
|
|
|
|
if [[ -z "${NIX_SSL_CERT_FILE:-}" && "${IN_NIX_SHELL:-}" != "impure" ]]; then
|
|
|
|
|
if [ -z "${NIX_SSL_CERT_FILE:-}" ] && [ "${IN_NIX_SHELL:-}" != "impure" ]; then
|
|
|
|
|
export NIX_SSL_CERT_FILE=/no-cert-file.crt
|
|
|
|
|
fi
|
|
|
|
|
# Another variant left for compatibility.
|
|
|
|
|
if [[ -z "${SSL_CERT_FILE:-}" && "${IN_NIX_SHELL:-}" != "impure" ]]; then
|
|
|
|
|
if [ -z "${SSL_CERT_FILE:-}" ] && [ "${IN_NIX_SHELL:-}" != "impure" ]; then
|
|
|
|
|
export SSL_CERT_FILE=/no-cert-file.crt
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
@ -728,7 +718,6 @@ substituteStream() {
|
|
|
|
|
|
|
|
|
|
consumeEntire() {
|
|
|
|
|
# read returns non-0 on EOF, so we want read to fail
|
|
|
|
|
# shellcheck disable=SC2086
|
|
|
|
|
if IFS='' read -r -N 0 $1; then
|
|
|
|
|
echo "consumeEntire(): ERROR: Input null bytes, won't process" >&2
|
|
|
|
|
return 1
|
|
|
|
@ -900,7 +889,7 @@ unpackPhase() {
|
|
|
|
|
# Find the source directory.
|
|
|
|
|
|
|
|
|
|
# set to empty if unset
|
|
|
|
|
: "${sourceRoot=}"
|
|
|
|
|
: ${sourceRoot=}
|
|
|
|
|
|
|
|
|
|
if [ -n "${setSourceRoot:-}" ]; then
|
|
|
|
|
runOneHook setSourceRoot
|
|
|
|
@ -978,8 +967,8 @@ configurePhase() {
|
|
|
|
|
runHook preConfigure
|
|
|
|
|
|
|
|
|
|
# set to empty if unset
|
|
|
|
|
: "${configureScript=}"
|
|
|
|
|
: "${configureFlags=}"
|
|
|
|
|
: ${configureScript=}
|
|
|
|
|
: ${configureFlags=}
|
|
|
|
|
|
|
|
|
|
if [[ -z "$configureScript" && -x ./configure ]]; then
|
|
|
|
|
configureScript=./configure
|
|
|
|
@ -997,27 +986,25 @@ configurePhase() {
|
|
|
|
|
configureFlags="${prefixKey:---prefix=}$prefix $configureFlags"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ -f "$configureScript" ]; then
|
|
|
|
|
# Add --disable-dependency-tracking to speed up some builds.
|
|
|
|
|
if [[ -z ${dontAddDisableDepTrack:-} ]]; then
|
|
|
|
|
if grep -q dependency-tracking "$configureScript"; then
|
|
|
|
|
if [ -z "${dontAddDisableDepTrack:-}" ]; then
|
|
|
|
|
if [ -f "$configureScript" ] && grep -q dependency-tracking "$configureScript"; then
|
|
|
|
|
configureFlags="--disable-dependency-tracking $configureFlags"
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# By default, disable static builds.
|
|
|
|
|
if [[ -z ${dontDisableStatic:-} ]]; then
|
|
|
|
|
if grep -q enable-static "$configureScript"; then
|
|
|
|
|
if [ -z "${dontDisableStatic:-}" ]; then
|
|
|
|
|
if [ -f "$configureScript" ] && grep -q enable-static "$configureScript"; then
|
|
|
|
|
configureFlags="--disable-static $configureFlags"
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ -n "$configureScript" ]; then
|
|
|
|
|
IFS=" " read -r -a configureFlagsTemp <<< "$configureFlags"
|
|
|
|
|
local -a flagsArray=(
|
|
|
|
|
"${configureFlagsTemp[@]}"
|
|
|
|
|
"${configureFlagsArray[@]}"
|
|
|
|
|
# Old bash empty array hack
|
|
|
|
|
# shellcheck disable=SC2086
|
|
|
|
|
local flagsArray=(
|
|
|
|
|
$configureFlags ${configureFlagsArray+"${configureFlagsArray[@]}"}
|
|
|
|
|
)
|
|
|
|
|
echoCmd 'configure flags' "${flagsArray[@]}"
|
|
|
|
|
# shellcheck disable=SC2086
|
|
|
|
@ -1035,22 +1022,20 @@ buildPhase() {
|
|
|
|
|
runHook preBuild
|
|
|
|
|
|
|
|
|
|
# set to empty if unset
|
|
|
|
|
: "${makeFlags=}"
|
|
|
|
|
: ${makeFlags=}
|
|
|
|
|
|
|
|
|
|
if [[ -z "$makeFlags" && -z "${makefile:-}" && ! ( -e Makefile || -e makefile || -e GNUmakefile ) ]]; then
|
|
|
|
|
echo "no Makefile, doing nothing"
|
|
|
|
|
else
|
|
|
|
|
foundMakefile=1
|
|
|
|
|
IFS=" " read -r -a makeFlagsTemp <<< "$makeFlags"
|
|
|
|
|
# shellcheck disable=SC2154
|
|
|
|
|
IFS=" " read -r -a buildFlagsTemp <<< "$buildFlags"
|
|
|
|
|
local -a flagsArray=(
|
|
|
|
|
|
|
|
|
|
# Old bash empty array hack
|
|
|
|
|
# shellcheck disable=SC2086
|
|
|
|
|
local flagsArray=(
|
|
|
|
|
${enableParallelBuilding:+-j${NIX_BUILD_CORES} -l${NIX_BUILD_CORES}}
|
|
|
|
|
SHELL="$SHELL"
|
|
|
|
|
"${makeFlagsTemp[@]}"
|
|
|
|
|
"${makeFlagsArray[@]}"
|
|
|
|
|
"${buildFlagsTemp[@]}"
|
|
|
|
|
"${buildFlagsArray[@]}"
|
|
|
|
|
SHELL=$SHELL
|
|
|
|
|
$makeFlags ${makeFlagsArray+"${makeFlagsArray[@]}"}
|
|
|
|
|
$buildFlags ${buildFlagsArray+"${buildFlagsArray[@]}"}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
echoCmd 'build flags' "${flagsArray[@]}"
|
|
|
|
@ -1074,26 +1059,23 @@ checkPhase() {
|
|
|
|
|
if [[ -z "${checkTarget:-}" ]]; then
|
|
|
|
|
#TODO(@oxij): should flagsArray influence make -n?
|
|
|
|
|
if make -n ${makefile:+-f $makefile} check >/dev/null 2>&1; then
|
|
|
|
|
checkTarget="check"
|
|
|
|
|
checkTarget=check
|
|
|
|
|
elif make -n ${makefile:+-f $makefile} test >/dev/null 2>&1; then
|
|
|
|
|
checkTarget="test"
|
|
|
|
|
checkTarget=test
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [[ -z "${checkTarget:-}" ]]; then
|
|
|
|
|
echo "no check/test target in ${makefile:-Makefile}, doing nothing"
|
|
|
|
|
else
|
|
|
|
|
IFS=" " read -r -a makeFlagsTemp <<< "$makeFlags"
|
|
|
|
|
IFS=" " read -r -a checkFlagsTemp <<< "${checkFlags:-VERBOSE=y}"
|
|
|
|
|
IFS=" " read -r -a checkTargetTemp <<< "${checkTarget}"
|
|
|
|
|
local -a flagsArray=(
|
|
|
|
|
# Old bash empty array hack
|
|
|
|
|
# shellcheck disable=SC2086
|
|
|
|
|
local flagsArray=(
|
|
|
|
|
${enableParallelChecking:+-j${NIX_BUILD_CORES} -l${NIX_BUILD_CORES}}
|
|
|
|
|
SHELL="$SHELL"
|
|
|
|
|
"${makeFlagsTemp[@]}"
|
|
|
|
|
"${makeFlagsArray[@]}"
|
|
|
|
|
"${checkFlagsTemp[@]}"
|
|
|
|
|
"${checkFlagsArray[@]}"
|
|
|
|
|
"${checkTargetTemp[@]}"
|
|
|
|
|
SHELL=$SHELL
|
|
|
|
|
$makeFlags ${makeFlagsArray+"${makeFlagsArray[@]}"}
|
|
|
|
|
${checkFlags:-VERBOSE=y} ${checkFlagsArray+"${checkFlagsArray[@]}"}
|
|
|
|
|
${checkTarget}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
echoCmd 'check flags' "${flagsArray[@]}"
|
|
|
|
@ -1112,18 +1094,14 @@ installPhase() {
|
|
|
|
|
if [ -n "$prefix" ]; then
|
|
|
|
|
mkdir -p "$prefix"
|
|
|
|
|
fi
|
|
|
|
|
IFS=" " read -r -a makeFlagsTemp <<< "$makeFlags"
|
|
|
|
|
# shellcheck disable=SC2154
|
|
|
|
|
IFS=" " read -r -a installFlagsTemp <<< "$installFlags"
|
|
|
|
|
# shellcheck disable=SC2154
|
|
|
|
|
IFS=" " read -r -a installTargetsTemp <<< "${installTargets:-install}"
|
|
|
|
|
local -a flagsArray=(
|
|
|
|
|
SHELL="$SHELL"
|
|
|
|
|
"${makeFlagsTemp[@]}"
|
|
|
|
|
"${makeFlagsArray[@]}"
|
|
|
|
|
"${installFlagsTemp[@]}"
|
|
|
|
|
"${installFlagsArray[@]}"
|
|
|
|
|
"${installTargetsTemp[@]}"
|
|
|
|
|
|
|
|
|
|
# Old bash empty array hack
|
|
|
|
|
# shellcheck disable=SC2086
|
|
|
|
|
local flagsArray=(
|
|
|
|
|
SHELL=$SHELL
|
|
|
|
|
$makeFlags ${makeFlagsArray+"${makeFlagsArray[@]}"}
|
|
|
|
|
$installFlags ${installFlagsArray+"${installFlagsArray[@]}"}
|
|
|
|
|
${installTargets:-install}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
echoCmd 'install flags' "${flagsArray[@]}"
|
|
|
|
@ -1178,7 +1156,6 @@ fixupPhase() {
|
|
|
|
|
|
|
|
|
|
[[ "${!propagatedInputsSlice}" ]] || continue
|
|
|
|
|
|
|
|
|
|
# shellcheck disable=SC2154
|
|
|
|
|
mkdir -p "${!outputDev}/nix-support"
|
|
|
|
|
# shellcheck disable=SC2086
|
|
|
|
|
printWords ${!propagatedInputsSlice} > "${!outputDev}/nix-support/$propagatedInputsFile"
|
|
|
|
@ -1195,8 +1172,6 @@ fixupPhase() {
|
|
|
|
|
mkdir -p "${!outputDev}/nix-support"
|
|
|
|
|
local hook
|
|
|
|
|
for hook in $setupHooks; do
|
|
|
|
|
# content is being assigned to in the following lines
|
|
|
|
|
# shellcheck disable=SC2034
|
|
|
|
|
local content
|
|
|
|
|
consumeEntire content < "$hook"
|
|
|
|
|
substituteAllStream content "file '$hook'" >> "${!outputDev}/nix-support/setup-hook"
|
|
|
|
@ -1208,7 +1183,6 @@ fixupPhase() {
|
|
|
|
|
# Propagate user-env packages into the output with binaries, TODO?
|
|
|
|
|
|
|
|
|
|
if [ -n "${propagatedUserEnvPkgs:-}" ]; then
|
|
|
|
|
# shellcheck disable=SC2154
|
|
|
|
|
mkdir -p "${!outputBin}/nix-support"
|
|
|
|
|
# shellcheck disable=SC2086
|
|
|
|
|
printWords $propagatedUserEnvPkgs > "${!outputBin}/nix-support/propagated-user-env-packages"
|
|
|
|
@ -1225,21 +1199,17 @@ installCheckPhase() {
|
|
|
|
|
echo "no Makefile or custom installCheckPhase, doing nothing"
|
|
|
|
|
#TODO(@oxij): should flagsArray influence make -n?
|
|
|
|
|
elif [[ -z "${installCheckTarget:-}" ]] \
|
|
|
|
|
&& ! make -n ${makefile:+-f $makefile} "${installCheckTarget:-installcheck}" >/dev/null 2>&1; then
|
|
|
|
|
&& ! make -n ${makefile:+-f $makefile} ${installCheckTarget:-installcheck} >/dev/null 2>&1; then
|
|
|
|
|
echo "no installcheck target in ${makefile:-Makefile}, doing nothing"
|
|
|
|
|
else
|
|
|
|
|
IFS=" " read -r -a makeFlagsTemp <<< "$makeFlags"
|
|
|
|
|
# shellcheck disable=SC2154
|
|
|
|
|
IFS=" " read -r -a installCheckFlagsTemp <<< "$installCheckFlags"
|
|
|
|
|
IFS=" " read -r -a installCheckTargetTemp <<< "${installCheckTarget:-installcheck}"
|
|
|
|
|
local -a flagsArray=(
|
|
|
|
|
# Old bash empty array hack
|
|
|
|
|
# shellcheck disable=SC2086
|
|
|
|
|
local flagsArray=(
|
|
|
|
|
${enableParallelChecking:+-j${NIX_BUILD_CORES} -l${NIX_BUILD_CORES}}
|
|
|
|
|
SHELL="$SHELL"
|
|
|
|
|
"${makeFlagsTemp[@]}"
|
|
|
|
|
"${makeFlagsArray[@]}"
|
|
|
|
|
"${installCheckFlagsTemp[@]}"
|
|
|
|
|
"${installCheckFlagsArray[@]}"
|
|
|
|
|
"${installCheckTargetTemp[@]}"
|
|
|
|
|
SHELL=$SHELL
|
|
|
|
|
$makeFlags ${makeFlagsArray+"${makeFlagsArray[@]}"}
|
|
|
|
|
$installCheckFlags ${installCheckFlagsArray+"${installCheckFlagsArray[@]}"}
|
|
|
|
|
${installCheckTarget:-installcheck}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
echoCmd 'installcheck flags' "${flagsArray[@]}"
|
|
|
|
@ -1254,13 +1224,10 @@ installCheckPhase() {
|
|
|
|
|
distPhase() {
|
|
|
|
|
runHook preDist
|
|
|
|
|
|
|
|
|
|
# shellcheck disable=SC2154
|
|
|
|
|
IFS=" " read -r -a distFlagsTemp <<< "$distFlags"
|
|
|
|
|
|
|
|
|
|
# Old bash empty array hack
|
|
|
|
|
# shellcheck disable=SC2086
|
|
|
|
|
local flagsArray=(
|
|
|
|
|
"${distFlagsTemp[@]}"
|
|
|
|
|
${distFlagsArray+"${distFlagsArray[@]}"}
|
|
|
|
|
"${distTarget:-dist}"
|
|
|
|
|
$distFlags ${distFlagsArray+"${distFlagsArray[@]}"} ${distTarget:-dist}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
echo 'dist flags: %q' "${flagsArray[@]}"
|
|
|
|
@ -1297,7 +1264,6 @@ showPhaseHeader() {
|
|
|
|
|
|
|
|
|
|
genericBuild() {
|
|
|
|
|
if [ -f "${buildCommandPath:-}" ]; then
|
|
|
|
|
# shellcheck disable=SC1090
|
|
|
|
|
source "$buildCommandPath"
|
|
|
|
|
return
|
|
|
|
|
fi
|
|
|
|
@ -1325,7 +1291,7 @@ genericBuild() {
|
|
|
|
|
if [[ "$curPhase" = distPhase && -z "${doDist:-}" ]]; then continue; fi
|
|
|
|
|
|
|
|
|
|
if [[ -n $NIX_LOG_FD ]]; then
|
|
|
|
|
echo "@nix { \"action\": \"setPhase\", \"phase\": \"$curPhase\" }" >&"$NIX_LOG_FD"
|
|
|
|
|
echo "@nix { \"action\": \"setPhase\", \"phase\": \"$curPhase\" }" >&$NIX_LOG_FD
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
showPhaseHeader "$curPhase"
|
|
|
|
|