bgfx.lua 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. --
  2. -- Copyright 2010-2016 Branimir Karadzic. All rights reserved.
  3. -- License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
  4. --
  5. function overridefiles(_srcPath, _dstPath, _files)
  6. local remove = {}
  7. local add = {}
  8. for _, file in ipairs(_files) do
  9. file = path.getrelative(_srcPath, file)
  10. local filePath = path.join(BGFX_DIR, "../bgfx-ext", file)
  11. if not os.isfile(filePath) then print(filePath .. " not found") return end
  12. table.insert(remove, path.join(_srcPath, file))
  13. table.insert(add, filePath)
  14. end
  15. removefiles {
  16. remove,
  17. }
  18. files {
  19. add,
  20. }
  21. end
  22. function bgfxProject(_name, _kind, _defines)
  23. project ("bgfx" .. _name)
  24. uuid (os.uuid("bgfx" .. _name))
  25. kind (_kind)
  26. if _kind == "SharedLib" then
  27. defines {
  28. "BGFX_SHARED_LIB_BUILD=1",
  29. }
  30. configuration { "vs20* or mingw*" }
  31. links {
  32. "gdi32",
  33. "psapi",
  34. }
  35. configuration { "mingw*" }
  36. linkoptions {
  37. "-shared",
  38. }
  39. configuration { "linux-*" }
  40. buildoptions {
  41. "-fPIC",
  42. }
  43. configuration {}
  44. end
  45. includedirs {
  46. path.join(BGFX_DIR, "3rdparty"),
  47. path.join(BGFX_DIR, "3rdparty/dxsdk/include"),
  48. path.join(BX_DIR, "include"),
  49. }
  50. defines {
  51. _defines,
  52. }
  53. if _OPTIONS["with-glfw"] then
  54. defines {
  55. "BGFX_CONFIG_MULTITHREADED=0",
  56. }
  57. end
  58. if _OPTIONS["with-ovr"] then
  59. defines {
  60. -- "BGFX_CONFIG_MULTITHREADED=0",
  61. "BGFX_CONFIG_USE_OVR=1",
  62. }
  63. includedirs {
  64. "$(OVR_DIR)/LibOVR/Include",
  65. }
  66. configuration { "x32" }
  67. libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Windows/Win32/Release", _ACTION) }
  68. configuration { "x64" }
  69. libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Windows/x64/Release", _ACTION) }
  70. configuration { "x32 or x64" }
  71. links { "libovr" }
  72. configuration {}
  73. end
  74. configuration { "Debug" }
  75. defines {
  76. "BGFX_CONFIG_DEBUG=1",
  77. }
  78. configuration { "android*" }
  79. links {
  80. "EGL",
  81. "GLESv2",
  82. }
  83. configuration { "winphone8* or winstore8*" }
  84. linkoptions {
  85. "/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
  86. }
  87. configuration { "*clang*" }
  88. buildoptions {
  89. "-Wno-microsoft-enum-value", -- enumerator value is not representable in the underlying type 'int'
  90. "-Wno-microsoft-const-init", -- default initialization of an object of const type '' without a user-provided default constructor is a Microsoft extension
  91. }
  92. configuration { "osx" }
  93. linkoptions {
  94. "-framework Cocoa",
  95. "-framework QuartzCore",
  96. "-framework OpenGL",
  97. "-weak_framework Metal",
  98. "-weak_framework MetalKit",
  99. }
  100. configuration { "not nacl", "not linux-steamlink" }
  101. includedirs {
  102. --nacl has GLES2 headers modified...
  103. --steamlink has EGL headers modified...
  104. path.join(BGFX_DIR, "3rdparty/khronos"),
  105. }
  106. configuration { "linux-steamlink" }
  107. defines {
  108. "EGL_API_FB",
  109. }
  110. configuration {}
  111. includedirs {
  112. path.join(BGFX_DIR, "include"),
  113. }
  114. files {
  115. path.join(BGFX_DIR, "include/**.h"),
  116. path.join(BGFX_DIR, "src/**.cpp"),
  117. path.join(BGFX_DIR, "src/**.h"),
  118. }
  119. removefiles {
  120. path.join(BGFX_DIR, "src/**.bin.h"),
  121. }
  122. overridefiles(BGFX_DIR, path.join(BGFX_DIR, "../bgfx-ext"), {
  123. path.join(BGFX_DIR, "src/renderer_vk.cpp"),
  124. path.join(BGFX_DIR, "src/renderer_vk.h"),
  125. })
  126. overridefiles(BGFX_DIR, path.join(BGFX_DIR, "../bgfx-ext"), {
  127. path.join(BGFX_DIR, "src/renderer_gnm.cpp"),
  128. path.join(BGFX_DIR, "src/renderer_gnm.h"),
  129. })
  130. if _OPTIONS["with-amalgamated"] then
  131. excludes {
  132. path.join(BGFX_DIR, "src/bgfx.cpp"),
  133. path.join(BGFX_DIR, "src/debug_**.cpp"),
  134. path.join(BGFX_DIR, "src/glcontext_**.cpp"),
  135. path.join(BGFX_DIR, "src/image.cpp"),
  136. path.join(BGFX_DIR, "src/hmd**.cpp"),
  137. path.join(BGFX_DIR, "src/renderer_**.cpp"),
  138. path.join(BGFX_DIR, "src/shader**.cpp"),
  139. path.join(BGFX_DIR, "src/topology.cpp"),
  140. path.join(BGFX_DIR, "src/vertexdecl.cpp"),
  141. }
  142. configuration { "xcode* or osx or ios*" }
  143. files {
  144. path.join(BGFX_DIR, "src/amalgamated.mm"),
  145. }
  146. excludes {
  147. path.join(BGFX_DIR, "src/glcontext_**.mm"),
  148. path.join(BGFX_DIR, "src/renderer_**.mm"),
  149. path.join(BGFX_DIR, "src/amalgamated.cpp"),
  150. }
  151. configuration { "not (xcode* or osx or ios*)" }
  152. excludes {
  153. path.join(BGFX_DIR, "src/**.mm"),
  154. }
  155. configuration {}
  156. else
  157. configuration { "xcode* or osx or ios*" }
  158. files {
  159. path.join(BGFX_DIR, "src/glcontext_**.mm"),
  160. path.join(BGFX_DIR, "src/renderer_**.mm"),
  161. }
  162. configuration {}
  163. excludes {
  164. path.join(BGFX_DIR, "src/amalgamated.**"),
  165. }
  166. end
  167. configuration {}
  168. copyLib()
  169. end