adding functional premake

This commit is contained in:
NishiOwO 2025-04-10 04:59:48 +09:00
parent 028ce17799
commit 6a557a0cca
No known key found for this signature in database
GPG Key ID: 27EF69B208EB9343

View File

@ -1,37 +1,63 @@
backends = {
glx = {"GLX", {"X11"}},
wgl = {"WGL", {"gdi32"}},
glfw = {"GLFW", {"glfw"}}
opengl = {
name = "OpenGL",
default = "glfw",
unix = {"GL", "GLU"},
windows = {"opengl32", "glu32"},
backends = {
glx = {"GLX", {"X11"}},
wgl = {"WGL", {"gdi32"}},
glfw = {"GLFW", {"glfw"}}
}
}
}
plt = {}
for k,v in pairs(backends) do
table.insert(plt, "Native-" .. v[1])
if not(v[1] == "GLX") then
table.insert(plt, "Win32-" .. v[1])
table.insert(plt, "Win64-" .. v[1])
end
end
workspace("NishBox")
configurations({
"Debug",
"Release"
})
platforms(plt)
defaultplatform("Native-GLX")
platforms({
"Native",
"Win32",
"Win64"
})
defaultplatform("Native")
filter("platforms:Win32-*")
filter("platforms:Win32")
system("windows")
architecture("x86")
gccprefix("i686-w64-mingw32-")
filter("platforms:Win64-*")
filter("platforms:Win64")
system("windows")
architecture("x86_64")
gccprefix("x86_64-w64-mingw32-")
l = {}
for k,v in pairs(backends) do
allowed = {}
for k2,v2 in pairs(v["backends"]) do
table.insert(allowed, {k2, v2[1]})
end
newoption({
trigger = k,
value = "API",
description = "Choose a backend for " .. v["name"],
allowed = allowed,
default = v["default"]
})
table.insert(l, {k, v["name"]})
end
newoption({
trigger = "backend",
value = "API",
description = "Choose a backend for rendering",
allowed = l,
default = "opengl"
})
newaction({
trigger = "clean",
description = "Clean the files",
@ -55,7 +81,7 @@ function default_stuffs()
defines({
"THREAD_POSIX"
})
filter("platforms:Native-*")
filter("platforms:Native")
includedirs({
"/usr/local/include",
"/usr/X11R*/include"
@ -65,7 +91,7 @@ function default_stuffs()
"/usr/X11R*/lib"
})
filter({
"platforms:Native-*",
"platforms:Native",
"system:bsd"
})
includedirs({
@ -76,11 +102,16 @@ function default_stuffs()
})
for k,v in pairs(backends) do
filter("platforms:*-" .. k)
defines({
"DRV_OPENGL",
"USE_" .. string.upper(k)
for k2,v2 in pairs(v["backends"]) do
filter({
"options:backend=" .. k,
"options:" .. k .. "=" .. k2
})
defines({
"DRV_" .. string.upper(k),
"USE_" .. string.upper(k2)
})
end
end
filter({})
@ -108,27 +139,37 @@ project("NishBox")
"ode"
})
default_stuffs()
for k,v in pairs(backends) do
filter("platforms:*-" .. k)
links(v[2])
end
filter("toolset:gcc or toolset:clang")
links({
"stdc++"
})
for k,v in pairs(backends) do
for k2,v2 in pairs(v["backends"]) do
filter({
"options:backend=" .. k,
"options:" .. k .. "=" .. k2,
"system:windows"
})
links(v.windows)
links(v2[2])
filter({
"options:backend=" .. k,
"options:" .. k .. "=" .. k2,
"system:not windows"
})
links(v.unix)
links(v2[2])
end
end
filter("system:windows")
files({
"src/*.rc"
})
links({
"opengl32",
"glu32",
"ws2_32"
})
filter("system:not windows")
links({
"GL",
"GLU",
"pthread"
})
filter("configurations:Debug")
@ -175,9 +216,14 @@ project("NishEngine")
"engine/thread/posix/ne_thread.c"
})
for k,v in pairs(backends) do
filter("platforms:*-" .. k)
files({
"engine/graphic/opengl/" .. k .. "/ne_draw.c",
"engine/graphic/opengl/*.c"
for k2,v2 in pairs(v["backends"]) do
filter({
"options:backend=" .. k,
"options:" .. k .. "=" .. k2
})
files({
"engine/graphic/" .. k .. "/*.c",
"engine/graphic/" .. k .. "/" .. k2 .. "/*.c"
})
end
end