forked from google/startup-os
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_or_test.sh
executable file
·37 lines (30 loc) · 1.07 KB
/
build_or_test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env bash
# Build or test all targets.
# Note that 'testing all targets' also builds all buildable targets.
# If ANDROID_HOME is not set, skips Android targets.
# Usage: tools/build_or_test.sh (build|test)
RED=$(tput setaf 1)
GREEN=$(tput setaf 2)
RESET=$(tput sgr0)
function bazel_build() {
if [[ -z "$ANDROID_HOME" ]]; then
# Ignore third_party, node_modules and android targets
bazel query '//... except //third_party/... except filter(node_modules, //...) except kind("android_.* rule", //...)' | xargs bazel $1
return $?
else
# Ignore just third_party and node_modules
bazel query '//... except //third_party/... except filter(node_modules, //...)' | xargs bazel $1
return $?
fi
}
# Warn if ANDROID_HOME is not set.
if [[ -z "$ANDROID_HOME" ]]; then
echo "$RED""ANDROID_HOME not set, skipping Android targets. See examples/android for more details.$RESET"
fi
# Check we have (build|test) param
if [[ $1 != "build" && $1 != "test" ]]; then
echo "$RED""Run script with 'build' or 'test' as param$RESET"
exit 1
fi
bazel_build $1
exit $?