-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_bindings.sh
44 lines (35 loc) · 1.15 KB
/
generate_bindings.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
#!/bin/sh
# NOTE:: requires libclang-dev installed
# `sudo apt install libclang-dev`
#
# you can see what version of llvm is installed `ls /usr/lib/llvm*`
#
# then you'll need to have the lib linked to the one in use (create a sym link)
# sudo ln -s /usr/lib/llvm-11/lib/libclang.so /usr/lib/libclang.so
echo "--"
echo "preparing..."
echo "--"
# clone the required repositories
git clone --depth 1 https://github.com/tensorflow/tensorflow
git clone --depth 1 https://github.com/crystal-lang/crystal_lib
# build the binding generator
cd crystal_lib
shards check || shards install
test -f "./main" || crystal build src/main.cr
echo "--"
echo "generating bindings..."
echo "--"
# this might require you to have installed bazel
# and have run `./configure` from the `tensorflow/tensorflow` directory
cd ../tensorflow
cp ../bindings/bindings_generator.cr ../src/tensorflow_lite/bindings_generator.cr
../crystal_lib/main "../src/tensorflow_lite/bindings_generator.cr" | grep -vE 'alias(.+)Void$' > "../src/tensorflow_lite/lib_tensorflowlite.cr"
cd ..
crystal tool format
echo "--"
echo "Cleaning up..."
echo "--"
rm -rf ./tensorflow
rm -rf ./crystal_lib
echo "--"
echo "Done!"