bgfx/scripts/genie.lua

488 lines
9.3 KiB
Lua
Raw Normal View History

2012-04-03 20:30:07 -07:00
--
2018-01-01 11:16:06 -08:00
-- Copyright 2010-2018 Branimir Karadzic. All rights reserved.
2016-01-01 00:11:04 -08:00
-- License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
2012-04-03 20:30:07 -07:00
--
2014-05-04 15:43:14 -07:00
newoption {
trigger = "with-amalgamated",
description = "Enable amalgamated build.",
2014-05-04 15:43:14 -07:00
}
2014-08-22 19:29:54 -07:00
newoption {
trigger = "with-ovr",
description = "Enable OculusVR integration.",
2014-08-22 19:29:54 -07:00
}
newoption {
trigger = "with-sdl",
description = "Enable SDL entry.",
}
2015-03-24 22:19:21 -07:00
newoption {
trigger = "with-glfw",
description = "Enable GLFW entry.",
}
2015-11-13 21:11:19 -08:00
newoption {
trigger = "with-profiler",
description = "Enable build with intrusive profiler.",
}
2015-06-08 21:16:07 -07:00
newoption {
trigger = "with-scintilla",
description = "Enable building with Scintilla editor.",
}
2014-10-19 21:29:27 -07:00
newoption {
trigger = "with-shared-lib",
description = "Enable building shared library.",
}
newoption {
trigger = "with-tools",
description = "Enable building tools.",
2014-10-19 21:29:27 -07:00
}
2017-06-25 22:54:17 -07:00
newoption {
trigger = "with-combined-examples",
description = "Enable building examples (combined as single executable).",
}
newoption {
trigger = "with-examples",
description = "Enable building examples.",
}
2012-04-03 20:30:07 -07:00
solution "bgfx"
configurations {
"Debug",
"Release",
}
if _ACTION == "xcode4" then
platforms {
"Universal",
}
else
platforms {
"x32",
"x64",
-- "Xbox360",
"Native", -- for targets where bitness is not specified
}
end
2012-04-03 20:30:07 -07:00
language "C++"
2014-09-15 20:50:35 -07:00
startproject "example-00-helloworld"
2012-04-03 20:30:07 -07:00
2016-04-21 22:12:35 -07:00
MODULE_DIR = path.getabsolute("../")
BGFX_DIR = path.getabsolute("..")
BX_DIR = os.getenv("BX_DIR")
BIMG_DIR = os.getenv("BIMG_DIR")
2016-01-09 15:34:41 -08:00
local BGFX_BUILD_DIR = path.join(BGFX_DIR, ".build")
local BGFX_THIRD_PARTY_DIR = path.join(BGFX_DIR, "3rdparty")
2016-01-09 15:34:41 -08:00
if not BX_DIR then
2016-01-09 20:30:15 -08:00
BX_DIR = path.getabsolute(path.join(BGFX_DIR, "../bx"))
2016-01-09 15:34:41 -08:00
end
2012-09-16 17:36:08 -07:00
if not BIMG_DIR then
BIMG_DIR = path.getabsolute(path.join(BGFX_DIR, "../bimg"))
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)
end
if not os.isdir(BIMG_DIR) then
print("bimg not found at " .. BIMG_DIR)
end
2015-12-10 22:58:31 -08:00
print("For more info see: https://bkaradzic.github.io/bgfx/build.html")
os.exit()
end
dofile (path.join(BX_DIR, "scripts/toolchain.lua"))
if not toolchain(BGFX_BUILD_DIR, BGFX_THIRD_PARTY_DIR) then
return -- no action specified
end
2012-04-03 20:30:07 -07:00
2012-06-01 21:56:20 -07:00
function copyLib()
end
if _OPTIONS["with-sdl"] then
if os.is("windows") then
if not os.getenv("SDL2_DIR") then
print("Set SDL2_DIR enviroment variable.")
end
end
end
2015-11-13 21:11:19 -08:00
if _OPTIONS["with-profiler"] then
defines {
"ENTRY_CONFIG_PROFILER=1",
2017-10-06 20:10:05 -07:00
"BGFX_CONFIG_PROFILER=1",
2015-11-13 21:11:19 -08:00
}
end
2017-06-24 18:23:43 -07:00
function exampleProjectDefaults()
2013-01-26 16:30:02 -08:00
debugdir (path.join(BGFX_DIR, "examples/runtime"))
2013-01-26 16:30:02 -08:00
includedirs {
2015-03-18 16:23:38 -07:00
path.join(BX_DIR, "include"),
2017-04-03 22:42:27 -07:00
path.join(BIMG_DIR, "include"),
path.join(BGFX_DIR, "include"),
path.join(BGFX_DIR, "3rdparty"),
path.join(BGFX_DIR, "examples/common"),
2013-01-26 16:30:02 -08:00
}
2017-03-12 18:25:23 -07:00
flags {
"FatalWarnings",
}
2013-01-26 16:30:02 -08:00
links {
2017-01-08 17:07:29 -08:00
"example-common",
"example-glue",
2013-01-26 16:30:02 -08:00
"bgfx",
2017-04-03 22:42:27 -07:00
"bimg_decode",
"bimg",
2017-01-08 15:15:22 -08:00
"bx",
2013-01-26 16:30:02 -08:00
}
if _OPTIONS["with-sdl"] then
defines { "ENTRY_CONFIG_USE_SDL=1" }
links { "SDL2" }
2016-01-23 21:07:44 -08:00
configuration { "osx" }
libdirs { "$(SDL2_DIR)/lib" }
configuration {}
end
2015-03-24 22:19:21 -07:00
if _OPTIONS["with-glfw"] then
defines { "ENTRY_CONFIG_USE_GLFW=1" }
2016-01-23 21:07:44 -08:00
links { "glfw3" }
2015-03-24 22:19:21 -07:00
2015-04-10 16:46:49 +02:00
configuration { "linux or freebsd" }
2015-03-24 23:21:32 -07:00
links {
"Xrandr",
"Xinerama",
"Xi",
"Xxf86vm",
"Xcursor",
}
2015-03-24 22:19:21 -07:00
configuration { "osx" }
linkoptions {
"-framework CoreVideo",
"-framework IOKit",
}
configuration {}
end
2014-10-19 21:29:27 -07:00
if _OPTIONS["with-ovr"] then
2016-04-02 18:47:54 -07:00
configuration { "x32" }
2016-04-02 11:41:40 +02:00
libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Windows/Win32/Release", _ACTION) }
2014-10-19 21:29:27 -07:00
2016-04-02 18:47:54 -07:00
configuration { "x64" }
2016-04-02 11:41:40 +02:00
libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Windows/x64/Release", _ACTION) }
2014-10-19 21:29:27 -07:00
2016-04-02 11:41:40 +02:00
configuration { "x32 or x64" }
links { "libovr" }
2014-10-19 21:29:27 -07:00
configuration {}
end
2016-02-25 20:29:09 -08:00
configuration { "vs*", "x32 or x64" }
linkoptions {
"/ignore:4199", -- LNK4199: /DELAYLOAD:*.dll ignored; no imports found from *.dll
}
links { -- this is needed only for testing with GLES2/3 on Windows with VS2008
"DelayImp",
}
2016-02-25 20:29:09 -08:00
configuration { "vs201*", "x32 or x64" }
linkoptions { -- this is needed only for testing with GLES2/3 on Windows with VS201x
"/DELAYLOAD:\"libEGL.dll\"",
"/DELAYLOAD:\"libGLESv2.dll\"",
}
configuration { "mingw*" }
targetextension ".exe"
2016-02-25 20:29:09 -08:00
links {
"gdi32",
"psapi",
}
2016-02-25 20:29:09 -08:00
configuration { "vs20*", "x32 or x64" }
2014-10-15 23:21:46 -07:00
links {
"gdi32",
"psapi",
}
2016-02-25 20:29:09 -08:00
configuration { "durango" }
links {
"d3d11_x",
2016-03-08 16:39:59 -08:00
"d3d12_x",
2016-02-25 20:29:09 -08:00
"combase",
"kernelx",
}
2017-12-14 20:40:30 -08:00
configuration { "winstore*" }
removelinks {
"DelayImp",
"gdi32",
"psapi"
}
links {
"d3d11",
2017-12-13 23:40:39 -08:00
"d3d12",
"dxgi"
}
linkoptions {
"/ignore:4264" -- LNK4264: archiving object file compiled with /ZW into a static library; note that when authoring Windows Runtime types it is not recommended to link with a static library that contains Windows Runtime metadata
}
-- WinRT targets need their own output directories or build files stomp over each other
2017-12-14 20:40:30 -08:00
configuration { "x32", "winstore*" }
targetdir (path.join(BGFX_BUILD_DIR, "win32_" .. _ACTION, "bin", _name))
objdir (path.join(BGFX_BUILD_DIR, "win32_" .. _ACTION, "obj", _name))
2017-12-14 20:40:30 -08:00
configuration { "x64", "winstore*" }
targetdir (path.join(BGFX_BUILD_DIR, "win64_" .. _ACTION, "bin", _name))
objdir (path.join(BGFX_BUILD_DIR, "win64_" .. _ACTION, "obj", _name))
2017-12-14 20:40:30 -08:00
configuration { "ARM", "winstore*" }
targetdir (path.join(BGFX_BUILD_DIR, "arm_" .. _ACTION, "bin", _name))
objdir (path.join(BGFX_BUILD_DIR, "arm_" .. _ACTION, "obj", _name))
2014-10-17 23:17:29 -07:00
configuration { "mingw-clang" }
kind "ConsoleApp"
2013-04-16 23:12:03 -07:00
configuration { "android*" }
2013-12-02 19:46:25 -08:00
kind "ConsoleApp"
2013-04-16 23:12:03 -07:00
targetextension ".so"
2013-12-02 19:46:25 -08:00
linkoptions {
"-shared",
}
2013-04-16 23:12:03 -07:00
links {
"EGL",
"GLESv2",
}
2014-03-16 12:38:43 -07:00
configuration { "asmjs" }
kind "ConsoleApp"
targetextension ".bc"
2016-02-15 19:45:58 +01:00
configuration { "linux-* or freebsd", "not linux-steamlink" }
2013-01-26 16:30:02 -08:00
links {
2013-04-29 19:35:33 -07:00
"X11",
2013-01-26 16:30:02 -08:00
"GL",
"pthread",
}
2016-02-15 19:45:58 +01:00
configuration { "linux-steamlink" }
links {
"EGL",
"GLESv2",
"SDL2",
"pthread",
}
2016-02-25 20:29:09 -08:00
2014-08-24 17:41:41 -07:00
configuration { "rpi" }
links {
"X11",
"brcmGLESv2",
"brcmEGL",
2014-08-24 17:41:41 -07:00
"bcm_host",
2014-08-24 20:39:35 -07:00
"vcos",
"vchiq_arm",
2014-08-24 17:41:41 -07:00
"pthread",
}
2013-04-12 23:43:46 -07:00
configuration { "osx" }
2015-10-06 15:27:54 -07:00
linkoptions {
"-framework Cocoa",
"-framework QuartzCore",
"-framework OpenGL",
"-weak_framework Metal",
2013-01-26 16:30:02 -08:00
}
2015-10-12 13:32:39 -07:00
configuration { "ios* or tvos*" }
2013-07-21 14:44:53 -07:00
kind "ConsoleApp"
2013-07-12 22:27:46 -07:00
linkoptions {
"-framework CoreFoundation",
"-framework Foundation",
"-framework OpenGLES",
2013-07-21 14:44:53 -07:00
"-framework UIKit",
"-framework QuartzCore",
"-weak_framework Metal",
2013-07-12 22:27:46 -07:00
}
configuration { "xcode4", "ios" }
kind "WindowedApp"
files {
path.join(BGFX_DIR, "examples/runtime/iOS-Info.plist"),
}
2015-10-12 13:32:39 -07:00
configuration { "xcode4", "tvos" }
kind "WindowedApp"
files {
path.join(BGFX_DIR, "examples/runtime/tvOS-Info.plist"),
}
2017-06-24 18:23:43 -07:00
configuration { "qnx*" }
targetextension ""
links {
"EGL",
"GLESv2",
}
configuration {}
strip()
2013-01-26 16:30:02 -08:00
end
2017-06-24 18:56:45 -07:00
function exampleProject(_combined, ...)
2017-06-24 18:23:43 -07:00
2017-06-24 18:56:45 -07:00
if _combined then
2017-06-24 18:23:43 -07:00
project ("examples")
uuid (os.uuid("examples"))
kind "WindowedApp"
for _, name in ipairs({...}) do
files {
path.join(BGFX_DIR, "examples", name, "**.c"),
path.join(BGFX_DIR, "examples", name, "**.cpp"),
path.join(BGFX_DIR, "examples", name, "**.h"),
}
removefiles {
path.join(BGFX_DIR, "examples", name, "**.bin.h"),
}
end
2017-06-25 21:44:04 -07:00
files {
path.join(BGFX_DIR, "examples/25-c99/helloworld.c"), -- hack for _main_
}
2017-06-24 18:23:43 -07:00
exampleProjectDefaults()
else
for _, name in ipairs({...}) do
project ("example-" .. name)
uuid (os.uuid("example-" .. name))
kind "WindowedApp"
files {
path.join(BGFX_DIR, "examples", name, "**.c"),
path.join(BGFX_DIR, "examples", name, "**.cpp"),
path.join(BGFX_DIR, "examples", name, "**.h"),
}
removefiles {
path.join(BGFX_DIR, "examples", name, "**.bin.h"),
}
2017-06-25 21:44:04 -07:00
defines {
"ENTRY_CONFIG_IMPLEMENT_MAIN=1",
}
2017-06-24 18:23:43 -07:00
exampleProjectDefaults()
end
end
end
2012-06-01 19:55:56 -07:00
dofile "bgfx.lua"
2014-12-06 12:52:14 -08:00
group "libs"
2014-09-10 23:01:22 -07:00
bgfxProject("", "StaticLib", {})
2017-04-03 22:42:27 -07:00
dofile(path.join(BX_DIR, "scripts/bx.lua"))
dofile(path.join(BIMG_DIR, "scripts/bimg.lua"))
2017-04-04 19:47:18 -07:00
dofile(path.join(BIMG_DIR, "scripts/bimg_decode.lua"))
if _OPTIONS["with-tools"] then
dofile(path.join(BIMG_DIR, "scripts/bimg_encode.lua"))
end
2017-01-08 15:15:22 -08:00
2017-06-25 22:54:17 -07:00
if _OPTIONS["with-examples"]
or _OPTIONS["with-combined-examples"]
or _OPTIONS["with-tools"] then
2016-09-10 09:53:29 -07:00
group "examples"
dofile "example-common.lua"
end
2017-06-25 22:54:17 -07:00
if _OPTIONS["with-examples"]
or _OPTIONS["with-combined-examples"] then
group "examples"
2017-06-24 18:23:43 -07:00
2017-06-25 22:54:17 -07:00
exampleProject(_OPTIONS["with-combined-examples"]
2017-06-24 18:23:43 -07:00
, "00-helloworld"
, "01-cubes"
, "02-metaballs"
, "03-raymarch"
, "04-mesh"
, "05-instancing"
, "06-bump"
, "07-callback"
, "08-update"
, "09-hdr"
, "10-font"
, "11-fontsdf"
, "12-lod"
, "13-stencil"
, "14-shadowvolumes"
, "15-shadowmaps-simple"
, "16-shadowmaps"
, "17-drawstress"
, "18-ibl"
, "19-oit"
, "20-nanovg"
, "21-deferred"
, "22-windows"
, "23-vectordisplay"
, "24-nbody"
, "26-occlusion"
, "27-terrain"
, "28-wireframe"
, "29-debugdraw"
, "30-picking"
, "31-rsm"
, "32-particles"
, "33-pom"
2017-08-19 10:58:06 -07:00
, "34-mvs"
, "35-dynamic"
, "36-sky"
, "37-gpudrivenrendering"
2017-06-24 18:23:43 -07:00
)
-- C99 source doesn't compile under WinRT settings
if not premake.vstudio.iswinrt() then
2017-06-24 18:56:45 -07:00
exampleProject(false, "25-c99")
end
end
2014-08-22 19:29:54 -07:00
if _OPTIONS["with-shared-lib"] then
2014-12-06 12:52:14 -08:00
group "libs"
2014-09-10 23:01:22 -07:00
bgfxProject("-shared-lib", "SharedLib", {})
2014-08-22 19:29:54 -07:00
end
2014-05-04 15:43:14 -07:00
if _OPTIONS["with-tools"] then
2014-12-06 12:52:14 -08:00
group "tools"
2014-05-04 15:43:14 -07:00
dofile "shaderc.lua"
dofile "texturec.lua"
2016-04-21 22:12:35 -07:00
dofile "texturev.lua"
2014-05-04 15:43:14 -07:00
dofile "geometryc.lua"
end