diff options
Diffstat (limited to 'plugins/MirLua/Modules/ffi/src/test_includes.sh')
-rw-r--r-- | plugins/MirLua/Modules/ffi/src/test_includes.sh | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/plugins/MirLua/Modules/ffi/src/test_includes.sh b/plugins/MirLua/Modules/ffi/src/test_includes.sh new file mode 100644 index 0000000000..c0b9cfa1f9 --- /dev/null +++ b/plugins/MirLua/Modules/ffi/src/test_includes.sh @@ -0,0 +1,25 @@ +#!/bin/sh
+make test || exit
+rm -rf test_includes
+mkdir -p test_includes
+for f in /usr/include/*.h
+do
+ gcc -E -c "${f}" > tmp 2>/dev/null
+ if [ $? == 0 ]
+ then
+ echo "${f}";
+ lua -e '
+ local str = io.read("*a")
+ -- remove preprocessor commands eg line directives
+ str = str:gsub("#[^\n]*", "")
+ -- remove inline function definitions and declarations
+ str = str:gsub("extern%s+__inline__", "static")
+ str = str:gsub("extern%s+__inline", "static")
+ str = str:gsub("static[^;(]+__attribute__%s*%b()", "static ")
+ str = str:gsub("static[^;(]+__attribute__%s*%b()", "static ")
+ str = str:gsub("static[^;(]+%b()%s*%b{}", "")
+ str = str:gsub("static[^;(]+%b()%s*;", "")
+ io.write(str)' > "test_includes/`basename $f`" < tmp
+ lua -e 'ffi = require("ffi"); ffi.cdef(io.read("*a"))' < "test_includes/`basename $f`"
+ fi
+done
|