Formatting, lua_translate target_os

This commit is contained in:
Fierelier 2023-08-10 20:01:05 +02:00
parent e73a462c91
commit 40b8cab88e
2 changed files with 22 additions and 17 deletions

View File

@ -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")
if os.environ["target_os"] == "linux":
ofile.write('''\
#include <lua5.3/lua.h>
#include <lua5.3/lualib.h>
#include <lua5.3/lauxlib.h>
lua_State * engine_lua_state;
''')
if os.environ["target_os"] == "openbsd":
ofile.write('''\
#include <lua-5.3/lua.h>
#include <lua-5.3/lualib.h>
#include <lua-5.3/lauxlib.h>
''')
ofile.write('''lua_State * engine_lua_state;
#include "lua_manual.c"
''')

18
run Normal file → Executable file
View File

@ -1,24 +1,19 @@
#!/usr/bin/env bash
set -e
if [ $# -ne 1 ]; then
echo "Usage: $0 <supported_os>"
if [ "$#" -ne "1" ]; then
echo "Usage: $0 <linux/openbsd>"
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