bgfx.lua 4.9 KB

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