OLD | NEW |
---|---|
(Empty) | |
1 #!/bin/bash | |
2 # Copyright (c) 2014 Google Inc. All rights reserved. | |
3 # Use of this source code is governed by a BSD-style license that can be | |
4 # found in the LICENSE file. | |
5 | |
6 set -e | |
7 | |
8 # `xcodebuild -version` output looks like | |
9 # Xcode 4.6.3 | |
10 # Build version 4H1503 | |
11 # or like | |
12 # Xcode 3.2.6 | |
13 # Component versions: DevToolsCore-1809.0; DevToolsSupport-1806.0 | |
14 # BuildVersion: 10M2518 | |
15 # Convert that to '0463' | |
16 function xcodeversion() { | |
17 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
| |
18 } | |
19 | |
20 # Returns true if |string1| is smaller than |string2|. | |
21 # This function assumes that both strings represent Xcode version numbers | |
22 # as returned by |xcodeversion|. | |
23 function smaller() { | |
24 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.
| |
25 test "${min}" != "${2}" | |
26 } | |
27 | |
28 # If Xcode version is older than 5.0.0, check that SDKROOT is set but empty. | |
29 # Otherwise, check that it is set to "xcodebuild -version -sdk '' Path". | |
30 if smaller "$(xcodeversion)" "0500"; then | |
31 [[ ! ${SDKROOT} && ${SDKROOT-_} ]] | |
32 else | |
33 [[ "${SDKROOT}" == "$(xcodebuild -version -sdk '' Path)" ]] | |
34 fi | |
OLD | NEW |