bgfx.lua 4.7 KB

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