Repository navigation
Expand file tree
/
Copy pathsync_from_lvgl_bindings.sh
More file actions
executable file
·78 lines (68 loc) · 2.27 KB
/
Copy pathsync_from_lvgl_bindings.sh
File metadata and controls
executable file
·78 lines (68 loc) · 2.27 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
#!/usr/bin/env bash
# Sync the hand-written Python helper (fs_driver.py)
# from PyDevices/lvgl-bindings on GitHub (not the local workspace).
#
# Usage:
# ./scripts/sync_from_lvgl_bindings.sh --ref <40-character commit SHA>
# ./scripts/sync_from_lvgl_bindings.sh --ref v9.5.N
#
# After syncing, commit the updated files under lib/ in this repo.
set -euo pipefail
LV_BINDINGS_REPO="${LV_BINDINGS_REPO:-https://github.com/PyDevices/lvgl-bindings.git}"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SOURCE_REPO="$(cd "$SCRIPT_DIR/.." && pwd)"
REF="${LV_BINDINGS_REF:-}"
while [[ $# -gt 0 ]]; do
case "$1" in
--ref)
REF=$2
shift 2
;;
--help | -h)
sed -n '2,12p' "$0" | sed 's/^# \?//'
exit 0
;;
*)
echo "Unknown option: $1" >&2
exit 1
;;
esac
done
if [[ -z "$REF" ]]; then
REF=$(tr -d '[:space:]' < "$SOURCE_REPO/LVGL_BINDINGS_COMMIT")
fi
if [[ ! "$REF" =~ ^[0-9a-fA-F]{40}$ && ! "$REF" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: --ref must be an exact 40-character commit SHA or vX.Y.Z tag, got: $REF" >&2
exit 1
fi
TMP=$(mktemp -d)
cleanup() { rm -rf "$TMP"; }
trap cleanup EXIT
HELPERS=(fs_driver.py)
echo "Fetching ${LV_BINDINGS_REPO} @ ${REF}..."
git clone --filter=blob:none --no-checkout "${LV_BINDINGS_REPO}" "${TMP}/lvgl-bindings"
git -C "${TMP}/lvgl-bindings" fetch origin "$REF"
RESOLVED_REF=$(git -C "${TMP}/lvgl-bindings" rev-parse 'FETCH_HEAD^{commit}')
for helper in "${HELPERS[@]}"; do
git -C "${TMP}/lvgl-bindings" checkout "$RESOLVED_REF" -- "python/${helper}"
done
mkdir -p "${SOURCE_REPO}/lib"
for helper in "${HELPERS[@]}"; do
SRC="${TMP}/lvgl-bindings/python/${helper}"
if [[ ! -f "$SRC" ]]; then
echo "Error: python/${helper} not found on ${REF}." >&2
exit 1
fi
cp "$SRC" "${SOURCE_REPO}/lib/${helper}"
done
printf '%s\n' "$RESOLVED_REF" > "${SOURCE_REPO}/LVGL_BINDINGS_COMMIT"
echo
echo "Synced from lvgl-bindings ${RESOLVED_REF}:"
for helper in "${HELPERS[@]}"; do
echo " lib/${helper}"
done
echo
echo "Commit when ready:"
echo " LVGL_BINDINGS_COMMIT"
echo " git add LVGL_BINDINGS_COMMIT lib/"
echo " git commit -m \"Sync Python helpers from lvgl-bindings ${RESOLVED_REF}.\""