Fix build kinks on windows

This commit is contained in:
Sky Johnson 2025-01-21 10:59:32 -06:00
parent e2342406fd
commit e4fd777d6a
3 changed files with 125 additions and 1 deletions

22
.gitignore vendored Normal file
View File

@ -0,0 +1,22 @@
# Ignore build outputs
/build/
# Ignore xmake temporary files
.xmake/
# Ignore LuaJIT generated files (if any)
luajit/src/*.o
luajit/src/*.obj
luajit/src/*.exe
luajit/src/*.so
luajit/src/*.dll
luajit/src/*.dylib
# Ignore log files
*.log
# Ignore editor/IDE-specific files
.vscode/
.idea/
*.swp
.DS_Store

View File

@ -1,3 +1,3 @@
# LuaJIT
Need to be able to build LuaJIT cross-platform for the Go wrapper.
A way to build static and dynamic libraries for LuaJIT. Uses xmake and gcc to build and copy over linkable headers/libraries.

102
xmake.lua Normal file
View File

@ -0,0 +1,102 @@
-- Project setup
set_project("LuaJIT")
set_version("2.1.0")
set_config("buildir", "build")
target("luajit")
set_kind("phony")
on_build(function (target)
import("core.tool.toolchain")
import("lib.detect.find_tool")
import("core.project.config")
-- Change to LuaJIT src dir first
os.cd("luajit/src")
-- Get number of CPU cores for parallel build
local cpu_num = os.cpuinfo().ncpu
-- Use gcc
os.setenv("CC", "gcc")
-- Use make/mingw32-make based on platform
if is_plat("windows") then
local make = find_tool("mingw32-make")
if not make then
raise("mingw32-make not found!")
end
-- Build with CMD shell
os.execv(make.program, {"-j" .. cpu_num, "SHELL=cmd.exe"})
else
local make = find_tool("make")
if not make then
raise("make not found!")
end
os.exec(string.format("%s -j%d", make.program, cpu_num))
end
-- Copy build outputs to /build
os.mkdir("../../build")
if is_plat("windows") then
-- Dynamic libraries and executable
os.cp("*.dll", "../../build")
os.cp("luajit.exe", "../../build")
-- Static libraries
os.cp("*.lib", "../../build")
os.cp("*.exp", "../../build")
os.cp("*.a", "../../build")
-- Headers for embedding
os.cp("lua.h", "../../build")
os.cp("luaconf.h", "../../build")
os.cp("lualib.h", "../../build")
os.cp("luajit.h", "../../build")
os.cp("lauxlib.h", "../../build")
else
os.cp("libluajit.so", "../../build", {force = true})
os.cp("libluajit.a", "../../build")
os.cp("luajit", "../../build")
-- Headers for embedding
os.cp("lua.h", "../../build")
os.cp("luaconf.h", "../../build")
os.cp("lualib.h", "../../build")
os.cp("luajit.h", "../../build")
os.cp("lauxlib.h", "../../build")
end
os.cd("../../")
end)
on_clean(function (target)
-- Clean build directory
os.rm("build")
-- Clean generated files in LuaJIT src directory
os.cd("luajit/src")
os.rm("*.o")
os.rm("*.obj")
os.rm("*.lib")
os.rm("*.exp")
os.rm("*.dll")
os.rm("*.exe")
os.rm("*.manifest")
os.rm("*.pdb")
os.rm("*.ilk")
os.rm("*.a")
os.rm("host/*.o")
os.rm("host/*.obj")
os.rm("host/minilua.exe")
os.rm("host/buildvm.exe")
os.rm("lj_vm.S")
os.rm("lj_bcdef.h")
os.rm("lj_ffdef.h")
os.rm("lj_libdef.h")
os.rm("lj_recdef.h")
os.rm("lj_folddef.h")
os.rm("host/buildvm_arch.h")
os.rm("luajit.h")
os.rm("luajit_relver.txt")
os.rm("jit/vmdef.lua")
os.cd("../../")
end)