Skip to content
This repository was archived by the owner on Aug 4, 2022. It is now read-only.

Commit 0f07d8f

Browse files
jverkoeyajsecord
authored andcommitted
Add support for specifying a minimum Xcode version. (#6)
1 parent e22aaa1 commit 0f07d8f

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@ git fetch
4747
git checkout v3.0.0
4848
popd
4949

50-
./.kokoro-ios-runner/bazel.sh build //:CatalogByConvention
51-
./.kokoro-ios-runner/bazel.sh test //:CatalogByConventionTests
50+
./.kokoro-ios-runner/bazel.sh build //:CatalogByConvention 8.0.0
51+
./.kokoro-ios-runner/bazel.sh test //:CatalogByConventionTests 8.0.0
5252
```

bazel.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
# Arguments:
2323
# 1. bazel action (build or test, usually)
2424
# 2. BUILD target.
25+
# 3. Minimum Xcode version. E.g. "8" or "8.2.1"
2526
#
2627
# Example usage:
2728
# bazel.sh build //:CatalogByConvention
@@ -36,8 +37,18 @@ set -x
3637
script_version="v3.0.0"
3738
echo "bazel_build_and_test version $script_version"
3839

40+
version_as_number() {
41+
padded_version="${1%.}" # Strip any trailing dots
42+
# Pad with .0 until we get a M.m.p version string.
43+
while [ $(grep -o "\." <<< "$padded_version" | wc -l) -lt "2" ]; do
44+
padded_version=${padded_version}.0
45+
done
46+
echo "${padded_version//.}"
47+
}
48+
3949
action="$1"
4050
target="$2"
51+
min_xcode_version="$(version_as_number $3)"
4152

4253
# Dependencies
4354

@@ -55,6 +66,16 @@ ls /Applications/ | grep "Xcode" | while read -r xcode_path; do
5566
| grep string \
5667
| cut -d'>' -f2 \
5768
| cut -d'<' -f1)
69+
if [ -z "$min_xcode_version" ]; then
70+
:
71+
else
72+
xcode_version_as_number="$(version_as_number $xcode_version)"
73+
74+
# TODO: This doesn't work yet.
75+
if [ "$xcode_version_as_number" -lt "$min_xcode_version" ]; then
76+
continue
77+
fi
78+
fi
5879

5980
set +x
6081
if [ "$action" == "build" ]; then

0 commit comments

Comments
 (0)