nixpkgs-suyu/pkgs/build-support/cc-wrapper/gnatlink-wrapper.sh
John Ericson 9f1e009975 cc-wrapper: Unconditionally use @infixSalt@ accross the board
This is basically a sed job, in preparation of the next commit. The
rules are more or less:

  - s"NIX_(.._WRAPPER_)?([a-zA-Z0-9@]*)"NIX_\1@infixSalt@_\2"g

  - except for non-cc-wrapper-specific vars like `NIX_DEBUG`
2017-08-07 03:05:50 -04:00

37 lines
1 KiB
Bash

#! @shell@
set -e -o pipefail
shopt -s nullglob
# Add the flags for the GNAT compiler proper.
extraAfter=("--GCC=@out@/bin/gcc")
extraBefore=()
## Add the flags that should be passed to the linker (and prevent
## `ld-wrapper' from adding NIX_@infixSalt@_LDFLAGS again).
#for i in $NIX_@infixSalt@_LDFLAGS_BEFORE; do
# extraBefore+=("-largs" "$i")
#done
#for i in $NIX_@infixSalt@_LDFLAGS; do
# if [ "${i:0:3}" = -L/ ]; then
# extraAfter+=("$i")
# else
# extraAfter+=("-largs" "$i")
# fi
#done
#export NIX_@infixSalt@_LDFLAGS_SET=1
# Optionally print debug info.
if [ -n "$NIX_DEBUG" ]; then
echo "extra flags before to @prog@:" >&2
printf " %q\n" "${extraBefore[@]}" >&2
echo "original flags to @prog@:" >&2
printf " %q\n" "$@" >&2
echo "extra flags after to @prog@:" >&2
printf " %q\n" "${extraAfter[@]}" >&2
fi
if [ -n "$NIX_@infixSalt@_GNAT_WRAPPER_EXEC_HOOK" ]; then
source "$NIX_@infixSalt@_GNAT_WRAPPER_EXEC_HOOK"
fi
exec @prog@ "${extraBefore[@]}" "$@" "${extraAfter[@]}"