summary refs log tree commit diff
path: root/pkgs/development/tools/xcbuild
diff options
context:
space:
mode:
authorDave Nicponski <dev.Nicponski.Dave@dev.bwater.com>2020-04-22 18:58:45 -0400
committerDave Nicponski <dave.nicponski@gmail.com>2020-04-28 22:49:53 -0400
commitc3c3f68020af668e0c9ce3c93077e5f1fcafc87b (patch)
tree119460b22de112d8f931b0efeeb99a0f3f0f1b20 /pkgs/development/tools/xcbuild
parent7679b8edae18c8bf98b95ce2ca7d6413369f143a (diff)
downloadnixpkgs-c3c3f68020af668e0c9ce3c93077e5f1fcafc87b.tar
nixpkgs-c3c3f68020af668e0c9ce3c93077e5f1fcafc87b.tar.gz
nixpkgs-c3c3f68020af668e0c9ce3c93077e5f1fcafc87b.tar.bz2
nixpkgs-c3c3f68020af668e0c9ce3c93077e5f1fcafc87b.tar.lz
nixpkgs-c3c3f68020af668e0c9ce3c93077e5f1fcafc87b.tar.xz
nixpkgs-c3c3f68020af668e0c9ce3c93077e5f1fcafc87b.tar.zst
nixpkgs-c3c3f68020af668e0c9ce3c93077e5f1fcafc87b.zip
xcbuild: add compatibility support for exporting sdk info
"Real" xcodebuild allows using `xcodebuild -version -sdk` without
an sdk version argument, which will dump sdk info for all the
installed sdks.

Bazel"s "xcode cc toolchain setup on mac" process uses this
to determine which SDK version is actually installed.  This
change allows using a nix-supplied pinned compiler and build
system under bazel.
Diffstat (limited to 'pkgs/development/tools/xcbuild')
-rw-r--r--pkgs/development/tools/xcbuild/wrapper.nix4
1 files changed, 4 insertions, 0 deletions
diff --git a/pkgs/development/tools/xcbuild/wrapper.nix b/pkgs/development/tools/xcbuild/wrapper.nix
index cd7b8616366..861ef0fc847 100644
--- a/pkgs/development/tools/xcbuild/wrapper.nix
+++ b/pkgs/development/tools/xcbuild/wrapper.nix
@@ -110,11 +110,15 @@ runCommand "xcodebuild-${xcbuild.version}" {
   mkdir -p $out/Applications/Xcode.app/Contents
   ln -s $out $out/Applications/Xcode.app/Contents/Developer
 
+  # The native xcodebuild command supports an invocation like "xcodebuild -version -sdk" without specifying the specific SDK, so we simulate this by
+  # detecting this case and simulating the output; printing the header and appending the normal output via appending the sdk version to the positional
+  # arguments we pass through to the wrapped xcodebuild.
   makeWrapper ${xcbuild}/bin/xcodebuild $out/bin/xcodebuild \
     --add-flags "-xcconfig ${xcconfig}" \
     --add-flags "DERIVED_DATA_DIR=." \
     --set DEVELOPER_DIR "$out" \
     --set SDKROOT ${sdkName} \
+    --run '[ "$#" -eq 2 ] && [ "$1" = "-version" ] && [ "$2" = "-sdk" ] && echo ${sdkName}.sdk - macOS ${sdkVer} \(macosx${sdkVer}\) && set -- "$@" "${sdkName}"' \
     --run '[ "$1" = "-version" ] && [ "$#" -eq 1 ] && (echo Xcode ${xcodeVer}; echo Build version ${sdkBuildVersion}) && exit 0' \
     --run '[ "$1" = "-license" ] && exit 0'