Also fix some setup hooks that unnecessarily used environment hooks, which revolted in the same variable being modified too many times.wip/yesman
parent
34a3233a2e
commit
2110c0bd30
@ -0,0 +1,75 @@ |
||||
# Since the same derivation can be depend on in multiple ways, we need to |
||||
# accumulate *each* role (i.e. host and target platforms relative the depending |
||||
# derivation) in which the derivation is used. |
||||
# |
||||
# The role is intened to be use as part of other variables names like |
||||
# - $NIX_${role_pre}_SOMETHING |
||||
# - $NIX_SOMETHING_${role_post} |
||||
|
||||
function getRole() { |
||||
case $1 in |
||||
-1) |
||||
role_pre='BUILD_' |
||||
role_post='_FOR_BUILD' |
||||
;; |
||||
0) |
||||
role_pre='' |
||||
role_post='' |
||||
;; |
||||
1) |
||||
role_pre='TARGET_' |
||||
role_post='_FOR_TARGET' |
||||
;; |
||||
*) |
||||
echo "@name@: used as improper sort of dependency" >2 |
||||
return 1 |
||||
;; |
||||
esac |
||||
} |
||||
|
||||
# `hostOffset` describes how the host platform of the package is slid relative |
||||
# to the depending package. `targetOffset` likewise describes the target |
||||
# platform of the package. Both are brought into scope of the setup hook defined |
||||
# for dependency whose setup hook is being processed relative to the package |
||||
# being built. |
||||
|
||||
function getHostRole() { |
||||
getRole "$hostOffset" |
||||
} |
||||
function getTargetRole() { |
||||
getRole "$targetOffset" |
||||
} |
||||
|
||||
# `depHostOffset` describes how the host platform of the dependencies are slid |
||||
# relative to the depending package. `depTargetOffset` likewise describes the |
||||
# target platform of dependenices. Both are brought into scope of the |
||||
# environment hook defined for the dependency being applied relative to the |
||||
# package being built. |
||||
|
||||
function getHostRoleEnvHook() { |
||||
getRole "$depHostOffset" |
||||
} |
||||
function getTargetRoleEnvHook() { |
||||
getRole "$depTargetOffset" |
||||
} |
||||
|
||||
# This variant is inteneded specifically for code-prodocing tool wrapper scripts |
||||
# `NIX_@wrapperName@_@infixSalt@_TARGET_*` tracks this (needs to be an exported |
||||
# env var so can't use fancier data structures). |
||||
function getTargetRoleWrapper() { |
||||
case $targetOffset in |
||||
-1) |
||||
export NIX_@wrapperName@_@infixSalt@_TARGET_BUILD=1 |
||||
;; |
||||
0) |
||||
export NIX_@wrapperName@_@infixSalt@_TARGET_HOST=1 |
||||
;; |
||||
1) |
||||
export NIX_@wrapperName@_@infixSalt@_TARGET_TARGET=1 |
||||
;; |
||||
*) |
||||
echo "@name@: used as improper sort of dependency" >2 |
||||
return 1 |
||||
;; |
||||
esac |
||||
} |
@ -1,13 +1,5 @@ |
||||
# The `hostOffset` describes how the host platform of the dependencies are slid |
||||
# relative to the depending package. It is brought into scope of the setup hook |
||||
# defined as the role of the dependency whose hooks is being run. |
||||
case $hostOffset in |
||||
-1) local role='BUILD_' ;; |
||||
0) local role='' ;; |
||||
1) local role='TARGET_' ;; |
||||
*) echo "cc-wrapper: Error: Cannot be used with $hostOffset-offset deps" >2; |
||||
return 1 ;; |
||||
esac |
||||
# See pkgs/build-support/setup-hooks/role.bash |
||||
getHostRole |
||||
|
||||
export NIX_${role}CXXSTDLIB_COMPILE+=" -isystem $(echo -n @gcc@/include/c++/*) -isystem $(echo -n @gcc@/include/c++/*)/$(@gcc@/bin/gcc -dumpmachine)" |
||||
export NIX_${role}CXXSTDLIB_LINK=" -stdlib=libstdc++" |
||||
export NIX_${role_pre}CXXSTDLIB_COMPILE+=" -isystem $(echo -n @gcc@/include/c++/*) -isystem $(echo -n @gcc@/include/c++/*)/$(@gcc@/bin/gcc -dumpmachine)" |
||||
export NIX_${role_pre}CXXSTDLIB_LINK=" -stdlib=libstdc++" |
||||
|
@ -1,14 +1,6 @@ |
||||
# The `hostOffset` describes how the host platform of the dependencies are slid |
||||
# relative to the depending package. It is brought into scope of the setup hook |
||||
# defined as the role of the dependency whose hooks is being run. |
||||
case $hostOffset in |
||||
-1) local role='BUILD_' ;; |
||||
0) local role='' ;; |
||||
1) local role='TARGET_' ;; |
||||
*) echo "cc-wrapper: Error: Cannot be used with $hostOffset-offset deps" >2; |
||||
return 1 ;; |
||||
esac |
||||
# See pkgs/build-support/setup-hooks/role.bash |
||||
getHostRole |
||||
|
||||
linkCxxAbi="@linkCxxAbi@" |
||||
export NIX_${role}CXXSTDLIB_COMPILE+=" -isystem @out@/include/c++/v1" |
||||
export NIX_${role}CXXSTDLIB_LINK=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}" |
||||
export NIX_${role_pre}CXXSTDLIB_COMPILE+=" -isystem @out@/include/c++/v1" |
||||
export NIX_${role_pre}CXXSTDLIB_LINK=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}" |
||||
|
@ -1,14 +1,6 @@ |
||||
# The `hostOffset` describes how the host platform of the dependencies are slid |
||||
# relative to the depending package. It is brought into scope of the setup hook |
||||
# defined as the role of the dependency whose hooks is being run. |
||||
case $hostOffset in |
||||
-1) local role='BUILD_' ;; |
||||
0) local role='' ;; |
||||
1) local role='TARGET_' ;; |
||||
*) echo "cc-wrapper: Error: Cannot be used with $hostOffset-offset deps" >2; |
||||
return 1 ;; |
||||
esac |
||||
# See pkgs/build-support/setup-hooks/role.bash |
||||
getHostRole |
||||
|
||||
linkCxxAbi="@linkCxxAbi@" |
||||
export NIX_${role}CXXSTDLIB_COMPILE+=" -isystem @out@/include/c++/v1" |
||||
export NIX_${role}CXXSTDLIB_LINK=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}" |
||||
export NIX_${role_pre}CXXSTDLIB_COMPILE+=" -isystem @out@/include/c++/v1" |
||||
export NIX_${role_pre}CXXSTDLIB_LINK=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}" |
||||
|
@ -1,14 +1,6 @@ |
||||
# The `hostOffset` describes how the host platform of the dependencies |
||||
# relative to the depending package. It is brought into scope of the setup hook |
||||
# defined as the role of the dependency whose hooks is being run. |
||||
case $hostOffset in |
||||
-1) local role='BUILD_' ;; |
||||
0) local role='' ;; |
||||
1) local role='TARGET_' ;; |
||||
*) echo "cc-wrapper: Error: Cannot be used with $hostOffset-offset deps" >2; |
||||
return 1 ;; |
||||
esac |
||||
# See pkgs/build-support/setup-hooks/role.bash |
||||
getHostRole |
||||
|
||||
linkCxxAbi="@linkCxxAbi@" |
||||
export NIX_${role}CXXSTDLIB_COMPILE+=" -isystem @out@/include/c++/v1" |
||||
export NIX_${role}CXXSTDLIB_LINK=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}" |
||||
export NIX_${role_pre}CXXSTDLIB_COMPILE+=" -isystem @out@/include/c++/v1" |
||||
export NIX_${role_pre}CXXSTDLIB_LINK=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}" |
||||
|
@ -1,14 +1,6 @@ |
||||
# The `hostOffset` describes how the host platform of the dependencies |
||||
# relative to the depending package. It is brought into scope of the setup hook |
||||
# defined as the role of the dependency whose hooks is being run. |
||||
case $hostOffset in |
||||
-1) local role='BUILD_' ;; |
||||
0) local role='' ;; |
||||
1) local role='TARGET_' ;; |
||||
*) echo "cc-wrapper: Error: Cannot be used with $hostOffset-offset deps" >2; |
||||
return 1 ;; |
||||
esac |
||||
# See pkgs/build-support/setup-hooks/role.bash |
||||
getHostRole |
||||
|
||||
linkCxxAbi="@linkCxxAbi@" |
||||
export NIX_${role}CXXSTDLIB_COMPILE+=" -isystem @out@/include/c++/v1" |
||||
export NIX_${role}CXXSTDLIB_LINK=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}" |
||||
export NIX_${role_pre}CXXSTDLIB_COMPILE+=" -isystem @out@/include/c++/v1" |
||||
export NIX_${role_pre}CXXSTDLIB_LINK=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}" |
||||
|
@ -1,14 +1,6 @@ |
||||
# The `hostOffset` describes how the host platform of the dependencies |
||||
# relative to the depending package. It is brought into scope of the setup hook |
||||
# defined as the role of the dependency whose hooks is being run. |
||||
case $hostOffset in |
||||
-1) local role='BUILD_' ;; |
||||
0) local role='' ;; |
||||
1) local role='TARGET_' ;; |
||||
*) echo "cc-wrapper: Error: Cannot be used with $hostOffset-offset deps" >2; |
||||
return 1 ;; |
||||
esac |
||||
# See pkgs/build-support/setup-hooks/role.bash |
||||
getHostRole |
||||
|
||||
linkCxxAbi="@linkCxxAbi@" |
||||
export NIX_${role}CXXSTDLIB_COMPILE+=" -isystem @out@/include/c++/v1" |
||||
export NIX_${role}CXXSTDLIB_LINK=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}" |
||||
export NIX_${role_pre}CXXSTDLIB_COMPILE+=" -isystem @out@/include/c++/v1" |
||||
export NIX_${role_pre}CXXSTDLIB_LINK=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}" |
||||
|
@ -1,14 +1,6 @@ |
||||
# The `hostOffset` describes how the host platform of the dependencies |
||||
# relative to the depending package. It is brought into scope of the setup hook |
||||
# defined as the role of the dependency whose hooks is being run. |
||||
case $hostOffset in |
||||
-1) local role='BUILD_' ;; |
||||
0) local role='' ;; |
||||
1) local role='TARGET_' ;; |
||||
*) echo "cc-wrapper: Error: Cannot be used with $hostOffset-offset deps" >2; |
||||
return 1 ;; |
||||
esac |
||||
# See pkgs/build-support/setup-hooks/role.bash |
||||
getHostRole |
||||
|
||||
linkCxxAbi="@linkCxxAbi@" |
||||
export NIX_${role}CXXSTDLIB_COMPILE+=" -isystem @out@/include/c++/v1" |
||||
export NIX_${role}CXXSTDLIB_LINK=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}" |
||||
export NIX_${role_pre}CXXSTDLIB_COMPILE+=" -isystem @out@/include/c++/v1" |
||||
export NIX_${role_pre}CXXSTDLIB_LINK=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}" |
||||
|
@ -1,14 +1,6 @@ |
||||
# The `hostOffset` describes how the host platform of the dependencies |
||||
# relative to the depending package. It is brought into scope of the setup hook |
||||
# defined as the role of the dependency whose hooks is being run. |
||||
case $hostOffset in |
||||
-1) local role='BUILD_' ;; |
||||
0) local role='' ;; |
||||
1) local role='TARGET_' ;; |
||||
*) echo "cc-wrapper: Error: Cannot be used with $hostOffset-offset deps" >2; |
||||
return 1 ;; |
||||
esac |
||||
# See pkgs/build-support/setup-hooks/role.bash |
||||
getHostRole |
||||
|
||||
linkCxxAbi="@linkCxxAbi@" |
||||
export NIX_${role}CXXSTDLIB_COMPILE+=" -isystem @out@/include/c++/v1" |
||||
export NIX_${role}CXXSTDLIB_LINK=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}" |
||||
export NIX_${role_pre}CXXSTDLIB_COMPILE+=" -isystem @out@/include/c++/v1" |
||||
export NIX_${role_pre}CXXSTDLIB_LINK=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}" |
||||
|
@ -1,18 +1,6 @@ |
||||
# libiconv must be listed in load flags on non-Glibc |
||||
# it doesn't hurt to have it in Glibc either though |
||||
iconvLdflags() { |
||||
# The `depHostOffset` describes how the host platform of the dependencies |
||||
# are slid relative to the depending package. It is brought into scope of |
||||
# the environment hook defined as the role of the dependency being applied. |
||||
case $depHostOffset in |
||||
-1) local role='BUILD_' ;; |
||||
0) local role='' ;; |
||||
1) local role='TARGET_' ;; |
||||
*) echo "cc-wrapper: Error: Cannot be used with $depHostOffset-offset deps" >2; |
||||
return 1 ;; |
||||
esac |
||||
|
||||
export NIX_${role}LDFLAGS+=" -liconv" |
||||
} |
||||
|
||||
addEnvHooks "$hostOffset" iconvLdflags |
||||
# See pkgs/build-support/setup-hooks/role.bash |
||||
getHostRole |
||||
export NIX_${role_pre}LDFLAGS+=" -liconv" |
||||
|
@ -1,18 +1,6 @@ |
||||
setupCompatFlags() { |
||||
# The `depHostOffset` describes how the host platform of the dependencies |
||||
# are slid relative to the depending package. It is brought into scope of |
||||
# the environment hook defined as the role of the dependency being applied. |
||||
case $depHostOffset in |
||||
-1) local role='BUILD_' ;; |
||||
0) local role='' ;; |
||||
1) local role='TARGET_' ;; |
||||
*) echo "cc-wrapper: Error: Cannot be used with $depHostOffset-offset deps" >2; |
||||
return 1 ;; |
||||
esac |
||||
# See pkgs/build-support/setup-hooks/role.bash |
||||
getHostRole |
||||
|
||||
export NIX_${role}LDFLAGS+=" -lnbcompat" |
||||
export NIX_${role}CFLAGS_COMPILE+=" -DHAVE_NBTOOL_CONFIG_H" |
||||
export NIX_${role}CFLAGS_COMPILE+=" -include nbtool_config.h" |
||||
} |
||||
|
||||
addEnvHooks "$hostOffset" setupCompatFlags |
||||
export NIX_${role_pre}LDFLAGS+=" -lnbcompat" |
||||
export NIX_${role_pre}CFLAGS_COMPILE+=" -DHAVE_NBTOOL_CONFIG_H" |
||||
export NIX_${role_pre}CFLAGS_COMPILE+=" -include nbtool_config.h" |
||||
|
@ -1,16 +1,4 @@ |
||||
ftsLdflags() { |
||||
# The `depHostOffset` describes how the host platform of the dependencies |
||||
# are slid relative to the depending package. It is brought into scope of |
||||
# the environment hook defined as the role of the dependency being applied. |
||||
case $depHostOffset in |
||||
-1) local role='BUILD_' ;; |
||||
0) local role='' ;; |
||||
1) local role='TARGET_' ;; |
||||
*) echo "cc-wrapper: Error: Cannot be used with $depHostOffset-offset deps" >2; |
||||
return 1 ;; |
||||
esac |
||||
# See pkgs/build-support/setup-hooks/role.bash |
||||
getHostRole |
||||
|
||||
export NIX_${role}LDFLAGS+=" -lfts" |
||||
} |
||||
|
||||
addEnvHooks "$hostOffset" ftsLdflags |
||||
export NIX_${role_pre}LDFLAGS+=" -lfts" |
||||
|
@ -1,17 +1,4 @@ |
||||
ftsLdflags() { |
||||
# The `depHostOffset` describes how the host platform of the dependencies |
||||
# are slid relative to the depending package. It is brought into scope of |
||||
# the environment hook defined as the role of the dependency being applied. |
||||
case $depHostOffset in |
||||
-1) local role='BUILD_' ;; |
||||
0) local role='' ;; |
||||
1) local role='TARGET_' ;; |
||||
*) echo "cc-wrapper: Error: Cannot be used with $depHostOffset-offset deps" >2; |
||||
return 1 ;; |
||||
esac |
||||
|
||||
export NIX_${role}LDFLAGS+=" -lfts" |
||||
} |
||||
|
||||
addEnvHooks "$hostOffset" ftsLdflags |
||||
# See pkgs/build-support/setup-hooks/role.bash |
||||
getHostRole |
||||
|
||||
export NIX_${role_pre}LDFLAGS+=" -lfts" |
||||
|
Loading…
Reference in new issue