-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
*_wrap.c | ||
build/ | ||
.xmake/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,9 +18,27 @@ | |
|
||
### Lua ### | ||
|
||
> Example build: | ||
```sh | ||
# This example build script requires `xmake` and `swig` installed. | ||
# `xmake.lua` in this repo is used to build the Lua `.so` module. Should work on Windows as well to build a `.dll`. | ||
# You can use Lua 5.1~5.4 too, but you need to make changes in the `xmake.lua` accordingly. | ||
xrepo install "luajit 2.1.0-beta3" && xmake build "swigraylib_lua" | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
Rinkaa
Author
Member
|
||
``` | ||
|
||
> Print raylib version in the terminal: | ||
```sh | ||
# Start luajit to test. You should change path of the output library accordingly. | ||
luajit -i -e "package.cpath=package.cpath..';./build/linux/x86_64/release/libswig?_lua.so'" | ||
> raylib = require "raylib" | ||
> print(raylib.RAYLIB_VERSION) | ||
3.7 | ||
``` | ||
|
||
> Basic window in Lua: | ||
```lua | ||
-- Original version in C: https://github.com/raysan5/raylib/blob/master/examples/core/core_basic_window.c, by Ramon Santamaria (@raysan5) | ||
local raylib = require "raylib" | ||
|
||
local screenWidth, screenHeight = 800, 450 | ||
raylib.InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window") | ||
raylib.SetTargetFPS(60) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
add_rules("mode.release", "mode.debug") | ||
set_languages("c99") | ||
add_requires("raylib 3.7.0") | ||
|
||
-- Choose one of the Lua versions: | ||
-- add_requires("lua 5.3", {optional=true}) | ||
-- add_requires("lua 5.4, {optional=true}") | ||
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 | ||
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 | ||
add_packages("raylib") | ||
add_files("raylib_wrap.c") | ||
|
||
-- Choose one of the Lua package: | ||
-- add_packages("lua") | ||
add_packages("luajit") |
1 comment
on commit d6d3f18
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The next version of xmake will support swig/lua. see xmake-io/xmake#1622 (comment)
不需要xrepo,直接执行 xmake 就能自动装包