diff --git a/lua_translate b/lua_translate index b16ab97..c9ccb38 100755 --- a/lua_translate +++ b/lua_translate @@ -1,5 +1,6 @@ #!/usr/bin/env python3 import toml +import os typesIn = { "__unknown": "lua_touserdata", "char": "luaL_checkinteger", @@ -22,11 +23,21 @@ statics = toml.loads(open("src/values/statics.toml").read()) functions = toml.loads(open("src/values/functions.toml").read()) ofile = open("src/lua.c","w") -ofile.write('''\ -#include -#include -#include -lua_State * engine_lua_state; +if os.environ["target_os"] == "linux": + ofile.write('''\ + #include + #include + #include + ''') + +if os.environ["target_os"] == "openbsd": + ofile.write('''\ + #include + #include + #include + ''') + +ofile.write('''lua_State * engine_lua_state; #include "lua_manual.c" ''') diff --git a/run b/run old mode 100644 new mode 100755 index e36a811..f879612 --- a/run +++ b/run @@ -1,24 +1,19 @@ #!/usr/bin/env bash set -e -if [ $# -ne 1 ]; then - echo "Usage: $0 " +if [ "$#" -ne "1" ]; then + echo "Usage: $0 " exit 1 fi - -target_os=$(echo "$1") - -printf "$target_os\n" - +export target_os="$1" case "$target_os" in linux) - echo "compiling linux" + echo "* Compiling: linux ..." ./lua_translate gcc -std=gnu89 src/main.c -g -lSDL2 -llua5.3 -lm -o engine -O3 -Werror -Wall ;; openbsd) - echo "compiling openbsd" - sed -i 's/lua5\.3/lua-5.3/g' lua_translate + echo "* Compiling: openbsd ..." ./lua_translate egcc -std=gnu89 src/main.c -g -lSDL2 -llua5.3 -lm -o engine -O3 -Werror -Wall -I /usr/local/include ;; @@ -28,6 +23,5 @@ case "$target_os" in ;; esac -printf "\n\tengine is running" - +echo "Running engine ..." exec ./engine