revert system.c

do not generate the exported symbols with the script
This commit is contained in:
takase1121
2021-11-17 08:58:44 +08:00
parent 68eb6810d9
commit b42f48782b
3 changed files with 53 additions and 237 deletions
+1 -69
View File
@@ -42,10 +42,6 @@ import_sym() {
grep '^LUA' | grep -v "$IGNORE_SYM" | sed -e "s/$sym_regex/\tIMPORT_SYMBOL(\3, \2, \4);/"
}
export_sym() {
grep '^LUA' | grep -v "$IGNORE_SYM" | sed -e "s/$sym_regex/\t\tEXPORT_SYMBOL(\3),/"
}
decl() {
echo "/** $(basename "$1") **/"
echo
@@ -65,11 +61,6 @@ decl_import() {
uncomment $1 | onelineize | import_sym
}
decl_export() {
uncomment $1 | onelineize | export_sym
}
generate_header() {
local LUA_PATH="$1"
echo "#ifndef LITE_XL_PLUGIN_API"
@@ -113,58 +104,14 @@ generate_header() {
echo "#endif"
}
generate_api_require() {
local LUA_PATH="$1"
echo "#ifndef API_REQUIRE_H"
echo "#define API_REQUIRE_H"
echo "/**"
echo "This file contains the function api_require that"
echo "returns a function pointer with it's corresponding name."
echo
echo "This file is automatically generated. DO NOT MODIFY."
echo "**/"
echo
echo
echo "#include <string.h>"
echo "#include <stddef.h>"
echo '#include "lua.h"'
echo '#include "lauxlib.h"'
echo
echo "typedef struct fnptr_s {"
echo -e "\tconst char* name;"
echo -e "\tvoid *addr;"
echo "} fnptr_t;"
echo
echo "#define EXPORT_SYMBOL(SYM) { #SYM, (void*)(SYM) }"
echo "static void *api_require(const char *symbol) {"
echo -e "\tstatic fnptr_t nodes[] = {"
decl_export "$LUA_PATH/lua.h"
decl_export "$LUA_PATH/lauxlib.h"
echo -e "\t};"
echo -e "\tfor (int i = 0; i < sizeof(nodes) / sizeof(fnptr_t); i++)"
echo -e "\t\tif (strcmp(nodes[i].name, symbol) == 0)"
echo -e "\t\t\treturn nodes[i].addr;"
echo -e "\tfprintf(stderr, \"warning: %s cannot be exported.\", symbol);"
echo -e "\treturn NULL;"
echo "}"
echo "#endif"
}
show_help() {
echo -e "Usage: $0 <OPTIONS> prefix"
echo
echo -e "Available options:"
echo
echo -e "-a\t--api-header\tGenerate lite_xl_plugin_api.h"
echo -e "-b\t--api-require\tGenerate api_require.h"
echo -e "-p\t--prefix\tSet prefix (where to find lua.h and lauxlib.h)"
}
main() {
local header=0
local require=0
local prefix=""
for i in "$@"; do
@@ -173,14 +120,6 @@ main() {
show_help
exit 0
;;
-a|--api-header)
header=1
shift
;;
-b|--api-require)
require=1
shift
;;
-p|--prefix)
prefix="$2"
shift
@@ -191,14 +130,7 @@ main() {
esac
done
if [[ "$header" -eq 1 ]]; then
generate_header "$prefix"
elif [[ "$require" -eq 1 ]]; then
generate_api_require "$prefix"
else
show_help
exit 1
fi
generate_header "$prefix"
}
main "$@"