2
0

bgfx.lua 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. --
  2. -- Copyright 2010-2025 Branimir Karadzic. All rights reserved.
  3. -- License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
  4. --
  5. function filesexist(_srcPath, _dstPath, _files)
  6. for _, file in ipairs(_files) do
  7. file = path.getrelative(_srcPath, file)
  8. local filePath = path.join(_dstPath, file)
  9. if not os.isfile(filePath) then return false end
  10. end
  11. return true
  12. end
  13. function overridefiles(_srcPath, _dstPath, _files)
  14. local remove = {}
  15. local add = {}
  16. for _, file in ipairs(_files) do
  17. file = path.getrelative(_srcPath, file)
  18. local filePath = path.join(_dstPath, file)
  19. if not os.isfile(filePath) then return end
  20. table.insert(remove, path.join(_srcPath, file))
  21. table.insert(add, filePath)
  22. end
  23. removefiles {
  24. remove,
  25. }
  26. files {
  27. add,
  28. }
  29. end
  30. function bgfxProjectBase(_kind, _defines)
  31. kind (_kind)
  32. if _kind == "SharedLib" then
  33. defines {
  34. "BGFX_SHARED_LIB_BUILD=1",
  35. }
  36. links {
  37. "bimg",
  38. }
  39. configuration { "vs20* or mingw*" }
  40. links {
  41. "gdi32",
  42. "psapi",
  43. }
  44. configuration { "mingw*" }
  45. linkoptions {
  46. "-shared",
  47. }
  48. configuration { "linux-*" }
  49. buildoptions {
  50. "-fPIC",
  51. }
  52. links {
  53. "X11",
  54. "GL",
  55. "pthread",
  56. }
  57. configuration { "android*" }
  58. targetextension ".so"
  59. configuration { "android*" ,"Debug"}
  60. linkoptions {
  61. "-Wl,-soname,libbgfx-shared-libDebug.so",
  62. }
  63. configuration { "android*" ,"Release"}
  64. linkoptions {
  65. "-Wl,-soname,libbgfx-shared-libRelease.so",
  66. }
  67. configuration {}
  68. else
  69. configuration { "android*" }
  70. linkoptions {
  71. "-Wl,--fix-cortex-a8",
  72. }
  73. configuration {}
  74. end
  75. includedirs {
  76. path.join(BGFX_DIR, "3rdparty"),
  77. path.join(BIMG_DIR, "include"),
  78. }
  79. defines (_defines)
  80. using_bx()
  81. if _OPTIONS["with-glfw"] then
  82. defines {
  83. "BGFX_CONFIG_MULTITHREADED=0",
  84. }
  85. end
  86. configuration { "linux-*" }
  87. includedirs {
  88. path.join(BGFX_DIR, "3rdparty/directx-headers/include/directx"),
  89. path.join(BGFX_DIR, "3rdparty/directx-headers/include"),
  90. path.join(BGFX_DIR, "3rdparty/directx-headers/include/wsl/stubs"),
  91. }
  92. configuration { "vs* or mingw*", "not durango" }
  93. includedirs {
  94. path.join(BGFX_DIR, "3rdparty/directx-headers/include/directx"),
  95. }
  96. configuration { "android*" }
  97. links {
  98. "EGL",
  99. "GLESv2",
  100. }
  101. configuration { "winstore*" }
  102. linkoptions {
  103. "/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
  104. }
  105. configuration { "*clang*" }
  106. buildoptions {
  107. "-Wno-microsoft-enum-value", -- enumerator value is not representable in the underlying type 'int'
  108. "-Wno-microsoft-const-init", -- default initialization of an object of const type '' without a user-provided default constructor is a Microsoft extension
  109. }
  110. configuration { "osx*" }
  111. buildoptions { "-x objective-c++" } -- additional build option for osx
  112. linkoptions {
  113. "-framework Cocoa",
  114. "-framework IOKit",
  115. "-framework OpenGL",
  116. "-framework QuartzCore",
  117. "-weak_framework Metal",
  118. "-weak_framework MetalKit",
  119. }
  120. configuration { "not NX32", "not NX64" }
  121. includedirs {
  122. -- NX has EGL headers modified...
  123. path.join(BGFX_DIR, "3rdparty/khronos"),
  124. }
  125. configuration {}
  126. includedirs {
  127. path.join(BGFX_DIR, "include"),
  128. }
  129. files {
  130. path.join(BGFX_DIR, "include/**.h"),
  131. path.join(BGFX_DIR, "src/**.cpp"),
  132. path.join(BGFX_DIR, "src/**.h"),
  133. path.join(BGFX_DIR, "scripts/**.natvis"),
  134. }
  135. removefiles {
  136. path.join(BGFX_DIR, "src/**.bin.h"),
  137. }
  138. overridefiles(BGFX_DIR, path.join(BGFX_DIR, "../bgfx-agc"), {
  139. path.join(BGFX_DIR, "src/renderer_agc.cpp"),
  140. path.join(BGFX_DIR, "src/renderer_agc.h"),
  141. })
  142. overridefiles(BGFX_DIR, path.join(BGFX_DIR, "../bgfx-gnm"), {
  143. path.join(BGFX_DIR, "src/renderer_gnm.cpp"),
  144. path.join(BGFX_DIR, "src/renderer_gnm.h"),
  145. })
  146. overridefiles(BGFX_DIR, path.join(BGFX_DIR, "../bgfx-nvn"), {
  147. path.join(BGFX_DIR, "src/renderer_nvn.cpp"),
  148. path.join(BGFX_DIR, "src/renderer_nvn.h"),
  149. })
  150. if _OPTIONS["with-amalgamated"] then
  151. excludes {
  152. path.join(BGFX_DIR, "src/bgfx.cpp"),
  153. path.join(BGFX_DIR, "src/debug_**.cpp"),
  154. path.join(BGFX_DIR, "src/dxgi.cpp"),
  155. path.join(BGFX_DIR, "src/glcontext_**.cpp"),
  156. path.join(BGFX_DIR, "src/hmd**.cpp"),
  157. path.join(BGFX_DIR, "src/image.cpp"),
  158. path.join(BGFX_DIR, "src/nvapi.cpp"),
  159. path.join(BGFX_DIR, "src/renderer_**.cpp"),
  160. path.join(BGFX_DIR, "src/shader**.cpp"),
  161. path.join(BGFX_DIR, "src/topology.cpp"),
  162. path.join(BGFX_DIR, "src/vertexlayout.cpp"),
  163. }
  164. configuration { "xcode* or osx* or ios*" }
  165. files {
  166. path.join(BGFX_DIR, "src/amalgamated.mm"),
  167. }
  168. excludes {
  169. path.join(BGFX_DIR, "src/renderer_**.mm"),
  170. path.join(BGFX_DIR, "src/amalgamated.cpp"),
  171. }
  172. configuration { "not (xcode* or osx* or ios*)" }
  173. excludes {
  174. path.join(BGFX_DIR, "src/**.mm"),
  175. }
  176. configuration {}
  177. else
  178. configuration { "xcode* or osx* or ios*" }
  179. files {
  180. path.join(BGFX_DIR, "src/renderer_**.mm"),
  181. }
  182. configuration {}
  183. excludes {
  184. path.join(BGFX_DIR, "src/amalgamated.**"),
  185. }
  186. end
  187. if filesexist(BGFX_DIR, path.join(BGFX_DIR, "../bgfx-gnm"), {
  188. path.join(BGFX_DIR, "scripts/bgfx.lua"), }) then
  189. dofile(path.join(BGFX_DIR, "../bgfx-gnm/scripts/bgfx.lua") )
  190. end
  191. if filesexist(BGFX_DIR, path.join(BGFX_DIR, "../bgfx-nvn"), {
  192. path.join(BGFX_DIR, "scripts/bgfx.lua"), }) then
  193. dofile(path.join(BGFX_DIR, "../bgfx-nvn/scripts/bgfx.lua") )
  194. end
  195. configuration {}
  196. end
  197. function bgfxProject(_name, _kind, _defines)
  198. project ("bgfx" .. _name)
  199. uuid (os.uuid("bgfx" .. _name))
  200. bgfxProjectBase(_kind, _defines)
  201. copyLib()
  202. end