bgfx.lua 4.9 KB

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