2013-05-18 06:39:08 +04:00
--
2020-01-15 08:37:06 +03:00
-- Copyright 2010-2020 Branimir Karadzic. All rights reserved.
2016-01-01 11:11:04 +03:00
-- License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
2013-05-18 06:39:08 +04:00
--
2016-10-05 08:48:59 +03:00
function filesexist ( _srcPath , _dstPath , _files )
for _ , file in ipairs ( _files ) do
file = path.getrelative ( _srcPath , file )
local filePath = path.join ( _dstPath , file )
if not os.isfile ( filePath ) then return false end
end
return true
end
2016-09-30 07:23:07 +03:00
function overridefiles ( _srcPath , _dstPath , _files )
local remove = { }
local add = { }
for _ , file in ipairs ( _files ) do
file = path.getrelative ( _srcPath , file )
2016-10-05 08:48:59 +03:00
local filePath = path.join ( _dstPath , file )
2016-10-01 06:03:16 +03:00
if not os.isfile ( filePath ) then return end
2016-09-30 07:23:07 +03:00
table.insert ( remove , path.join ( _srcPath , file ) )
table.insert ( add , filePath )
end
removefiles {
remove ,
}
files {
add ,
}
end
2017-11-02 19:12:09 +03:00
function bgfxProjectBase ( _kind , _defines )
2014-12-26 01:51:11 +03:00
2019-01-26 04:18:30 +03:00
kind ( _kind )
2013-02-22 09:13:56 +04:00
2019-01-26 04:18:30 +03:00
if _kind == " SharedLib " then
2014-08-01 09:00:36 +04:00
defines {
2019-01-26 04:18:30 +03:00
" BGFX_SHARED_LIB_BUILD=1 " ,
2013-02-22 09:13:56 +04:00
}
2017-01-09 02:15:22 +03:00
links {
2019-01-26 04:18:30 +03:00
" bimg " ,
2017-01-09 02:15:22 +03:00
" bx " ,
}
2019-01-26 04:18:30 +03:00
configuration { " vs20* or mingw* " }
2014-08-01 09:00:36 +04:00
links {
2019-01-26 04:18:30 +03:00
" gdi32 " ,
" psapi " ,
2014-08-01 09:00:36 +04:00
}
2013-02-22 09:13:56 +04:00
2019-01-26 04:18:30 +03:00
configuration { " mingw* " }
2014-11-10 02:24:22 +03:00
linkoptions {
2019-01-26 04:18:30 +03:00
" -shared " ,
2014-11-10 02:24:22 +03:00
}
2019-01-26 04:18:30 +03:00
configuration { " linux-* " }
2015-09-23 01:19:39 +03:00
buildoptions {
2019-01-26 04:18:30 +03:00
" -fPIC " ,
2015-09-23 01:19:39 +03:00
}
2020-05-04 04:18:26 +03:00
links {
" X11 " ,
" GL " ,
" pthread " ,
}
2015-09-23 01:19:39 +03:00
2019-01-26 04:18:30 +03:00
configuration { }
end
2014-06-02 02:26:36 +04:00
2019-01-26 04:18:30 +03:00
includedirs {
path.join ( BGFX_DIR , " 3rdparty " ) ,
path.join ( BX_DIR , " include " ) ,
path.join ( BIMG_DIR , " include " ) ,
}
2014-06-02 02:26:36 +04:00
2019-01-26 04:18:30 +03:00
defines {
_defines ,
}
2016-02-15 21:45:58 +03:00
2019-01-26 04:18:30 +03:00
links {
" bx " ,
}
if _OPTIONS [ " with-glfw " ] then
defines {
" BGFX_CONFIG_MULTITHREADED=0 " ,
}
end
2014-06-02 02:26:36 +04:00
2019-01-26 04:18:30 +03:00
configuration { " Debug " }
defines {
" BGFX_CONFIG_DEBUG=1 " ,
}
configuration { " vs* or mingw* " , " not durango " }
2014-06-02 02:26:36 +04:00
includedirs {
2019-01-26 04:18:30 +03:00
path.join ( BGFX_DIR , " 3rdparty/dxsdk/include " ) ,
2014-06-02 02:26:36 +04:00
}
2019-01-26 04:18:30 +03:00
configuration { " android* " }
links {
" EGL " ,
" GLESv2 " ,
2014-07-08 06:53:00 +04:00
}
2019-01-26 04:18:30 +03:00
configuration { " winstore* " }
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
2014-06-02 02:26:36 +04:00
}
2019-01-26 04:18:30 +03:00
configuration { " *clang* " }
buildoptions {
" -Wno-microsoft-enum-value " , -- enumerator value is not representable in the underlying type 'int'
" -Wno-microsoft-const-init " , -- default initialization of an object of const type '' without a user-provided default constructor is a Microsoft extension
}
2016-09-30 07:23:07 +03:00
2019-01-26 04:18:30 +03:00
configuration { " osx " }
2019-08-02 16:33:40 +03:00
buildoptions { " -x objective-c++ " } -- additional build option for osx
2019-01-26 04:18:30 +03:00
linkoptions {
" -framework Cocoa " ,
" -framework QuartzCore " ,
" -framework OpenGL " ,
" -weak_framework Metal " ,
" -weak_framework MetalKit " ,
}
2015-06-20 03:34:01 +03:00
2020-03-12 07:51:55 +03:00
configuration { " not NX32 " , " not NX64 " }
2019-01-26 04:18:30 +03:00
includedirs {
-- NX has EGL headers modified...
path.join ( BGFX_DIR , " 3rdparty/khronos " ) ,
}
2015-06-20 10:22:36 +03:00
2019-01-26 04:18:30 +03:00
configuration { }
2016-09-23 08:16:54 +03:00
2019-01-26 04:18:30 +03:00
includedirs {
path.join ( BGFX_DIR , " include " ) ,
}
2015-06-20 05:55:23 +03:00
2019-01-26 04:18:30 +03:00
files {
path.join ( BGFX_DIR , " include/**.h " ) ,
path.join ( BGFX_DIR , " src/**.cpp " ) ,
path.join ( BGFX_DIR , " src/**.h " ) ,
path.join ( BGFX_DIR , " scripts/**.natvis " ) ,
}
2015-06-20 03:34:01 +03:00
2019-01-26 04:18:30 +03:00
removefiles {
path.join ( BGFX_DIR , " src/**.bin.h " ) ,
}
2019-03-13 03:01:02 +03:00
overridefiles ( BGFX_DIR , path.join ( BGFX_DIR , " ../bgfx-gnm " ) , {
2019-01-26 04:18:30 +03:00
path.join ( BGFX_DIR , " src/renderer_gnm.cpp " ) ,
path.join ( BGFX_DIR , " src/renderer_gnm.h " ) ,
} )
2019-03-13 03:01:02 +03:00
overridefiles ( BGFX_DIR , path.join ( BGFX_DIR , " ../bgfx-nvn " ) , {
path.join ( BGFX_DIR , " src/renderer_nvn.cpp " ) ,
path.join ( BGFX_DIR , " src/renderer_nvn.h " ) ,
} )
2020-05-09 20:24:23 +03:00
if _OPTIONS [ " with-webgpu " ] then
2020-05-08 18:53:53 +03:00
defines {
" BGFX_CONFIG_RENDERER_WEBGPU=1 " ,
}
2020-05-09 20:24:23 +03:00
local generator = " out/VS2019 "
includedirs {
path.join ( DAWN_DIR , " src " ) ,
path.join ( DAWN_DIR , " src/include " ) ,
path.join ( DAWN_DIR , " third_party/vulkan-headers/include " ) ,
path.join ( DAWN_DIR , generator , " gen/src " ) ,
path.join ( DAWN_DIR , generator , " gen/src/include " ) ,
}
2020-05-08 18:53:53 +03:00
configuration { " asmjs " }
defines {
" BGFX_CONFIG_RENDERER_OPENGL=0 " ,
" BGFX_CONFIG_RENDERER_OPENGLES=0 " ,
}
configuration { " not asmjs " }
--local generator = "out/Default"
2020-05-09 20:24:23 +03:00
configuration { " vs* " }
defines {
" NTDDI_VERSION=NTDDI_WIN10_RS2 " ,
2020-05-08 18:53:53 +03:00
2020-05-09 20:24:23 +03:00
-- We can't say `=_WIN32_WINNT_WIN10` here because some files do
-- `#if WINVER < 0x0600` without including windows.h before,
-- and then _WIN32_WINNT_WIN10 isn't yet known to be 0x0A00.
" _WIN32_WINNT=0x0A00 " ,
" WINVER=0x0A00 " ,
}
2020-05-08 18:53:53 +03:00
configuration { }
end
2020-05-08 19:03:02 +03:00
2019-01-26 04:18:30 +03:00
if _OPTIONS [ " with-amalgamated " ] then
excludes {
path.join ( BGFX_DIR , " src/bgfx.cpp " ) ,
path.join ( BGFX_DIR , " src/debug_**.cpp " ) ,
path.join ( BGFX_DIR , " src/dxgi.cpp " ) ,
path.join ( BGFX_DIR , " src/glcontext_**.cpp " ) ,
path.join ( BGFX_DIR , " src/hmd**.cpp " ) ,
path.join ( BGFX_DIR , " src/image.cpp " ) ,
path.join ( BGFX_DIR , " src/nvapi.cpp " ) ,
path.join ( BGFX_DIR , " src/renderer_**.cpp " ) ,
path.join ( BGFX_DIR , " src/shader**.cpp " ) ,
path.join ( BGFX_DIR , " src/topology.cpp " ) ,
2020-03-29 06:06:03 +03:00
path.join ( BGFX_DIR , " src/vertexlayout.cpp " ) ,
2019-01-26 04:18:30 +03:00
}
configuration { " xcode* or osx or ios* " }
files {
path.join ( BGFX_DIR , " src/amalgamated.mm " ) ,
}
2015-06-20 05:55:23 +03:00
2015-03-22 03:42:46 +03:00
excludes {
2019-01-26 04:18:30 +03:00
path.join ( BGFX_DIR , " src/glcontext_**.mm " ) ,
path.join ( BGFX_DIR , " src/renderer_**.mm " ) ,
path.join ( BGFX_DIR , " src/amalgamated.cpp " ) ,
}
configuration { " not (xcode* or osx or ios*) " }
excludes {
path.join ( BGFX_DIR , " src/**.mm " ) ,
2015-03-22 03:42:46 +03:00
}
2014-08-01 09:00:36 +04:00
configuration { }
2019-01-26 04:18:30 +03:00
else
configuration { " xcode* or osx or ios* " }
files {
path.join ( BGFX_DIR , " src/glcontext_**.mm " ) ,
path.join ( BGFX_DIR , " src/renderer_**.mm " ) ,
}
configuration { }
excludes {
path.join ( BGFX_DIR , " src/amalgamated.** " ) ,
}
end
2019-03-13 03:01:02 +03:00
if filesexist ( BGFX_DIR , path.join ( BGFX_DIR , " ../bgfx-gnm " ) , {
path.join ( BGFX_DIR , " scripts/bgfx.lua " ) , } ) then
dofile ( path.join ( BGFX_DIR , " ../bgfx-gnm/scripts/bgfx.lua " ) )
end
if filesexist ( BGFX_DIR , path.join ( BGFX_DIR , " ../bgfx-nvn " ) , {
2019-01-26 04:18:30 +03:00
path.join ( BGFX_DIR , " scripts/bgfx.lua " ) , } ) then
2019-03-13 03:01:02 +03:00
dofile ( path.join ( BGFX_DIR , " ../bgfx-nvn/scripts/bgfx.lua " ) )
2019-01-26 04:18:30 +03:00
end
configuration { }
end
function bgfxProject ( _name , _kind , _defines )
project ( " bgfx " .. _name )
uuid ( os.uuid ( " bgfx " .. _name ) )
bgfxProjectBase ( _kind , _defines )
copyLib ( )
2014-08-01 09:00:36 +04:00
end
2020-05-08 18:53:53 +03:00
2020-05-09 20:24:23 +03:00
if _OPTIONS [ " with-webgpu " ] then
2020-05-08 18:53:53 +03:00
function usesWebGPU ( )
configuration { " asmjs " }
linkoptions {
" -s USE_WEBGPU=1 " ,
}
configuration { " not asmjs " }
--local generator = "out/Default"
local generator = " out/VS2019 "
includedirs {
path.join ( DAWN_DIR , " src " ) ,
path.join ( DAWN_DIR , " src/include " ) ,
path.join ( DAWN_DIR , generator , " gen/src " ) ,
path.join ( DAWN_DIR , generator , " gen/src/include " ) ,
}
libdirs {
path.join ( DAWN_DIR , generator ) ,
path.join ( DAWN_DIR , generator , " lib/Debug " ) ,
}
files {
path.join ( DAWN_DIR , generator , " gen/src/dawn/webgpu_cpp.cpp " ) ,
}
links {
-- shared
" dawn_proc_shared " ,
" dawn_native_shared " ,
" shaderc_spvc_shared " ,
-- static
--"dawn_common",
--"dawn_proc",
--"dawn_native",
--"dawn_platform",
------"shaderc",
--"shaderc_spvc",
--"SPIRV-tools",
--"SPIRV-tools-opt",
--"spirv-cross-cored",
--"spirv-cross-hlsld",
--"spirv-cross-glsld",
--"spirv-cross-msld",
--"spirv-cross-reflectd",
}
removeflags {
" FatalWarnings " ,
}
configuration { }
end
end