forked from ibis-project/ibis-substrait
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen-protos.sh
executable file
·44 lines (31 loc) · 1.17 KB
/
gen-protos.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
#!/usr/bin/env bash
set -eo pipefail
substrait_protos="${1:-${PROTO_DIR}}"
substrait_hash="${2:-${PROTO_HASH}}"
set -u
proto_dir=./proto
extension_dir=./ibis_substrait/extensions
mkdir -p "$proto_dir"
mkdir -p "$extension_dir"
chmod u+rwx "$proto_dir"
chmod u+rwx "$extension_dir"
rm -r "$proto_dir"
rm -r "$extension_dir"
cp -fr "$substrait_protos" "$proto_dir"
cp -fr "$substrait_protos/../extensions" "$extension_dir"
find "$proto_dir" -type d -exec chmod u+rwx {} +
find "$proto_dir" -type f -exec chmod u+rw {} +
find "$extension_dir" -type d -exec chmod u+rwx {} +
find "$extension_dir" -type f -exec chmod u+rw {} +
rm -rf ./ibis_substrait/proto
python proto_prefix.py "$proto_dir"/tmp substrait.ibis "$proto_dir"/substrait
mv "$proto_dir"/substrait substrait.bak
mv "$proto_dir"/tmp/substrait "$proto_dir"
buf generate
protol --in-place --create-package --python-out "./ibis_substrait/proto" buf
rm -rf "$proto_dir"/tmp
rm -rf "$proto_dir"/substrait
mv substrait.bak "$proto_dir"/substrait
# Insert current substrait rev into __init__.py
sed -i '/__substrait_hash__/d' ./ibis_substrait/__init__.py
echo "__substrait_hash__ = \"$substrait_hash\"" >> ./ibis_substrait/__init__.py