Index: test/mac/type_envvars/test_check_sdkroot.sh |
diff --git a/test/mac/type_envvars/test_check_sdkroot.sh b/test/mac/type_envvars/test_check_sdkroot.sh |
new file mode 100644 |
index 0000000000000000000000000000000000000000..86f0edb25647e874c96e8dcafa20bd4f400ae5a1 |
--- /dev/null |
+++ b/test/mac/type_envvars/test_check_sdkroot.sh |
@@ -0,0 +1,34 @@ |
+#!/bin/bash |
+# Copyright (c) 2014 Google Inc. All rights reserved. |
+# Use of this source code is governed by a BSD-style license that can be |
+# found in the LICENSE file. |
+ |
+set -e |
+ |
+# `xcodebuild -version` output looks like |
+# Xcode 4.6.3 |
+# Build version 4H1503 |
+# or like |
+# Xcode 3.2.6 |
+# Component versions: DevToolsCore-1809.0; DevToolsSupport-1806.0 |
+# BuildVersion: 10M2518 |
+# Convert that to '0463' |
+function xcodeversion() { |
+ xcodebuild -version|head -n1|sed 's,.* ,0000,;s,\.,,g;s,.*\(....\)$,\1,' |
Mark Mentovai
2014/03/06 17:27:29
This works for me locally too, but I have Xcode 5
sdefresne
2014/03/07 21:16:11
OK, there were multiple incorrect assumption in my
|
+} |
+ |
+# Returns true if |string1| is smaller than |string2|. |
+# This function assumes that both strings represent Xcode version numbers |
+# as returned by |xcodeversion|. |
+function smaller() { |
+ local min="$(echo -ne "${1}\n${2}\n"|sort -n|head -n1)" |
Mark Mentovai
2014/03/06 17:27:29
Can you put some spaces around your pipes for read
sdefresne
2014/03/07 21:16:11
Done.
|
+ test "${min}" != "${2}" |
+} |
+ |
+# If Xcode version is older than 5.0.0, check that SDKROOT is set but empty. |
+# Otherwise, check that it is set to "xcodebuild -version -sdk '' Path". |
+if smaller "$(xcodeversion)" "0500"; then |
+ [[ ! ${SDKROOT} && ${SDKROOT-_} ]] |
+else |
+ [[ "${SDKROOT}" == "$(xcodebuild -version -sdk '' Path)" ]] |
+fi |