Revert "stdenv: log build hooks as they run"

This commit is contained in:
a-n-n-a-l-e-e
2024-03-09 17:32:20 -08:00
committed by GitHub
parent 3ce29d4386
commit cf1a332500
2 changed files with 1 additions and 44 deletions
+1 -1
View File
@@ -432,7 +432,7 @@ The propagated equivalent of `depsTargetTarget`. This is prefixed for the same r
#### `NIX_DEBUG` {#var-stdenv-NIX_DEBUG}
A number between 0 and 7 indicating how much information to log. If set to 1 or higher, `stdenv` will print moderate debugging information during the build. In particular, the `gcc` and `ld` wrapper scripts will print out the complete command line passed to the wrapped tools. If set to 2 or higher, multiline build hooks will be printed literally. If set to 6 or higher, the `stdenv` setup script will be run with `set -x` tracing. If set to 7 or higher, the `gcc` and `ld` wrapper scripts will also be run with `set -x` tracing.
A number between 0 and 7 indicating how much information to log. If set to 1 or higher, `stdenv` will print moderate debugging information during the build. In particular, the `gcc` and `ld` wrapper scripts will print out the complete command line passed to the wrapped tools. If set to 6 or higher, the `stdenv` setup script will be run with `set -x` tracing. If set to 7 or higher, the `gcc` and `ld` wrapper scripts will also be run with `set -x` tracing.
### Attributes affecting build properties {#attributes-affecting-build-properties}
-43
View File
@@ -50,42 +50,6 @@ getAllOutputNames() {
######################################################################
# Hook handling.
# Log a hook, to be run before the hook is actually called.
# This only logs explicit hooks; "implicit" hooks, those specified directly
# in a derivation's arguments, are logged in `_callImplicitHook` instead.
_logHook() {
local hookKind="$1"
local hookExpr="$2"
shift 2
if declare -F "$hookExpr" > /dev/null 2>&1; then
echo "calling '$hookKind' function hook '$hookExpr'" "$@"
elif type -p "$hookExpr" > /dev/null; then
echo "sourcing '$hookKind' script hook '$hookExpr'"
elif [[ "$hookExpr" != "_callImplicitHook"* ]]; then
# Here we have a string hook to eval.
# Join lines onto one with literal \n characters unless NIX_DEBUG >= 2.
local exprToOutput
if (( "${NIX_DEBUG:-0}" >= 2 )); then
exprToOutput="$hookExpr"
else
while IFS= read -r hookExprLine; do
# These lines often have indentation,
# so let's remove leading whitespace.
hookExprLine="${hookExprLine#"${hookExprLine%%[![:space:]]*}"}"
# If this line wasn't entirely whitespace,
# then add it to our output.
if [[ -n "$hookExprLine" ]]; then
exprToOutput+="$hookExprLine\\n "
fi
done <<< "$hookExpr"
# And then remove the final, unnecessary, \n
exprToOutput="${exprToOutput%%\\n }"
fi
echo "evaling '$hookKind' string hook '$exprToOutput'"
fi
}
# Run all hooks with the specified name in the order in which they
# were added, stopping if any fails (returns a non-zero exit
@@ -100,7 +64,6 @@ runHook() {
# Hack around old bash being bad and thinking empty arrays are
# undefined.
for hook in "_callImplicitHook 0 $hookName" ${!hooksSlice+"${!hooksSlice}"}; do
_logHook "$hookName" "$hook" "$@"
_eval "$hook" "$@"
done
@@ -118,7 +81,6 @@ runOneHook() {
local hook ret=1
# Hack around old bash like above
for hook in "_callImplicitHook 1 $hookName" ${!hooksSlice+"${!hooksSlice}"}; do
_logHook "$hookName" "$hook" "$@"
if _eval "$hook" "$@"; then
ret=0
break
@@ -138,13 +100,10 @@ _callImplicitHook() {
local def="$1"
local hookName="$2"
if declare -F "$hookName" > /dev/null; then
echo "calling implicit '$hookName' function hook"
"$hookName"
elif type -p "$hookName" > /dev/null; then
echo "sourcing implicit '$hookName' script hook"
source "$hookName"
elif [ -n "${!hookName:-}" ]; then
echo "evaling implicit '$hookName' string hook"
eval "${!hookName}"
else
return "$def"
@@ -685,7 +644,6 @@ activatePackage() {
(( hostOffset <= targetOffset )) || exit 1
if [ -f "$pkg" ]; then
echo "sourcing setup hook '$pkg'"
source "$pkg"
fi
@@ -709,7 +667,6 @@ activatePackage() {
fi
if [[ -f "$pkg/nix-support/setup-hook" ]]; then
echo "sourcing setup hook '$pkg/nix-support/setuphook'"
source "$pkg/nix-support/setup-hook"
fi
}