fix windows related issues
cross compiling for windows
CC=x86_64-w64-mingw32-gcc luastatic main.lua /usr/x86_64-w64-mingw32/lib/liblua5.2.a -I/usr/x86_64-w64-mingw32/include/lua5.2/
cross compiling for windows is good but creating a cross platform code will be more convenient for end users.
I have created a variable is_windows which check wheter this script is running on windows or not. Most of the windows user use mingw so i used gcc instead of cc.
-- The boolean check for building on windows platform
local is_windows = _G.package.config:sub(1, 1) == "\\"
-- The C compiler used to compile and link the generated C source file.
local CC = os.getenv("CC") or (is_windows and "gcc" or "cc")
uname is not available in windows which causes this error.
'uname' is not recognized as an internal or external command,
operable program or batch file.
to solve this error I used this code.
local UNAME = "Unknown"
if is_windows then
UNAME = "Windows"
else
UNAME = (shellout("uname -s") or "Unknown"):match("%a+") or "Unknown"
end
also we cannot check a command by /dev/null in windows. so I just replaced previous code with this.
if not execute(CC .. " --version" .. (is_windows and "" or " 1>/dev/null 2>/dev/null")) then
io.stderr:write("C compiler not found.\n")
os.exit(1)
end
will these fixes be merged into trunk?
@aceyin I have created a PR #42 with support for windows. Meanwhile you can use luastatic from my fork lua-batteries/luastatic.