-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_libs.sh
executable file
·105 lines (85 loc) · 1.52 KB
/
create_libs.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/bin/bash
#
# Use this script to convert *.ksy to python, C#,...
#
set -eu
if ! type ksc > /dev/null 2>&1
then
if [ -e ./kaitai-struct-compiler-0.8/bin/kaitai-struct-compiler ]
then
KSC=./kaitai-struct-compiler-0.8/bin/kaitai-struct-compiler
else
echo "ksc not found, install kaitai-struct first"
exit 1
fi
else
KSC=ksc
fi
graphviz() {
echo "graphviz..."
mkdir -p graphviz
rm -rf graphviz/*
for ksy in kaitai-struct/*.ksy
do
echo $ksy
$KSC $ksy \
--target graphviz \
--import-path kaitai-struct/ \
--outdir graphviz
done
if type dot > /dev/null 2>&1
then
for dot in graphviz/*.dot
do
echo $dot
dot -Tpng $dot -o ${dot%%.dot}.png
done
else
echo "dot (graphviz) not found, skipping .png generation"
fi
}
csharp() {
echo "csharp..."
mkdir -p csharp/ctr
rm -rf csharp/ctr/*
for ksy in kaitai-struct/*.ksy
do
echo $ksy
$KSC $ksy \
--target csharp \
--import-path kaitai-struct/ \
--outdir csharp/ctr \
--dotnet-namespace ctr
done
}
python() {
echo "python..."
mkdir -p python/ctr
rm -rf python/ctr/*
touch python/ctr/__init__.py
for ksy in kaitai-struct/*.ksy
do
echo $ksy
$KSC $ksy \
--target python \
--import-path kaitai-struct/ \
--outdir python/ctr \
--python-package ctr
done
}
# TODO: perl
# TODO: java
# TODO: go
# TODO: cpp_stl
# TODO: php
# TODO: lua
# TODO: ruby
# TODO: javascript
if [ $# -eq 1 ]
then
$1
else
graphviz
python
csharp
fi