From c3c3f68020af668e0c9ce3c93077e5f1fcafc87b Mon Sep 17 00:00:00 2001 From: Dave Nicponski Date: Wed, 22 Apr 2020 18:58:45 -0400 Subject: 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. --- pkgs/development/tools/xcbuild/wrapper.nix | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'pkgs/development/tools/xcbuild') 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' -- cgit 1.4.1