Improve building and conditional declarations.
raylib-lua now manages properly `if defined` declarations.
This commit is contained in:
parent
f501ca9512
commit
707d2309b1
@ -32,10 +32,13 @@ local cflags = os.getenv "CFLAGS" or "-O2 -s"
|
||||
local ldflags = os.getenv "LDFLAGS" or "-O2 -s -lm"
|
||||
|
||||
local modules = "raymath rlgl easings gestures physac raygui"
|
||||
local graphics = os.getenv "GRAPHICS" or "GRAPHICS_API_OPENGL_33"
|
||||
|
||||
cflags = cflags .. " -Iluajit/src -Iraygui/src -Iraylib/src"
|
||||
ldflags = ldflags .. " luajit/src/libluajit.a raylib/src/libraylib.a luajit/src/libluajit.a"
|
||||
|
||||
cflags = cflags .. " -D" .. graphics
|
||||
|
||||
local exe_ldflags = ""
|
||||
|
||||
if los.type() == "linux" then
|
||||
@ -102,7 +105,7 @@ local raylua_src = {
|
||||
}, true)
|
||||
end)
|
||||
}
|
||||
local raylua_obj = c.compile(raylua_src, cflags, "raylua", cc)
|
||||
local raylua_obj = c.compile(raylua_src, cflags .. " -D" .. graphics, "raylua", cc)
|
||||
|
||||
local libraylua = c.lib("libraylua.a", raylua_obj, "raylua", ar)
|
||||
|
||||
|
@ -23,7 +23,7 @@ local vars = saphire.map({
|
||||
{ "RAYLIB_LIB_NAME", "raylib" },
|
||||
{ "RAYLIB_RES_FILE", "./raylib.dll.rc.data" },
|
||||
{ "PLATFORM", "PLATFORM_DESKTOP" },
|
||||
{ "GRAPHICS", "GRAPHICS_API_OPENGL_43" },
|
||||
{ "GRAPHICS", "GRAPHICS_API_OPENGL_33" },
|
||||
{ "USE_EXTERNAL_GLFW", "FALSE" },
|
||||
{ "USE_WAYLAND_DISPLAY", "FALSE" }
|
||||
}, function (v)
|
||||
|
6
makefile
6
makefile
@ -6,14 +6,16 @@ LUA ?= luajit/src/luajit
|
||||
|
||||
WINDRES ?= windres
|
||||
|
||||
CFLAGS += -Iluajit/src -Iraylib/src -Iraygui/src -DSUPPORT_COMPUTE_SHADERS
|
||||
CFLAGS += -Iluajit/src -Iraylib/src -Iraygui/src
|
||||
LDFLAGS += luajit/src/libluajit.a raylib/src/libraylib.a
|
||||
|
||||
MODULES := raymath rlgl easings gestures physac raygui
|
||||
|
||||
# raylib settings
|
||||
PLATFORM ?= PLATFORM_DESKTOP
|
||||
GRAPHICS ?= GRAPHICS_API_OPENGL_43
|
||||
GRAPHICS ?= GRAPHICS_API_OPENGL_33
|
||||
|
||||
CFLAGS += -D$(GRAPHICS)
|
||||
|
||||
USE_WAYLAND_DISPLAY ?= FALSE
|
||||
USE_EXTERNAL_GLFW ?= FALSE
|
||||
|
@ -31,11 +31,15 @@ local functions = {}
|
||||
local proto = {}
|
||||
|
||||
local counter = 0
|
||||
local file = io.open(arg[1], "wb")
|
||||
local modules = { "api" }
|
||||
local funcname
|
||||
|
||||
local custom_support = {
|
||||
["rlgl"] = function (line)
|
||||
return line:gsub("([%s*]+)(rl%w+)", function (pre, part)
|
||||
functions[#functions + 1] = part
|
||||
funcname = part
|
||||
counter = counter + 1
|
||||
|
||||
if counter == 2 then
|
||||
@ -47,16 +51,29 @@ local custom_support = {
|
||||
end
|
||||
}
|
||||
|
||||
local file = io.open(arg[1], "wb")
|
||||
local modules = { "api" }
|
||||
|
||||
for i=2,#arg do
|
||||
modules[i] = arg[i]
|
||||
end
|
||||
|
||||
file:write [[
|
||||
struct raylua_bind_entry {
|
||||
const char *name;
|
||||
const char *proto;
|
||||
void *ptr;
|
||||
};
|
||||
|
||||
struct raylua_bind_entry raylua_entries[] = {
|
||||
]]
|
||||
|
||||
for _,modname in ipairs(modules) do
|
||||
for line in io.lines("tools/" .. modname .. ".h") do
|
||||
if line:sub(0, 2) ~= "//" then
|
||||
if line:sub(1, 2) ~= "//" then
|
||||
if line:sub(1, 1) == "#" then
|
||||
file:write(" " .. line .. "\n")
|
||||
else
|
||||
counter = 0
|
||||
funcname = nil
|
||||
|
||||
if custom_support[modname] then
|
||||
line = custom_support[modname](line)
|
||||
end
|
||||
@ -86,9 +103,10 @@ for _,modname in ipairs(modules) do
|
||||
end
|
||||
|
||||
functions[#functions + 1] = part
|
||||
funcname = part
|
||||
counter = counter + 1
|
||||
|
||||
if count == 2 then
|
||||
if counter == 2 then
|
||||
print("WARN: Multiple matches for: " .. line)
|
||||
end
|
||||
|
||||
@ -100,6 +118,13 @@ for _,modname in ipairs(modules) do
|
||||
line = line:gsub("(%w)%s+([(),*.])", function (a, b) return a .. b end)
|
||||
|
||||
proto[#proto + 1] = line
|
||||
|
||||
if funcname and line then
|
||||
file:write(string.format(' { "%s", "%s", &%s },\n', funcname, line, funcname))
|
||||
elseif counter == 0 then
|
||||
print("WARN: Invalid entry", funcname, line)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -107,22 +132,9 @@ end
|
||||
assert(#proto == #functions, "Mismatching proto and function count : " ..
|
||||
#proto .. " ~= " .. #functions)
|
||||
|
||||
file:write [[
|
||||
struct raylua_bind_entry {
|
||||
const char *name;
|
||||
const char *proto;
|
||||
void *ptr;
|
||||
};
|
||||
print(string.format("Bound %d functions.", #proto))
|
||||
|
||||
struct raylua_bind_entry raylua_entries[] = {
|
||||
]]
|
||||
|
||||
for i=1,#proto do
|
||||
local name, proto = functions[i], proto[i]
|
||||
file:write(string.format('{ "%s", "%s", &%s },\n', name, proto, name))
|
||||
end
|
||||
|
||||
file:write '{ NULL, NULL, NULL },\n'
|
||||
file:write ' { NULL, NULL, NULL },\n'
|
||||
file:write "};\n"
|
||||
|
||||
file:close()
|
||||
|
@ -27,6 +27,10 @@ void rlEnableVertexBufferElement(unsigned int id)
|
||||
void rlDisableVertexBufferElement(void)
|
||||
void rlEnableVertexAttribute(unsigned int index)
|
||||
void rlDisableVertexAttribute(unsigned int index)
|
||||
#if defined(GRAPHICS_API_OPENGL_11)
|
||||
void rlEnableStatePointer(int vertexAttribType, void *buffer)
|
||||
void rlDisableStatePointer(int vertexAttribType)
|
||||
#endif
|
||||
void rlActiveTextureSlot(int slot)
|
||||
void rlEnableTexture(unsigned int id)
|
||||
void rlDisableTexture(void)
|
||||
@ -116,6 +120,7 @@ void rlSetUniform(int locIndex, const void *value, int uniformType, int count)
|
||||
void rlSetUniformMatrix(int locIndex, Matrix mat)
|
||||
void rlSetUniformSampler(int locIndex, unsigned int textureId)
|
||||
void rlSetShader(unsigned int id, int *locs)
|
||||
#if defined(GRAPHICS_API_OPENGL_43)
|
||||
unsigned int rlLoadComputeShaderProgram(int shaderId)
|
||||
void rlComputeShaderDispatch(unsigned int groupX, unsigned int groupY, unsigned int groupZ)
|
||||
unsigned int rlLoadShaderBuffer(unsigned long long size, const void *data, int usageHint)
|
||||
@ -126,6 +131,7 @@ void rlReadShaderBufferElements(unsigned int id, void *dest, unsigned long long
|
||||
void rlBindShaderBuffer(unsigned int id, unsigned int index)
|
||||
void rlCopyBuffersElements(unsigned int destId, unsigned int srcId, unsigned long long destOffset, unsigned long long srcOffset, unsigned long long count)
|
||||
void rlBindImageTexture(unsigned int id, unsigned int index, unsigned int format, int readonly)
|
||||
#endif
|
||||
Matrix rlGetMatrixModelview(void)
|
||||
Matrix rlGetMatrixProjection(void)
|
||||
Matrix rlGetMatrixTransform(void)
|
||||
|
Loading…
Reference in New Issue
Block a user