bgfx.lua 4.6 KB

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