bgfx.lua 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. --
  2. -- Copyright 2010-2018 Branimir Karadzic. All rights reserved.
  3. -- License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
  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 bgfxProject(_name, _kind, _defines)
  31. project ("bgfx" .. _name)
  32. uuid (os.uuid("bgfx" .. _name))
  33. bgfxProjectBase(_kind, _defines)
  34. copyLib()
  35. end
  36. function bgfxProjectBase(_kind, _defines)
  37. kind (_kind)
  38. if _kind == "SharedLib" then
  39. defines {
  40. "BGFX_SHARED_LIB_BUILD=1",
  41. }
  42. links {
  43. "bimg",
  44. "bx",
  45. }
  46. configuration { "vs20* or mingw*" }
  47. links {
  48. "gdi32",
  49. "psapi",
  50. }
  51. configuration { "mingw*" }
  52. linkoptions {
  53. "-shared",
  54. }
  55. configuration { "linux-*" }
  56. buildoptions {
  57. "-fPIC",
  58. }
  59. configuration {}
  60. end
  61. includedirs {
  62. path.join(BGFX_DIR, "3rdparty"),
  63. path.join(BX_DIR, "include"),
  64. path.join(BIMG_DIR, "include"),
  65. }
  66. defines {
  67. _defines,
  68. }
  69. links {
  70. "bx",
  71. }
  72. if _OPTIONS["with-glfw"] then
  73. defines {
  74. "BGFX_CONFIG_MULTITHREADED=0",
  75. }
  76. end
  77. if _OPTIONS["with-ovr"] then
  78. defines {
  79. -- "BGFX_CONFIG_MULTITHREADED=0",
  80. "BGFX_CONFIG_USE_OVR=1",
  81. }
  82. includedirs {
  83. "$(OVR_DIR)/LibOVR/Include",
  84. }
  85. configuration { "x32" }
  86. libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Windows/Win32/Release", _ACTION) }
  87. configuration { "x64" }
  88. libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Windows/x64/Release", _ACTION) }
  89. configuration { "x32 or x64" }
  90. links { "libovr" }
  91. configuration {}
  92. end
  93. configuration { "Debug" }
  94. defines {
  95. "BGFX_CONFIG_DEBUG=1",
  96. }
  97. configuration { "vs* or mingw*", "not durango" }
  98. includedirs {
  99. path.join(BGFX_DIR, "3rdparty/dxsdk/include"),
  100. }
  101. configuration { "android*" }
  102. links {
  103. "EGL",
  104. "GLESv2",
  105. }
  106. configuration { "winstore*" }
  107. linkoptions {
  108. "/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
  109. }
  110. configuration { "*clang*" }
  111. buildoptions {
  112. "-Wno-microsoft-enum-value", -- enumerator value is not representable in the underlying type 'int'
  113. "-Wno-microsoft-const-init", -- default initialization of an object of const type '' without a user-provided default constructor is a Microsoft extension
  114. }
  115. configuration { "osx" }
  116. linkoptions {
  117. "-framework Cocoa",
  118. "-framework QuartzCore",
  119. "-framework OpenGL",
  120. "-weak_framework Metal",
  121. "-weak_framework MetalKit",
  122. }
  123. configuration { "not linux-steamlink", "not NX32", "not NX64" }
  124. includedirs {
  125. -- steamlink has EGL headers modified...
  126. -- NX has EGL headers modified...
  127. path.join(BGFX_DIR, "3rdparty/khronos"),
  128. }
  129. configuration { "linux-steamlink" }
  130. defines {
  131. "EGL_API_FB",
  132. }
  133. configuration {}
  134. includedirs {
  135. path.join(BGFX_DIR, "include"),
  136. }
  137. files {
  138. path.join(BGFX_DIR, "include/**.h"),
  139. path.join(BGFX_DIR, "src/**.cpp"),
  140. path.join(BGFX_DIR, "src/**.h"),
  141. path.join(BGFX_DIR, "scripts/**.natvis"),
  142. }
  143. removefiles {
  144. path.join(BGFX_DIR, "src/**.bin.h"),
  145. }
  146. overridefiles(BGFX_DIR, path.join(BGFX_DIR, "../bgfx-ext"), {
  147. path.join(BGFX_DIR, "src/renderer_gnm.cpp"),
  148. path.join(BGFX_DIR, "src/renderer_gnm.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/vertexdecl.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/glcontext_**.mm"),
  170. path.join(BGFX_DIR, "src/renderer_**.mm"),
  171. path.join(BGFX_DIR, "src/amalgamated.cpp"),
  172. }
  173. configuration { "not (xcode* or osx or ios*)" }
  174. excludes {
  175. path.join(BGFX_DIR, "src/**.mm"),
  176. }
  177. configuration {}
  178. else
  179. configuration { "xcode* or osx or ios*" }
  180. files {
  181. path.join(BGFX_DIR, "src/glcontext_**.mm"),
  182. path.join(BGFX_DIR, "src/renderer_**.mm"),
  183. }
  184. configuration {}
  185. excludes {
  186. path.join(BGFX_DIR, "src/amalgamated.**"),
  187. }
  188. end
  189. configuration {}
  190. end