bgfx.lua 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  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" }
  117. includedirs {
  118. --nacl has GLES2 headers modified...
  119. --steamlink has EGL headers modified...
  120. path.join(BGFX_DIR, "3rdparty/khronos"),
  121. }
  122. configuration { "linux-steamlink" }
  123. defines {
  124. "EGL_API_FB",
  125. }
  126. configuration {}
  127. includedirs {
  128. path.join(BGFX_DIR, "include"),
  129. }
  130. files {
  131. path.join(BGFX_DIR, "include/**.h"),
  132. path.join(BGFX_DIR, "src/**.cpp"),
  133. path.join(BGFX_DIR, "src/**.h"),
  134. }
  135. removefiles {
  136. path.join(BGFX_DIR, "src/**.bin.h"),
  137. }
  138. overridefiles(BGFX_DIR, path.join(BGFX_DIR, "../bgfx-ext"), {
  139. path.join(BGFX_DIR, "src/renderer_gnm.cpp"),
  140. path.join(BGFX_DIR, "src/renderer_gnm.h"),
  141. })
  142. if _OPTIONS["with-amalgamated"] then
  143. excludes {
  144. path.join(BGFX_DIR, "src/bgfx.cpp"),
  145. path.join(BGFX_DIR, "src/debug_**.cpp"),
  146. path.join(BGFX_DIR, "src/glcontext_**.cpp"),
  147. path.join(BGFX_DIR, "src/image.cpp"),
  148. path.join(BGFX_DIR, "src/hmd**.cpp"),
  149. path.join(BGFX_DIR, "src/renderer_**.cpp"),
  150. path.join(BGFX_DIR, "src/shader**.cpp"),
  151. path.join(BGFX_DIR, "src/topology.cpp"),
  152. path.join(BGFX_DIR, "src/vertexdecl.cpp"),
  153. }
  154. configuration { "xcode* or osx or ios*" }
  155. files {
  156. path.join(BGFX_DIR, "src/amalgamated.mm"),
  157. }
  158. excludes {
  159. path.join(BGFX_DIR, "src/glcontext_**.mm"),
  160. path.join(BGFX_DIR, "src/renderer_**.mm"),
  161. path.join(BGFX_DIR, "src/amalgamated.cpp"),
  162. }
  163. configuration { "not (xcode* or osx or ios*)" }
  164. excludes {
  165. path.join(BGFX_DIR, "src/**.mm"),
  166. }
  167. configuration {}
  168. else
  169. configuration { "xcode* or osx or ios*" }
  170. files {
  171. path.join(BGFX_DIR, "src/glcontext_**.mm"),
  172. path.join(BGFX_DIR, "src/renderer_**.mm"),
  173. }
  174. configuration {}
  175. excludes {
  176. path.join(BGFX_DIR, "src/amalgamated.**"),
  177. }
  178. end
  179. configuration {}
  180. copyLib()
  181. end