pytrainer: unpin python 3.10
[NixPkgs.git] / pkgs / build-support / setup-hooks / role.bash
blobbfd6b61f0aed69f00b86d993080e3b16351a63cd
1 # Since the same derivation can be depended on in multiple ways, we need to
2 # accumulate *each* role (i.e. host and target platforms relative the depending
3 # derivation) in which the derivation is used.
5 # The role is intended to be used as part of other variables names like
6 # - $NIX_SOMETHING${role_post}
8 function getRole() {
9 case $1 in
10 -1)
11 role_post='_FOR_BUILD'
14 role_post=''
17 role_post='_FOR_TARGET'
20 echo "@name@: used as improper sort of dependency" >&2
21 return 1
23 esac
26 # `hostOffset` describes how the host platform of the package is slid relative
27 # to the depending package. `targetOffset` likewise describes the target
28 # platform of the package. Both are brought into scope of the setup hook defined
29 # for dependency whose setup hook is being processed relative to the package
30 # being built.
32 function getHostRole() {
33 getRole "$hostOffset"
35 function getTargetRole() {
36 getRole "$targetOffset"
39 # `depHostOffset` describes how the host platform of the dependencies are slid
40 # relative to the depending package. `depTargetOffset` likewise describes the
41 # target platform of dependenices. Both are brought into scope of the
42 # environment hook defined for the dependency being applied relative to the
43 # package being built.
45 function getHostRoleEnvHook() {
46 getRole "$depHostOffset"
48 function getTargetRoleEnvHook() {
49 getRole "$depTargetOffset"
52 # This variant is intended specifically for code-producing tool wrapper scripts
53 # `NIX_@wrapperName@_TARGET_*_@suffixSalt@` tracks this (needs to be an exported
54 # env var so can't use fancier data structures).
55 function getTargetRoleWrapper() {
56 case $targetOffset in
57 -1)
58 export NIX_@wrapperName@_TARGET_BUILD_@suffixSalt@=1
61 export NIX_@wrapperName@_TARGET_HOST_@suffixSalt@=1
64 export NIX_@wrapperName@_TARGET_TARGET_@suffixSalt@=1
67 echo "@name@: used as improper sort of dependency" >&2
68 return 1
70 esac