···6666# over no state, and there's no @-substitutions within, so any redefined
6767# function is guaranteed to be exactly the same.
6868ccWrapper_addCVars () {
6969- # The `depHostOffset` describes how the host platform of the dependencies
7070- # are slid relative to the depending package. It is brought into scope of
7171- # the environment hook defined as the role of the dependency being applied.
7272- case $depHostOffset in
7373- -1) local role='BUILD_' ;;
7474- 0) local role='' ;;
7575- 1) local role='TARGET_' ;;
7676- *) echo "cc-wrapper: Error: Cannot be used with $depHostOffset-offset deps" >2;
7777- return 1 ;;
7878- esac
6969+ # See ../setup-hooks/role.bash
7070+ local role_post role_pre
7171+ getTargetRoleEnvHook
79728073 if [[ -d "$1/include" ]]; then
8181- export NIX_${role}CFLAGS_COMPILE+=" ${ccIncludeFlag:--isystem} $1/include"
7474+ export NIX_${role_pre}CFLAGS_COMPILE+=" ${ccIncludeFlag:--isystem} $1/include"
8275 fi
83768477 if [[ -d "$1/Library/Frameworks" ]]; then
8585- export NIX_${role}CFLAGS_COMPILE+=" -F$1/Library/Frameworks"
7878+ export NIX_${role_pre}CFLAGS_COMPILE+=" -F$1/Library/Frameworks"
8679 fi
8780}
88818989-# Since the same cc-wrapper derivation can be depend on in multiple ways, we
9090-# need to accumulate *each* role (i.e. target platform relative the depending
9191-# derivation) in which the cc-wrapper derivation is used.
9292-# `NIX_CC_WRAPPER_@infixSalt@_TARGET_*` tracks this (needs to be an exported env
9393-# var so can't use fancier data structures).
9494-#
9595-# We also need to worry about what role is being added on *this* invocation of
9696-# setup-hook, which `role` tracks.
9797-case $targetOffset in
9898- -1)
9999- export NIX_CC_WRAPPER_@infixSalt@_TARGET_BUILD=1
100100- role_pre='BUILD_'
101101- role_post='_FOR_BUILD'
102102- ;;
103103- 0)
104104- export NIX_CC_WRAPPER_@infixSalt@_TARGET_HOST=1
105105- role_pre=''
106106- role_post=''
107107- ;;
108108- 1)
109109- export NIX_CC_WRAPPER_@infixSalt@_TARGET_TARGET=1
110110- role_pre='TARGET_'
111111- role_post='_FOR_TARGET'
112112- ;;
113113- *)
114114- echo "cc-wrapper: used as improper sort of dependency" >2;
115115- return 1
116116- ;;
117117-esac
8282+# See ../setup-hooks/role.bash
8383+getTargetRole
8484+getTargetRoleWrapper
1188511986# We use the `targetOffset` to choose the right env hook to accumulate the right
12087# sort of deps (those with that offset).
+75
pkgs/build-support/setup-hooks/role.bash
···11+# Since the same derivation can be depend on in multiple ways, we need to
22+# accumulate *each* role (i.e. host and target platforms relative the depending
33+# derivation) in which the derivation is used.
44+#
55+# The role is intened to be use as part of other variables names like
66+# - $NIX_${role_pre}_SOMETHING
77+# - $NIX_SOMETHING_${role_post}
88+99+function getRole() {
1010+ case $1 in
1111+ -1)
1212+ role_pre='BUILD_'
1313+ role_post='_FOR_BUILD'
1414+ ;;
1515+ 0)
1616+ role_pre=''
1717+ role_post=''
1818+ ;;
1919+ 1)
2020+ role_pre='TARGET_'
2121+ role_post='_FOR_TARGET'
2222+ ;;
2323+ *)
2424+ echo "@name@: used as improper sort of dependency" >2
2525+ return 1
2626+ ;;
2727+ esac
2828+}
2929+3030+# `hostOffset` describes how the host platform of the package is slid relative
3131+# to the depending package. `targetOffset` likewise describes the target
3232+# platform of the package. Both are brought into scope of the setup hook defined
3333+# for dependency whose setup hook is being processed relative to the package
3434+# being built.
3535+3636+function getHostRole() {
3737+ getRole "$hostOffset"
3838+}
3939+function getTargetRole() {
4040+ getRole "$targetOffset"
4141+}
4242+4343+# `depHostOffset` describes how the host platform of the dependencies are slid
4444+# relative to the depending package. `depTargetOffset` likewise describes the
4545+# target platform of dependenices. Both are brought into scope of the
4646+# environment hook defined for the dependency being applied relative to the
4747+# package being built.
4848+4949+function getHostRoleEnvHook() {
5050+ getRole "$depHostOffset"
5151+}
5252+function getTargetRoleEnvHook() {
5353+ getRole "$depTargetOffset"
5454+}
5555+5656+# This variant is inteneded specifically for code-prodocing tool wrapper scripts
5757+# `NIX_@wrapperName@_@infixSalt@_TARGET_*` tracks this (needs to be an exported
5858+# env var so can't use fancier data structures).
5959+function getTargetRoleWrapper() {
6060+ case $targetOffset in
6161+ -1)
6262+ export NIX_@wrapperName@_@infixSalt@_TARGET_BUILD=1
6363+ ;;
6464+ 0)
6565+ export NIX_@wrapperName@_@infixSalt@_TARGET_HOST=1
6666+ ;;
6767+ 1)
6868+ export NIX_@wrapperName@_@infixSalt@_TARGET_TARGET=1
6969+ ;;
7070+ *)
7171+ echo "@name@: used as improper sort of dependency" >2
7272+ return 1
7373+ ;;
7474+ esac
7575+}
+4-12
pkgs/development/compilers/gcc/libstdc++-hook.sh
···11-# The `hostOffset` describes how the host platform of the dependencies are slid
22-# relative to the depending package. It is brought into scope of the setup hook
33-# defined as the role of the dependency whose hooks is being run.
44-case $hostOffset in
55- -1) local role='BUILD_' ;;
66- 0) local role='' ;;
77- 1) local role='TARGET_' ;;
88- *) echo "cc-wrapper: Error: Cannot be used with $hostOffset-offset deps" >2;
99- return 1 ;;
1010-esac
11+# See pkgs/build-support/setup-hooks/role.bash
22+getHostRole
1131212-export NIX_${role}CXXSTDLIB_COMPILE+=" -isystem $(echo -n @gcc@/include/c++/*) -isystem $(echo -n @gcc@/include/c++/*)/$(@gcc@/bin/gcc -dumpmachine)"
1313-export NIX_${role}CXXSTDLIB_LINK=" -stdlib=libstdc++"
44+export NIX_${role_pre}CXXSTDLIB_COMPILE+=" -isystem $(echo -n @gcc@/include/c++/*) -isystem $(echo -n @gcc@/include/c++/*)/$(@gcc@/bin/gcc -dumpmachine)"
55+export NIX_${role_pre}CXXSTDLIB_LINK=" -stdlib=libstdc++"
···11-# The `hostOffset` describes how the host platform of the dependencies are slid
22-# relative to the depending package. It is brought into scope of the setup hook
33-# defined as the role of the dependency whose hooks is being run.
44-case $hostOffset in
55- -1) local role='BUILD_' ;;
66- 0) local role='' ;;
77- 1) local role='TARGET_' ;;
88- *) echo "cc-wrapper: Error: Cannot be used with $hostOffset-offset deps" >2;
99- return 1 ;;
1010-esac
11+# See pkgs/build-support/setup-hooks/role.bash
22+getHostRole
113124linkCxxAbi="@linkCxxAbi@"
1313-export NIX_${role}CXXSTDLIB_COMPILE+=" -isystem @out@/include/c++/v1"
1414-export NIX_${role}CXXSTDLIB_LINK=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}"
55+export NIX_${role_pre}CXXSTDLIB_COMPILE+=" -isystem @out@/include/c++/v1"
66+export NIX_${role_pre}CXXSTDLIB_LINK=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}"
···11-# The `hostOffset` describes how the host platform of the dependencies are slid
22-# relative to the depending package. It is brought into scope of the setup hook
33-# defined as the role of the dependency whose hooks is being run.
44-case $hostOffset in
55- -1) local role='BUILD_' ;;
66- 0) local role='' ;;
77- 1) local role='TARGET_' ;;
88- *) echo "cc-wrapper: Error: Cannot be used with $hostOffset-offset deps" >2;
99- return 1 ;;
1010-esac
11+# See pkgs/build-support/setup-hooks/role.bash
22+getHostRole
113124linkCxxAbi="@linkCxxAbi@"
1313-export NIX_${role}CXXSTDLIB_COMPILE+=" -isystem @out@/include/c++/v1"
1414-export NIX_${role}CXXSTDLIB_LINK=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}"
55+export NIX_${role_pre}CXXSTDLIB_COMPILE+=" -isystem @out@/include/c++/v1"
66+export NIX_${role_pre}CXXSTDLIB_LINK=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}"
···11-# The `hostOffset` describes how the host platform of the dependencies
22-# relative to the depending package. It is brought into scope of the setup hook
33-# defined as the role of the dependency whose hooks is being run.
44-case $hostOffset in
55- -1) local role='BUILD_' ;;
66- 0) local role='' ;;
77- 1) local role='TARGET_' ;;
88- *) echo "cc-wrapper: Error: Cannot be used with $hostOffset-offset deps" >2;
99- return 1 ;;
1010-esac
11+# See pkgs/build-support/setup-hooks/role.bash
22+getHostRole
113124linkCxxAbi="@linkCxxAbi@"
1313-export NIX_${role}CXXSTDLIB_COMPILE+=" -isystem @out@/include/c++/v1"
1414-export NIX_${role}CXXSTDLIB_LINK=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}"
55+export NIX_${role_pre}CXXSTDLIB_COMPILE+=" -isystem @out@/include/c++/v1"
66+export NIX_${role_pre}CXXSTDLIB_LINK=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}"
···11-# The `hostOffset` describes how the host platform of the dependencies
22-# relative to the depending package. It is brought into scope of the setup hook
33-# defined as the role of the dependency whose hooks is being run.
44-case $hostOffset in
55- -1) local role='BUILD_' ;;
66- 0) local role='' ;;
77- 1) local role='TARGET_' ;;
88- *) echo "cc-wrapper: Error: Cannot be used with $hostOffset-offset deps" >2;
99- return 1 ;;
1010-esac
11+# See pkgs/build-support/setup-hooks/role.bash
22+getHostRole
113124linkCxxAbi="@linkCxxAbi@"
1313-export NIX_${role}CXXSTDLIB_COMPILE+=" -isystem @out@/include/c++/v1"
1414-export NIX_${role}CXXSTDLIB_LINK=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}"
55+export NIX_${role_pre}CXXSTDLIB_COMPILE+=" -isystem @out@/include/c++/v1"
66+export NIX_${role_pre}CXXSTDLIB_LINK=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}"
···11-# The `hostOffset` describes how the host platform of the dependencies
22-# relative to the depending package. It is brought into scope of the setup hook
33-# defined as the role of the dependency whose hooks is being run.
44-case $hostOffset in
55- -1) local role='BUILD_' ;;
66- 0) local role='' ;;
77- 1) local role='TARGET_' ;;
88- *) echo "cc-wrapper: Error: Cannot be used with $hostOffset-offset deps" >2;
99- return 1 ;;
1010-esac
11+# See pkgs/build-support/setup-hooks/role.bash
22+getHostRole
113124linkCxxAbi="@linkCxxAbi@"
1313-export NIX_${role}CXXSTDLIB_COMPILE+=" -isystem @out@/include/c++/v1"
1414-export NIX_${role}CXXSTDLIB_LINK=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}"
55+export NIX_${role_pre}CXXSTDLIB_COMPILE+=" -isystem @out@/include/c++/v1"
66+export NIX_${role_pre}CXXSTDLIB_LINK=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}"
···11-# The `hostOffset` describes how the host platform of the dependencies
22-# relative to the depending package. It is brought into scope of the setup hook
33-# defined as the role of the dependency whose hooks is being run.
44-case $hostOffset in
55- -1) local role='BUILD_' ;;
66- 0) local role='' ;;
77- 1) local role='TARGET_' ;;
88- *) echo "cc-wrapper: Error: Cannot be used with $hostOffset-offset deps" >2;
99- return 1 ;;
1010-esac
11+# See pkgs/build-support/setup-hooks/role.bash
22+getHostRole
113124linkCxxAbi="@linkCxxAbi@"
1313-export NIX_${role}CXXSTDLIB_COMPILE+=" -isystem @out@/include/c++/v1"
1414-export NIX_${role}CXXSTDLIB_LINK=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}"
55+export NIX_${role_pre}CXXSTDLIB_COMPILE+=" -isystem @out@/include/c++/v1"
66+export NIX_${role_pre}CXXSTDLIB_LINK=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}"
···11-# The `hostOffset` describes how the host platform of the dependencies
22-# relative to the depending package. It is brought into scope of the setup hook
33-# defined as the role of the dependency whose hooks is being run.
44-case $hostOffset in
55- -1) local role='BUILD_' ;;
66- 0) local role='' ;;
77- 1) local role='TARGET_' ;;
88- *) echo "cc-wrapper: Error: Cannot be used with $hostOffset-offset deps" >2;
99- return 1 ;;
1010-esac
11+# See pkgs/build-support/setup-hooks/role.bash
22+getHostRole
113124linkCxxAbi="@linkCxxAbi@"
1313-export NIX_${role}CXXSTDLIB_COMPILE+=" -isystem @out@/include/c++/v1"
1414-export NIX_${role}CXXSTDLIB_LINK=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}"
55+export NIX_${role_pre}CXXSTDLIB_COMPILE+=" -isystem @out@/include/c++/v1"
66+export NIX_${role_pre}CXXSTDLIB_LINK=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}"
···11gettextDataDirsHook() {
22+ # See pkgs/build-support/setup-hooks/role.bash
33+ getHostRoleEnvHook
24 if [ -d "$1/share/gettext" ]; then
33- addToSearchPath GETTEXTDATADIRS "$1/share/gettext"
55+ addToSearchPath "GETTEXTDATADIRS${role_post}" "$1/share/gettext"
46 fi
57}
68···810911# libintl must be listed in load flags on non-Glibc
1012# it doesn't hurt to have it in Glibc either though
1111-gettextLdflags() {
1212- # The `depHostOffset` describes how the host platform of the dependencies
1313- # are slid relative to the depending package. It is brought into scope of
1414- # the environment hook defined as the role of the dependency being applied.
1515- case $depHostOffset in
1616- -1) local role='BUILD_' ;;
1717- 0) local role='' ;;
1818- 1) local role='TARGET_' ;;
1919- *) echo "cc-wrapper: Error: Cannot be used with $depHostOffset-offset deps" >2;
2020- return 1 ;;
2121- esac
2222-2323- export NIX_${role}LDFLAGS+=" -lintl"
2424-}
2525-2613if [ ! -z "@gettextNeedsLdflags@" ]; then
2727- addEnvHooks "$hostOffset" gettextLdflags
1414+ # See pkgs/build-support/setup-hooks/role.bash
1515+ getHostRole
1616+ export NIX_${role_pre}LDFLAGS+=" -lintl"
2817fi
···11# libiconv must be listed in load flags on non-Glibc
22# it doesn't hurt to have it in Glibc either though
33-iconvLdflags() {
44- # The `depHostOffset` describes how the host platform of the dependencies
55- # are slid relative to the depending package. It is brought into scope of
66- # the environment hook defined as the role of the dependency being applied.
77- case $depHostOffset in
88- -1) local role='BUILD_' ;;
99- 0) local role='' ;;
1010- 1) local role='TARGET_' ;;
1111- *) echo "cc-wrapper: Error: Cannot be used with $depHostOffset-offset deps" >2;
1212- return 1 ;;
1313- esac
1431515- export NIX_${role}LDFLAGS+=" -liconv"
1616-}
1717-1818-addEnvHooks "$hostOffset" iconvLdflags
44+# See pkgs/build-support/setup-hooks/role.bash
55+getHostRole
66+export NIX_${role_pre}LDFLAGS+=" -liconv"
+5-17
pkgs/os-specific/bsd/netbsd/compat-setup-hook.sh
···11-setupCompatFlags() {
22- # The `depHostOffset` describes how the host platform of the dependencies
33- # are slid relative to the depending package. It is brought into scope of
44- # the environment hook defined as the role of the dependency being applied.
55- case $depHostOffset in
66- -1) local role='BUILD_' ;;
77- 0) local role='' ;;
88- 1) local role='TARGET_' ;;
99- *) echo "cc-wrapper: Error: Cannot be used with $depHostOffset-offset deps" >2;
1010- return 1 ;;
1111- esac
11+# See pkgs/build-support/setup-hooks/role.bash
22+getHostRole
1231313- export NIX_${role}LDFLAGS+=" -lnbcompat"
1414- export NIX_${role}CFLAGS_COMPILE+=" -DHAVE_NBTOOL_CONFIG_H"
1515- export NIX_${role}CFLAGS_COMPILE+=" -include nbtool_config.h"
1616-}
1717-1818-addEnvHooks "$hostOffset" setupCompatFlags
44+export NIX_${role_pre}LDFLAGS+=" -lnbcompat"
55+export NIX_${role_pre}CFLAGS_COMPILE+=" -DHAVE_NBTOOL_CONFIG_H"
66+export NIX_${role_pre}CFLAGS_COMPILE+=" -include nbtool_config.h"
···11-ftsLdflags() {
22- # The `depHostOffset` describes how the host platform of the dependencies
33- # are slid relative to the depending package. It is brought into scope of
44- # the environment hook defined as the role of the dependency being applied.
55- case $depHostOffset in
66- -1) local role='BUILD_' ;;
77- 0) local role='' ;;
88- 1) local role='TARGET_' ;;
99- *) echo "cc-wrapper: Error: Cannot be used with $depHostOffset-offset deps" >2;
1010- return 1 ;;
1111- esac
11+# See pkgs/build-support/setup-hooks/role.bash
22+getHostRole
1231313- export NIX_${role}LDFLAGS+=" -lfts"
1414-}
1515-1616-addEnvHooks "$hostOffset" ftsLdflags
44+export NIX_${role_pre}LDFLAGS+=" -lfts"
+3-16
pkgs/os-specific/linux/musl/fts-setup-hook.sh
···11-ftsLdflags() {
22- # The `depHostOffset` describes how the host platform of the dependencies
33- # are slid relative to the depending package. It is brought into scope of
44- # the environment hook defined as the role of the dependency being applied.
55- case $depHostOffset in
66- -1) local role='BUILD_' ;;
77- 0) local role='' ;;
88- 1) local role='TARGET_' ;;
99- *) echo "cc-wrapper: Error: Cannot be used with $depHostOffset-offset deps" >2;
1010- return 1 ;;
1111- esac
11+# See pkgs/build-support/setup-hooks/role.bash
22+getHostRole
1231313- export NIX_${role}LDFLAGS+=" -lfts"
1414-}
1515-1616-addEnvHooks "$hostOffset" ftsLdflags
1717-44+export NIX_${role_pre}LDFLAGS+=" -lfts"