summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/bgfx/scripts/genie.lua
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/bgfx/scripts/genie.lua')
-rw-r--r--3rdparty/bgfx/scripts/genie.lua240
1 files changed, 178 insertions, 62 deletions
diff --git a/3rdparty/bgfx/scripts/genie.lua b/3rdparty/bgfx/scripts/genie.lua
index 05bc713595a..d3f4047cd93 100644
--- a/3rdparty/bgfx/scripts/genie.lua
+++ b/3rdparty/bgfx/scripts/genie.lua
@@ -1,8 +1,10 @@
--
--- Copyright 2010-2018 Branimir Karadzic. All rights reserved.
--- License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
+-- Copyright 2010-2022 Branimir Karadzic. All rights reserved.
+-- License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
--
+MODULE_DIR = path.getabsolute("../")
+
newoption {
trigger = "with-amalgamated",
description = "Enable amalgamated build.",
@@ -24,11 +26,6 @@ newoption {
}
newoption {
- trigger = "with-scintilla",
- description = "Enable building with Scintilla editor.",
-}
-
-newoption {
trigger = "with-shared-lib",
description = "Enable building shared library.",
}
@@ -48,15 +45,94 @@ newoption {
description = "Enable building examples.",
}
+newoption {
+ trigger = "with-webgpu",
+ description = "Enable webgpu experimental renderer.",
+}
+
+newaction {
+ trigger = "idl",
+ description = "Generate bgfx interface source code",
+ execute = function ()
+
+ local gen = require "bgfx-codegen"
+
+ local function generate(tempfile, outputfile, indent)
+ local codes = gen.apply(tempfile)
+ codes = gen.format(codes, {indent = indent})
+ gen.write(codes, outputfile)
+ print("Generating: " .. outputfile)
+ end
+
+ generate("temp.bgfx.h" , "../include/bgfx/c99/bgfx.h", " ")
+ generate("temp.bgfx.idl.inl", "../src/bgfx.idl.inl", "\t")
+ generate("temp.defines.h", "../include/bgfx/defines.h", "\t")
+
+ do
+ local csgen = require "bindings-cs"
+ csgen.write(csgen.gen(), "../bindings/cs/bgfx.cs")
+ csgen.write(csgen.gen_dllname(), "../bindings/cs/bgfx_dllname.cs")
+
+ local dgen = require "bindings-d"
+ dgen.write(dgen.gen_types(), "../bindings/d/types.d")
+ dgen.write(dgen.gen_funcs(), "../bindings/d/funcs.d")
+
+ local csgen = require "bindings-bf"
+ csgen.write(csgen.gen(), "../bindings/bf/bgfx.bf")
+
+ local ziggen = require "bindings-zig"
+ ziggen.write(ziggen.gen(), "../bindings/zig/bgfx.zig")
+ end
+
+ os.exit()
+ end
+}
+
+newaction {
+ trigger = "version",
+ description = "Generate bgfx version.h",
+ execute = function ()
+
+ local f = io.popen("git rev-list --count HEAD")
+ local rev = string.match(f:read("*a"), ".*%S")
+
+ local codegen = require "codegen"
+ local idl = codegen.idl "bgfx.idl"
+ print("1." .. idl._version .. "." .. rev)
+
+ f:close()
+ f = io.popen("git log --format=format:%H -1")
+ local sha1 = f:read("*a")
+ f:close()
+ io.output(path.join(MODULE_DIR, "src/version.h"))
+ io.write("/*\n")
+ io.write(" * Copyright 2011-2022 Branimir Karadzic. All rights reserved.\n")
+ io.write(" * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE\n")
+ io.write(" */\n")
+ io.write("\n")
+ io.write("/*\n")
+ io.write(" *\n")
+ io.write(" * AUTO GENERATED! DO NOT EDIT!\n")
+ io.write(" *\n")
+ io.write(" */\n")
+ io.write("\n")
+ io.write("#define BGFX_REV_NUMBER " .. rev .. "\n")
+ io.write("#define BGFX_REV_SHA1 \"" .. sha1 .. "\"\n")
+ io.close()
+
+ os.exit()
+ end
+}
+
solution "bgfx"
configurations {
"Debug",
"Release",
}
- if _ACTION == "xcode4" then
+ if _ACTION ~= nil and _ACTION:match "^xcode" then
platforms {
- "Universal",
+ "Native", -- let xcode decide based on the target output
}
else
platforms {
@@ -70,7 +146,6 @@ solution "bgfx"
language "C++"
startproject "example-00-helloworld"
-MODULE_DIR = path.getabsolute("../")
BGFX_DIR = path.getabsolute("..")
BX_DIR = os.getenv("BX_DIR")
BIMG_DIR = os.getenv("BIMG_DIR")
@@ -88,17 +163,34 @@ end
if not os.isdir(BX_DIR) or not os.isdir(BIMG_DIR) then
if not os.isdir(BX_DIR) then
- print("bx not found at " .. BX_DIR)
+ print("bx not found at \"" .. BX_DIR .. "\". git clone https://github.com/bkaradzic/bx?")
end
if not os.isdir(BIMG_DIR) then
- print("bimg not found at " .. BIMG_DIR)
+ print("bimg not found at \"" .. BIMG_DIR .. "\". git clone https://github.com/bkaradzic/bimg?")
end
print("For more info see: https://bkaradzic.github.io/bgfx/build.html")
os.exit()
end
+if _OPTIONS["with-webgpu"] then
+ DAWN_DIR = os.getenv("DAWN_DIR")
+
+ if not DAWN_DIR then
+ DAWN_DIR = path.getabsolute(path.join(BGFX_DIR, "../dawn"))
+ end
+
+ if not os.isdir(DAWN_DIR) and "wasm*" ~= _OPTIONS["gcc"] then
+ print("Dawn not found at \"" .. DAWN_DIR .. "\". git clone https://dawn.googlesource.com/dawn?")
+
+ print("For more info see: https://bkaradzic.github.io/bgfx/build.html")
+ os.exit()
+ end
+
+ _OPTIONS["with-windows"] = "10.0"
+end
+
dofile (path.join(BX_DIR, "scripts/toolchain.lua"))
if not toolchain(BGFX_BUILD_DIR, BGFX_THIRD_PARTY_DIR) then
return -- no action specified
@@ -110,7 +202,7 @@ end
if _OPTIONS["with-sdl"] then
if os.is("windows") then
if not os.getenv("SDL2_DIR") then
- print("Set SDL2_DIR enviroment variable.")
+ print("Set SDL2_DIR environment variable.")
end
end
end
@@ -127,7 +219,6 @@ function exampleProjectDefaults()
debugdir (path.join(BGFX_DIR, "examples/runtime"))
includedirs {
- path.join(BX_DIR, "include"),
path.join(BIMG_DIR, "include"),
path.join(BGFX_DIR, "include"),
path.join(BGFX_DIR, "3rdparty"),
@@ -139,19 +230,24 @@ function exampleProjectDefaults()
}
links {
- "example-common",
"example-glue",
+ "example-common",
"bgfx",
"bimg_decode",
"bimg",
- "bx",
}
+ using_bx()
+
+ if _OPTIONS["with-webgpu"] then
+ usesWebGPU()
+ end
+
if _OPTIONS["with-sdl"] then
defines { "ENTRY_CONFIG_USE_SDL=1" }
links { "SDL2" }
- configuration { "osx" }
+ configuration { "osx*" }
libdirs { "$(SDL2_DIR)/lib" }
configuration {}
@@ -161,19 +257,9 @@ function exampleProjectDefaults()
defines { "ENTRY_CONFIG_USE_GLFW=1" }
links { "glfw3" }
- configuration { "linux or freebsd" }
- links {
- "Xrandr",
- "Xinerama",
- "Xi",
- "Xxf86vm",
- "Xcursor",
- }
-
- configuration { "osx" }
+ configuration { "osx*" }
linkoptions {
"-framework CoreVideo",
- "-framework IOKit",
}
configuration {}
@@ -196,6 +282,7 @@ function exampleProjectDefaults()
configuration { "mingw*" }
targetextension ".exe"
links {
+ "comdlg32",
"gdi32",
"psapi",
}
@@ -256,22 +343,27 @@ function exampleProjectDefaults()
"GLESv2",
}
- configuration { "asmjs" }
+ configuration { "wasm*" }
kind "ConsoleApp"
- targetextension ".bc"
- configuration { "linux-* or freebsd", "not linux-steamlink" }
- links {
- "X11",
- "GL",
- "pthread",
+ linkoptions {
+ "-s TOTAL_MEMORY=32MB",
+ "-s ALLOW_MEMORY_GROWTH=1",
+ "--preload-file ../../../examples/runtime@/"
+ }
+
+ removeflags {
+ "OptimizeSpeed",
+ }
+
+ flags {
+ "Optimize"
}
- configuration { "linux-steamlink" }
+ configuration { "linux-* or freebsd" }
links {
- "EGL",
- "GLESv2",
- "SDL2",
+ "X11",
+ "GL",
"pthread",
}
@@ -286,11 +378,12 @@ function exampleProjectDefaults()
"pthread",
}
- configuration { "osx" }
+ configuration { "osx*" }
linkoptions {
"-framework Cocoa",
- "-framework QuartzCore",
+ "-framework IOKit",
"-framework OpenGL",
+ "-framework QuartzCore",
"-weak_framework Metal",
}
@@ -299,32 +392,25 @@ function exampleProjectDefaults()
linkoptions {
"-framework CoreFoundation",
"-framework Foundation",
+ "-framework IOKit",
"-framework OpenGLES",
- "-framework UIKit",
"-framework QuartzCore",
+ "-framework UIKit",
"-weak_framework Metal",
}
- configuration { "xcode4", "ios" }
+ configuration { "xcode*", "ios" }
kind "WindowedApp"
files {
path.join(BGFX_DIR, "examples/runtime/iOS-Info.plist"),
}
- configuration { "xcode4", "tvos" }
+ configuration { "xcode*", "tvos" }
kind "WindowedApp"
files {
path.join(BGFX_DIR, "examples/runtime/tvOS-Info.plist"),
}
-
- configuration { "qnx*" }
- targetextension ""
- links {
- "EGL",
- "GLESv2",
- }
-
configuration {}
strip()
@@ -385,16 +471,35 @@ function exampleProject(_combined, ...)
end
-dofile "bgfx.lua"
-
group "libs"
-bgfxProject("", "StaticLib", {})
-
dofile(path.join(BX_DIR, "scripts/bx.lua"))
dofile(path.join(BIMG_DIR, "scripts/bimg.lua"))
dofile(path.join(BIMG_DIR, "scripts/bimg_decode.lua"))
+dofile "bgfx.lua"
+
+local function userdefines()
+ local defines = {}
+ local BGFX_CONFIG = os.getenv("BGFX_CONFIG")
+ if BGFX_CONFIG then
+ for def in BGFX_CONFIG:gmatch "[^%s:]+" do
+ table.insert(defines, "BGFX_CONFIG_" .. def)
+ end
+ end
+
+ return defines
+end
+
+BGFX_CONFIG = userdefines()
+
+bgfxProject("", "StaticLib", BGFX_CONFIG)
+
+if _OPTIONS["with-shared-lib"] then
+ group "libs"
+ bgfxProject("-shared-lib", "SharedLib", BGFX_CONFIG)
+end
if _OPTIONS["with-tools"] then
+ group "libs"
dofile(path.join(BIMG_DIR, "scripts/bimg_encode.lua"))
end
@@ -427,7 +532,6 @@ or _OPTIONS["with-combined-examples"] then
, "14-shadowvolumes"
, "15-shadowmaps-simple"
, "16-shadowmaps"
- , "17-drawstress"
, "18-ibl"
, "19-oit"
, "20-nanovg"
@@ -448,23 +552,35 @@ or _OPTIONS["with-combined-examples"] then
, "36-sky"
, "37-gpudrivenrendering"
, "38-bloom"
+ , "39-assao"
+ , "40-svt"
+ , "41-tess"
+ , "42-bunnylod"
+ , "43-denoise"
+ , "44-sss"
+ , "45-bokeh"
+ , "46-fsr"
+ , "47-pixelformats"
+ , "48-drawindirect"
+ , "49-hextile"
)
+ -- 17-drawstress requires multithreading, does not compile for singlethreaded wasm
+ if premake.gcc.namestyle == nil or not premake.gcc.namestyle == "Emscripten" then
+ exampleProject(false, "17-drawstress")
+ end
+
-- C99 source doesn't compile under WinRT settings
if not premake.vstudio.iswinrt() then
exampleProject(false, "25-c99")
end
end
-if _OPTIONS["with-shared-lib"] then
- group "libs"
- bgfxProject("-shared-lib", "SharedLib", {})
-end
-
if _OPTIONS["with-tools"] then
group "tools"
dofile "shaderc.lua"
dofile "texturec.lua"
dofile "texturev.lua"
dofile "geometryc.lua"
+ dofile "geometryv.lua"
end