| 1 | #!/bin/sh |
| 2 | make || exit |
| 3 | rm -rf test_includes |
| 4 | mkdir -p test_includes |
| 5 | for f in /usr/include/*.h |
| 6 | do |
| 7 | gcc -E -c "${f}" > tmp 2>/dev/null |
| 8 | if [ $? == 0 ] |
| 9 | then |
| 10 | echo "${f}"; |
| 11 | lua -e ' |
| 12 | local str = io.read("*a") |
| 13 | -- remove preprocessor commands eg line directives |
| 14 | str = str:gsub("#[^\n]*", "") |
| 15 | -- remove inline function definitions and declarations |
| 16 | str = str:gsub("extern%s+__inline__", "static") |
| 17 | str = str:gsub("extern%s+__inline", "static") |
| 18 | str = str:gsub("static[^;(]+__attribute__%s*%b()", "static ") |
| 19 | str = str:gsub("static[^;(]+__attribute__%s*%b()", "static ") |
| 20 | str = str:gsub("static[^;(]+%b()%s*%b{}", "") |
| 21 | str = str:gsub("static[^;(]+%b()%s*;", "") |
| 22 | io.write(str)' > "test_includes/`basename $f`" < tmp |
| 23 | lua -e 'ffi = require("ffi"); ffi.cdef(io.read("*a"))' < "test_includes/`basename $f`" |
| 24 | fi |
| 25 | done |