bgfx.lua 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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(BGFX_DIR, "3rdparty/dxsdk/include"),
  64. path.join(BX_DIR, "include"),
  65. path.join(BIMG_DIR, "include"),
  66. }
  67. defines {
  68. _defines,
  69. }
  70. links {
  71. "bx",
  72. }
  73. if _OPTIONS["with-glfw"] then
  74. defines {
  75. "BGFX_CONFIG_MULTITHREADED=0",
  76. }
  77. end
  78. if _OPTIONS["with-ovr"] then
  79. defines {
  80. -- "BGFX_CONFIG_MULTITHREADED=0",
  81. "BGFX_CONFIG_USE_OVR=1",
  82. }
  83. includedirs {
  84. "$(OVR_DIR)/LibOVR/Include",
  85. }
  86. configuration { "x32" }
  87. libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Windows/Win32/Release", _ACTION) }
  88. configuration { "x64" }
  89. libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Windows/x64/Release", _ACTION) }
  90. configuration { "x32 or x64" }
  91. links { "libovr" }
  92. configuration {}
  93. end
  94. configuration { "Debug" }
  95. defines {
  96. "BGFX_CONFIG_DEBUG=1",
  97. }
  98. configuration { "android*" }
  99. links {
  100. "EGL",
  101. "GLESv2",
  102. }
  103. configuration { "winstore*" }
  104. linkoptions {
  105. "/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
  106. }
  107. configuration { "*clang*" }
  108. buildoptions {
  109. "-Wno-microsoft-enum-value", -- enumerator value is not representable in the underlying type 'int'
  110. "-Wno-microsoft-const-init", -- default initialization of an object of const type '' without a user-provided default constructor is a Microsoft extension
  111. }
  112. configuration { "osx" }
  113. linkoptions {
  114. "-framework Cocoa",
  115. "-framework QuartzCore",
  116. "-framework OpenGL",
  117. "-weak_framework Metal",
  118. "-weak_framework MetalKit",
  119. }
  120. configuration { "not linux-steamlink", "not NX32", "not NX64" }
  121. includedirs {
  122. -- steamlink has EGL headers modified...
  123. -- NX has EGL headers modified...
  124. path.join(BGFX_DIR, "3rdparty/khronos"),
  125. }
  126. configuration { "linux-steamlink" }
  127. defines {
  128. "EGL_API_FB",
  129. }
  130. configuration {}
  131. includedirs {
  132. path.join(BGFX_DIR, "include"),
  133. }
  134. files {
  135. path.join(BGFX_DIR, "include/**.h"),
  136. path.join(BGFX_DIR, "src/**.cpp"),
  137. path.join(BGFX_DIR, "src/**.h"),
  138. }
  139. removefiles {
  140. path.join(BGFX_DIR, "src/**.bin.h"),
  141. }
  142. overridefiles(BGFX_DIR, path.join(BGFX_DIR, "../bgfx-ext"), {
  143. path.join(BGFX_DIR, "src/renderer_gnm.cpp"),
  144. path.join(BGFX_DIR, "src/renderer_gnm.h"),
  145. })
  146. if _OPTIONS["with-amalgamated"] then
  147. excludes {
  148. path.join(BGFX_DIR, "src/bgfx.cpp"),
  149. path.join(BGFX_DIR, "src/debug_**.cpp"),
  150. path.join(BGFX_DIR, "src/glcontext_**.cpp"),
  151. path.join(BGFX_DIR, "src/image.cpp"),
  152. path.join(BGFX_DIR, "src/hmd**.cpp"),
  153. path.join(BGFX_DIR, "src/renderer_**.cpp"),
  154. path.join(BGFX_DIR, "src/shader**.cpp"),
  155. path.join(BGFX_DIR, "src/topology.cpp"),
  156. path.join(BGFX_DIR, "src/vertexdecl.cpp"),
  157. }
  158. configuration { "xcode* or osx or ios*" }
  159. files {
  160. path.join(BGFX_DIR, "src/amalgamated.mm"),
  161. }
  162. excludes {
  163. path.join(BGFX_DIR, "src/glcontext_**.mm"),
  164. path.join(BGFX_DIR, "src/renderer_**.mm"),
  165. path.join(BGFX_DIR, "src/amalgamated.cpp"),
  166. }
  167. configuration { "not (xcode* or osx or ios*)" }
  168. excludes {
  169. path.join(BGFX_DIR, "src/**.mm"),
  170. }
  171. configuration {}
  172. else
  173. configuration { "xcode* or osx or ios*" }
  174. files {
  175. path.join(BGFX_DIR, "src/glcontext_**.mm"),
  176. path.join(BGFX_DIR, "src/renderer_**.mm"),
  177. }
  178. configuration {}
  179. excludes {
  180. path.join(BGFX_DIR, "src/amalgamated.**"),
  181. }
  182. end
  183. configuration {}
  184. end