-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_all.bash
More file actions
97 lines (83 loc) · 2.52 KB
/
Copy pathbuild_all.bash
File metadata and controls
97 lines (83 loc) · 2.52 KB
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
96
97
#!/usr/bin/env bash
# Build all MsptMetricsMod modules sequentially via Docker runner.
#
# Usage:
# ./build_all.bash # build ALL modules
# ./build_all.bash <filter> # build only items matching substring, e.g. "paper", "forge_1_12_2"
#
# Env overrides:
# TASK=build # Gradle task to execute (default: build)
# PROGRESS=plain # Passes through to docker buildx (flat logs)
#
# Requirements:
# - Docker with buildx
# - ./run_build.bash in repo root (auto-selects modern/legacy targets)
set -uo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
RUNNER="./run_build.bash"
if [[ ! -x "$RUNNER" ]]; then
echo "ERROR: $RUNNER not found or not executable." >&2
exit 2
fi
# Full, explicit list (order matters)
read -r -d '' MODULES <<'EOF'
paper paper_1_21_9
paper paper_1_21_8
paper paper_1_21_7
paper paper_1_21_4
paper paper_1_21_1
EOF
FILTER="${1:-}"
TASK_OVERRIDE="${TASK:-build}"
SUCCESS=()
FAILED=()
DURATIONS=()
now() { date +%s; }
format_dur() {
local sec=$1
printf "%dm %02ds" $((sec/60)) $((sec%60))
}
build_one() {
local group="$1" submodule="$2"
local label="$group/$submodule"
if [[ -n "$FILTER" ]] && [[ "$label" != *"$FILTER"* ]]; then
return 0
fi
echo "\n===== ▶ Building: $label (TASK=$TASK_OVERRIDE) ====="
local t0=$(now)
if PROGRESS="${PROGRESS:-}" "$RUNNER" "$group" "$submodule" "$TASK_OVERRIDE"; then
local t1=$(now); local dt=$((t1 - t0))
SUCCESS+=("$label")
DURATIONS+=("$label|$dt")
echo "===== ✅ Done: $label in $(format_dur "$dt") =====\n"
else
local t1=$(now); local dt=$((t1 - t0))
FAILED+=("$label")
DURATIONS+=("$label|$dt")
echo "===== Failed: $label after $(format_dur "$dt") =====\n"
fi
}
# Iterate
while read -r GROUP SUBMODULE; do
[[ -z "${GROUP:-}" ]] && continue
build_one "$GROUP" "$SUBMODULE"
done <<< "$MODULES"
# Summary
TOTAL=$(( ${#SUCCESS[@]} + ${#FAILED[@]} ))
echo "\n==================== SUMMARY ===================="
echo "Total: $TOTAL | OK: ${#SUCCESS[@]} | FAIL: ${#FAILED[@]}"
if ((${#SUCCESS[@]})); then
echo "\nOK:"; for s in "${SUCCESS[@]}"; do echo " - $s"; done
fi
if ((${#FAILED[@]})); then
echo "\nFAILED:"; for f in "${FAILED[@]}"; do echo " - $f"; done
fi
echo "\nDurations:"
for item in "${DURATIONS[@]}"; do
IFS='|' read -r lbl sec <<<"$item"
printf " - %-28s %s\n" "$lbl" "$(format_dur "$sec")"
done
echo "\nArtifacts are under ./out/<group>/<submodule>/"
# Exit 0 if all succeeded; 1 otherwise
if ((${#FAILED[@]})); then exit 1; else exit 0; fi