-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathgenerate-bindings.sh
More file actions
executable file
·64 lines (55 loc) · 1.23 KB
/
generate-bindings.sh
File metadata and controls
executable file
·64 lines (55 loc) · 1.23 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
#!/usr/bin/env bash
set -euo pipefail
script_dir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
bindings_dir="${script_dir}/rust-bindings"
force=false
commit="${LIBSQL_COMMIT:-libsql-0.9.21}"
remote="${LIBSQL_REMOTE:-https://github.com/tursodatabase/libsql.git}"
local_repo_path=""
while [[ $# -gt 0 ]]; do
case "$1" in
--force)
force=true
shift
;;
--commit)
commit="$2"
shift 2
;;
--remote)
remote="$2"
shift 2
;;
--local)
local_repo_path="$2"
shift 2
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
done
function run_if_force {
if [[ "${force}" == "true" ]];then
"$@"
fi
}
run_if_force rm -rf "${bindings_dir}/libsql"
run_if_force rm -rf "${bindings_dir}/target"
mkdir -p "${bindings_dir}"
if [[ -n "${local_repo_path}" ]]; then
ln -sfn "${local_repo_path}" "${bindings_dir}/libsql"
else
mkdir -p "${bindings_dir}/libsql"
cd "${bindings_dir}/libsql"
git init 2> /dev/null
if ! git config remote.origin.url &> /dev/null;then
git remote add --no-fetch origin "${remote}"
fi
git fetch --quiet origin ${commit} --depth 1
git checkout FETCH_HEAD
cd ../..
fi
cd "${bindings_dir}"
cargo build --lib --release