This repository has been archived by the owner on Apr 22, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.sh
executable file
·95 lines (76 loc) · 1.83 KB
/
build.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/usr/bin/env bash
_has() {
local needle="$1"; shift
local x
res=1
for x in "$@"; do
if [[ "$x" = "$needle" ]]; then
res=0
fi
done
return "$res"
}
_build() {
f:bbuild "$@" || {
BUILDSTATUS=$((BUILDSTATUS+1))
return
}
}
use_bootstrap_script() {
# running bin/bbuild to re-write itself leads to spurious
# errors. Use a separate bootstrapping copy
mkdir -p bin-candidates
cp bin/bbuild bin-candidates/bbuild-bootstrap
f:bbuild() {
bin-candidates/bbuild-bootstrap "$@"
}
}
set_build_outdir() {
# By default, do NOT blat previous release !
export BUILDOUTD=bin-candidates/
RUN_TESTS=true
f:bbuild() {
bin/bbuild "$@"
}
if [[ "$*" =~ --release ]]; then
use_bootstrap_script
export BUILDOUTD=bin/
RUN_TESTS=false
fi
}
run_tests() {
if [[ "$RUN_TESTS" = true ]]; then
echo -e "\n--- Integration tests"
test-integration/test-all.sh
echo -e "---\n"
fi
}
main() {
local all_scripts=(bbuild bbrun bashdoc tarshc)
set_build_outdir "$@"
BUILDSTATUS=0
if [[ -n "$*" ]] && [[ ! "$*" = --release ]]; then # Build specific
for buildsrc in "${all_scripts[@]}"; do
if _has "$buildsrc" "$@"; then
_build "src/$buildsrc"
fi
done
if _has install "$@"; then
_build src/install.sh ./install.sh
fi
else # Build all
for buildsrc in "${all_scripts[@]}"; do
_build "src/$buildsrc"
done
_build src/install.sh ./install.sh
fi
run_tests
[[ "$BUILDSTATUS" -le 0 ]] || {
echo "BUILD FAIL -- $BUILDSTATUS failures"
exit 1
}
echo "Version of bbuild is:"
echo
"$BUILDOUTD/bbuild" --version
}
main "$@"