-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate.sh
executable file
·48 lines (43 loc) · 1.74 KB
/
generate.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
45
46
47
48
#!/bin/bash
echo "Installing dependencies..."
python3 -m venv env
source env/bin/activate
pip3 install -r requirements.txt
OUT_DIR=./out
if [ ! -d "$OUT_DIR" ]; then
echo "Creating output directory"
mkdir -p $OUT_DIR
fi
echo "Generating protobufs for python..."
PYTHON_OUT_DIR=$OUT_DIR/python
if [ ! -d "$PYTHON_OUT_DIR" ]; then
echo "Creating Python output directory"
mkdir -p $PYTHON_OUT_DIR
fi
protoc -I $PWD --python_out=$PYTHON_OUT_DIR $PWD/client/*.proto
protoc -I $PWD --python_out=$PYTHON_OUT_DIR $PWD/common/*.proto
protoc -I $PWD --python_out=$PYTHON_OUT_DIR $PWD/device/*.proto
protoc -I $PWD --python_out=$PYTHON_OUT_DIR $PWD/payload.proto
echo "Generating protobufs for Javascript..."
JS_OUT_DIR=$OUT_DIR/js
if [ ! -d "$JS_OUT_DIR" ]; then
echo "Creating Javascript output directories"
mkdir -p $JS_OUT_DIR
mkdir $JS_OUT_DIR/client
mkdir $JS_OUT_DIR/common
mkdir $JS_OUT_DIR/device
fi
protoc -I $PWD --js_out=import_style=commonjs,binary:$JS_OUT_DIR $PWD/client/*.proto
protoc -I $PWD --js_out=import_style=commonjs,binary:$JS_OUT_DIR $PWD/common/*.proto
protoc -I $PWD --js_out=import_style=commonjs,binary:$JS_OUT_DIR $PWD/device/*.proto
protoc -I $PWD --js_out=import_style=commonjs,binary:$JS_OUT_DIR $PWD/payload.proto
echo "Generating protobufs for C..."
C_OUT_DIR=$OUT_DIR/c
if [ ! -d "$C_OUT_DIR" ]; then
echo "Creating C output directory"
mkdir -p $C_OUT_DIR
fi
python3 nanopb/generator/nanopb_generator.py -I $PWD $PWD/client/*.proto -D $C_OUT_DIR
python3 nanopb/generator/nanopb_generator.py -I $PWD $PWD/common/*.proto -D $C_OUT_DIR
python3 nanopb/generator/nanopb_generator.py -I $PWD $PWD/device/*.proto -D $C_OUT_DIR
python3 nanopb/generator/nanopb_generator.py -I $PWD $PWD/payload.proto -D $C_OUT_DIR