summary refs log tree commit diff
path: root/pkgs/build-support/bintools-wrapper/setup-hook.sh
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2017-08-03 12:45:06 -0400
committerJohn Ericson <John.Ericson@Obsidian.Systems>2017-12-30 22:04:21 -0500
commita036473a0a0c6100fce316e1444fc33ec6674b85 (patch)
tree28e6431bc6133b0e8cf8a8a6546ef52a36e110b7 /pkgs/build-support/bintools-wrapper/setup-hook.sh
parent7f3ca3e21a22fd3101b40cadb86899542dec2e35 (diff)
downloadnixpkgs-a036473a0a0c6100fce316e1444fc33ec6674b85.tar
nixpkgs-a036473a0a0c6100fce316e1444fc33ec6674b85.tar.gz
nixpkgs-a036473a0a0c6100fce316e1444fc33ec6674b85.tar.bz2
nixpkgs-a036473a0a0c6100fce316e1444fc33ec6674b85.tar.lz
nixpkgs-a036473a0a0c6100fce316e1444fc33ec6674b85.tar.xz
nixpkgs-a036473a0a0c6100fce316e1444fc33ec6674b85.tar.zst
nixpkgs-a036473a0a0c6100fce316e1444fc33ec6674b85.zip
{bintools,cc}-wrapper: Fix setup hook to respect the role of the cc-compiler
We now have the information to properly determine the role the
cc-wrapper dependency has, by taking advantage of `offset`. No longer
use the soon-to-be-deprecated crossConfig environment variable, the
temp hack used before this change.
Diffstat (limited to 'pkgs/build-support/bintools-wrapper/setup-hook.sh')
-rw-r--r--pkgs/build-support/bintools-wrapper/setup-hook.sh42
1 files changed, 30 insertions, 12 deletions
diff --git a/pkgs/build-support/bintools-wrapper/setup-hook.sh b/pkgs/build-support/bintools-wrapper/setup-hook.sh
index 43f79ec5920..c508963ac33 100644
--- a/pkgs/build-support/bintools-wrapper/setup-hook.sh
+++ b/pkgs/build-support/bintools-wrapper/setup-hook.sh
@@ -2,12 +2,17 @@
 #
 # See comments in cc-wrapper's setup hook. This works exactly the same way.
 
+set -u
+
+# Skip setup hook if we're not a build-time dep
+(( "$hostOffset" < 0 )) || return 0
+
 bintoolsWrapper_addLDVars () {
-    case $depOffset in
+    case $depHostOffset in
         -1) local role='BUILD_' ;;
         0)  local role='' ;;
         1)  local role='TARGET_' ;;
-        *)  echo "bintools-wrapper: Error: Cannot be used with $depOffset-offset deps, " >2;
+        *)  echo "bintools-wrapper: Error: Cannot be used with $depHostOffset-offset deps" >2;
             return 1 ;;
     esac
 
@@ -20,17 +25,29 @@ bintoolsWrapper_addLDVars () {
     fi
 }
 
-if [ -n "${crossConfig:-}" ]; then
-    export NIX_BINTOOLS_WRAPPER_@infixSalt@_TARGET_BUILD=1
-    role_pre='BUILD_'
-    role_post='_FOR_BUILD'
-else
-    export NIX_BINTOOLS_WRAPPER_@infixSalt@_TARGET_HOST=1
-    role_pre=""
-    role_post=''
-fi
+case $targetOffset in
+    -1)
+        export NIX_BINTOOLS_WRAPPER_@infixSalt@_TARGET_BUILD=1
+        role_pre='BUILD_'
+        role_post='_FOR_BUILD'
+        ;;
+    0)
+        export NIX_BINTOOLS_WRAPPER_@infixSalt@_TARGET_HOST=1
+        role_pre=''
+        role_post=''
+        ;;
+    1)
+        export NIX_BINTOOLS_WRAPPER_@infixSalt@_TARGET_TARGET=1
+        role_pre='TARGET_'
+        role_post='_FOR_TARGET'
+        ;;
+    *)
+        echo "cc-wrapper: used as improper sort of dependency" >2;
+        return 1
+        ;;
+esac
 
-envHooks+=(bintoolsWrapper_addLDVars)
+addEnvHooks "$targetOffset" bintoolsWrapper_addLDVars
 
 # shellcheck disable=SC2157
 if [ -n "@bintools_bin@" ]; then
@@ -65,3 +82,4 @@ done
 
 # No local scope in sourced file
 unset -v role_pre role_post cmd upper_case
+set +u