More explicit warning about versions mismatch.
[py-rsbac] / extra / gen.sh
1 #!/bin/bash
2
3 # This script generate the rsbac_x_y_z.py Python module which contains
4 # all the types defined in RSBAC include file.
5
6 # You need at least GCC-XML 0.7 CVS and codegenerator from the ctypes
7 # project.
8
9 export LC_ALL=C
10
11 # files
12 HEADERS=/path/to/rsbac-admin-1.3.0rc1/main/headers
13 SOURCES=(
14   "${HEADERS}/rsbac/types.h"
15   "${HEADERS}/rsbac/syscalls.h"
16   "${HEADERS}/rsbac/request_groups.h"
17   )
18 TARGET="./rsbac_1_3_0_rc1.py"
19
20 # gccxml
21 GCCXML=/path/to/gccxml
22 export PATH="${GCCXML}:${PATH}"
23
24 # codegen
25 CODEGEN=/path/to/codegen
26 export PYTHONPATH="$CODEGEN"
27 H2XML="${CODEGEN}/scripts/h2xml.py"
28 XML2PY="${CODEGEN}/scripts/xml2py.py"
29
30 TMP=".pyrsbac.$$"
31 python "$H2XML" "${SOURCES[@]}" -I "$HEADERS" -c -o "$TMP"
32 cat > "$TARGET" <<EOF
33 # Automatically generated by $0 on `date`
34
35 EOF
36 python "$XML2PY" "$TMP"|grep -v '^Could not init' >> "$TARGET"
37 rm "$TMP"