forked from ambrop72/badvpn
-
Notifications
You must be signed in to change notification settings - Fork 3
/
generate_files
executable file
·51 lines (42 loc) · 1.29 KB
/
generate_files
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
#!/bin/bash
set -e
PHP_CMD=( php )
FLEX_CMD=( flex )
BISON_CMD=( bison )
OUT_DIR="generated/"
function bproto() {
local input="$1"
local name="$2"
"${PHP_CMD[@]}" bproto_generator/bproto.php --input-file "${input}" --output-dir "${OUT_DIR}" --name "bproto_${name}"
}
function do_flex() {
local input="$1"
local name="$2"
"${FLEX_CMD[@]}" -o "${OUT_DIR}/flex_${name}.c" --header-file="${OUT_DIR}/flex_${name}.h" "${input}"
"${PHP_CMD[@]}" fix_flex.php "${OUT_DIR}/flex_${name}.c"
"${PHP_CMD[@]}" fix_flex.php "${OUT_DIR}/flex_${name}.h"
}
function do_bison() {
local input="$1"
local name="$2"
"${BISON_CMD[@]}" -d -o "${OUT_DIR}/bison_${name}.c" "${input}"
}
function do_lemon() {
local input="$1"
local name=$(basename "${input}")
(
cd generated &&
rm -f "${name}" &&
cp ../"${input}" "${name}" &&
../lemon/lemon "${name}"
)
}
mkdir -p generated
bproto tests/bproto_test.bproto bproto_test
bproto protocol/msgproto.bproto msgproto
bproto protocol/addr.bproto addr
do_flex predicate/BPredicate.l BPredicate
do_bison predicate/BPredicate.y BPredicate
"${PHP_CMD[@]}" blog_generator/blog.php --input-file blog_channels.txt --output-dir "${OUT_DIR}"
do_lemon ncd/NCDConfigParser_parse.y
do_lemon ncd/NCDValParser_parse.y