Skip to content

Commit

Permalink
update xmake.lua: build with xmake swig support
Browse files Browse the repository at this point in the history
  • Loading branch information
Rinkaa committed Sep 27, 2021
1 parent d6d3f18 commit 6e8cdb2
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,33 @@ add_requires("raylib 3.7.0")
add_requires("luajit 2.1.0-beta3", {optional=true})

target("swigraylib_lua")
set_kind("shared")

before_build(function(target)
local raylibDefs = {"-D_DEFAULT_SOURCE -DPLATFORM_DESKTOP -DGRAPHICS_API_OPENGL_33 -DPHYSAC_IMPLEMENTATION"}
if is_plat("windows") then
raylibDefs[#raylibDefs+1] = "-D_WIN32"
elseif is_plat("linux") then
raylibDefs[#raylibDefs+1] = "-D__linux__"
elseif is_plat("macosx") then
raylibDefs[#raylibDefs+1] = "-D__APPLE__"
else
if not (is_plat("windows") or is_plat("linux") or is_plat("macosx")) then
os.raise("This xmake script doesn't support this target platform at the moment...")
end
local swigParams = {"-lua", "-no-old-metatable-bindings"}
for i = 1, #raylibDefs do swigParams[#swigParams+1] = raylibDefs[i] end
swigParams[#swigParams+1] = "raylib.i"
os.runv("swig", swigParams)
cprint("${yellow underline}SwigCmd: swig "..table.concat(swigParams, ' ').." ${clear}")
target:add("cxflags", raylibDefs)
end)
if is_plat("linux") then
add_cxflags("-fPIC")
end

set_kind("shared")
add_rules("swig.c", {moduletype = "lua"})
add_packages("raylib")
add_files("raylib_wrap.c")

-- Choose one of the Lua package:
-- add_packages("lua")
add_packages("luajit")
add_packages("luajit")

local raylibDefs = {"-D_DEFAULT_SOURCE", "-DPLATFORM_DESKTOP", "-DGRAPHICS_API_OPENGL_33", "-DPHYSAC_IMPLEMENTATION"}
if is_plat("windows") then
raylibDefs[#raylibDefs+1] = "-D_WIN32"
elseif is_plat("linux") then
raylibDefs[#raylibDefs+1] = "-D__linux__"
add_cxflags("-fPIC")
elseif is_plat("macosx") then
raylibDefs[#raylibDefs+1] = "-D__APPLE__"
end

local swigParams = {"-no-old-metatable-bindings"}
table.join2(swigParams, raylibDefs)

add_files("raylib.i", {swigflags = swigParams})
add_cxflags(table.unpack(raylibDefs))

1 comment on commit 6e8cdb2

@Rinkaa
Copy link
Owner Author

@Rinkaa Rinkaa commented on 6e8cdb2 Sep 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: Currently fails to compile because of lacking -lraylib etc.

Please sign in to comment.