Add support for windows
This commit is contained in:
parent
773b1fbc23
commit
e52e213e84
19
compile
19
compile
|
@ -3,7 +3,7 @@ set -e
|
|||
export target_os="${target_os:=$1}"
|
||||
|
||||
if [ "$target_os" = "" ]; then
|
||||
echo "Usage: $0 <linux/openbsd>"
|
||||
echo "Usage: $0 <platform>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -23,5 +23,20 @@ if [ "$target_os" = "openbsd" ]; then
|
|||
exit
|
||||
fi
|
||||
|
||||
printf "Unsupported platform. These platforms are currently available:\n* linux\n* openbsd\n"
|
||||
if [ "$target_os" = "windows" ]; then
|
||||
echo "* Compiling: windows ..."
|
||||
CC="${CC:=gcc}"
|
||||
PYTHON="${PYTHON:=py}" # https://www.python.org/downloads/release/python-344/
|
||||
MINGWPATH="${MINGWPATH:=C:\\mingw32}" # https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/8.1.0/threads-posix/dwarf/
|
||||
SDLPATH="${SDLPATH:=SDL2}" # https://github.com/libsdl-org/SDL/releases
|
||||
LUAPATH="${LUAPATH:=lua5.3/src}" # https://www.lua.org/ftp/lua-5.3.6.tar.gz
|
||||
"$PYTHON" lua_translate
|
||||
"$CC" -std=gnu89 src/main.c -g -L"$MINGWPATH\\lib" -w -Wl,-subsystem,windows -lmingw32 -L"$LUAPATH" -I"$LUAPATH" -I"$SDLPATH/include" -L"$SDLPATH/lib" -lSDL2main -lSDL2 -llua53 -lm -o engine.exe -O3 -Werror -Wall $CFLAGS
|
||||
exit
|
||||
fi
|
||||
|
||||
echo "Unsupported platform. These platforms are currently available:"
|
||||
echo "* linux"
|
||||
echo "* openbsd"
|
||||
echo "* windows"
|
||||
exit 1
|
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
import toml
|
||||
import sys
|
||||
import os
|
||||
import toml
|
||||
typesIn = {
|
||||
"__unknown": "lua_touserdata",
|
||||
"char": "luaL_checkinteger",
|
||||
|
@ -23,19 +24,34 @@ statics = toml.loads(open("src/values/statics.toml").read())
|
|||
functions = toml.loads(open("src/values/functions.toml").read())
|
||||
ofile = open("src/lua.c","w")
|
||||
|
||||
supportedTarget = False
|
||||
if os.environ["target_os"] == "linux":
|
||||
ofile.write('''\
|
||||
#include <lua5.3/lua.h>
|
||||
#include <lua5.3/lualib.h>
|
||||
#include <lua5.3/lauxlib.h>
|
||||
''')
|
||||
#include <lua5.3/lua.h>
|
||||
#include <lua5.3/lualib.h>
|
||||
#include <lua5.3/lauxlib.h>
|
||||
''')
|
||||
supportedTarget = True
|
||||
|
||||
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>
|
||||
''')
|
||||
#include <lua-5.3/lua.h>
|
||||
#include <lua-5.3/lualib.h>
|
||||
#include <lua-5.3/lauxlib.h>
|
||||
''')
|
||||
supportedTarget = True
|
||||
|
||||
if os.environ["target_os"] == "windows":
|
||||
ofile.write('''\
|
||||
#include <lua.h>
|
||||
#include <lualib.h>
|
||||
#include <lauxlib.h>
|
||||
''')
|
||||
supportedTarget = True
|
||||
|
||||
if supportedTarget == False:
|
||||
print("Platform " +os.environ["target_os"]+ " unsupported by lua_translate.")
|
||||
sys.exit(1)
|
||||
|
||||
ofile.write('''lua_State * engine_lua_state;
|
||||
#include "lua_manual.c"
|
||||
|
@ -66,7 +82,7 @@ for func in functions:
|
|||
if not outtype in typesOut:
|
||||
pushfunc = typesOut["__unknown"]
|
||||
else:
|
||||
pushfunc = typesOut[arg]
|
||||
pushfunc = typesOut[outtype]
|
||||
|
||||
ofile.write('\t' +outtype+ ' outvar = ' +func + argstring + ";")
|
||||
ofile.write("\n\t" +pushfunc+ '(L,outvar);')
|
||||
|
|
Loading…
Reference in New Issue