genie.lua 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. --
  2. -- Copyright 2010-2015 Branimir Karadzic. All rights reserved.
  3. -- License: http://www.opensource.org/licenses/BSD-2-Clause
  4. --
  5. newoption {
  6. trigger = "with-amalgamated",
  7. description = "Enable amalgamated build.",
  8. }
  9. newoption {
  10. trigger = "with-ovr",
  11. description = "Enable OculusVR integration.",
  12. }
  13. newoption {
  14. trigger = "with-sdl",
  15. description = "Enable SDL entry.",
  16. }
  17. newoption {
  18. trigger = "with-glfw",
  19. description = "Enable GLFW entry.",
  20. }
  21. newoption {
  22. trigger = "with-shared-lib",
  23. description = "Enable building shared library.",
  24. }
  25. newoption {
  26. trigger = "with-tools",
  27. description = "Enable building tools.",
  28. }
  29. solution "bgfx"
  30. configurations {
  31. "Debug",
  32. "Release",
  33. }
  34. if _ACTION == "xcode4" then
  35. platforms {
  36. "Universal",
  37. }
  38. else
  39. platforms {
  40. "x32",
  41. "x64",
  42. -- "Xbox360",
  43. "Native", -- for targets where bitness is not specified
  44. }
  45. end
  46. language "C++"
  47. startproject "example-00-helloworld"
  48. BGFX_DIR = path.getabsolute("..")
  49. local BGFX_BUILD_DIR = path.join(BGFX_DIR, ".build")
  50. local BGFX_THIRD_PARTY_DIR = path.join(BGFX_DIR, "3rdparty")
  51. BX_DIR = path.getabsolute(path.join(BGFX_DIR, "../bx"))
  52. defines {
  53. "BX_CONFIG_ENABLE_MSVC_LEVEL4_WARNINGS=1"
  54. }
  55. dofile (path.join(BX_DIR, "scripts/toolchain.lua"))
  56. if not toolchain(BGFX_BUILD_DIR, BGFX_THIRD_PARTY_DIR) then
  57. return -- no action specified
  58. end
  59. function copyLib()
  60. end
  61. if _OPTIONS["with-sdl"] then
  62. if os.is("windows") then
  63. if not os.getenv("SDL2_DIR") then
  64. print("Set SDL2_DIR enviroment variable.")
  65. end
  66. end
  67. end
  68. function exampleProject(_name)
  69. project ("example-" .. _name)
  70. uuid (os.uuid("example-" .. _name))
  71. kind "WindowedApp"
  72. configuration {}
  73. -- don't output debugdir for winphone builds
  74. if "winphone81" ~= _OPTIONS["vs"] then
  75. debugdir (path.join(BGFX_DIR, "examples/runtime"))
  76. end
  77. includedirs {
  78. path.join(BX_DIR, "include"),
  79. path.join(BGFX_DIR, "include"),
  80. path.join(BGFX_DIR, "3rdparty"),
  81. path.join(BGFX_DIR, "examples/common"),
  82. }
  83. files {
  84. path.join(BGFX_DIR, "examples", _name, "**.c"),
  85. path.join(BGFX_DIR, "examples", _name, "**.cpp"),
  86. path.join(BGFX_DIR, "examples", _name, "**.h"),
  87. }
  88. removefiles {
  89. path.join(BGFX_DIR, "examples", _name, "**.bin.h"),
  90. }
  91. links {
  92. "bgfx",
  93. "example-common",
  94. }
  95. if _OPTIONS["with-sdl"] then
  96. defines { "ENTRY_CONFIG_USE_SDL=1" }
  97. links { "SDL2" }
  98. configuration { "x32", "windows" }
  99. libdirs { "$(SDL2_DIR)/lib/x86" }
  100. configuration { "x64", "windows" }
  101. libdirs { "$(SDL2_DIR)/lib/x64" }
  102. configuration {}
  103. end
  104. if _OPTIONS["with-glfw"] then
  105. defines { "ENTRY_CONFIG_USE_GLFW=1" }
  106. links {
  107. "glfw3"
  108. }
  109. configuration { "linux" }
  110. links {
  111. "Xrandr",
  112. "Xinerama",
  113. "Xi",
  114. "Xxf86vm",
  115. "Xcursor",
  116. }
  117. configuration { "osx" }
  118. linkoptions {
  119. "-framework CoreVideo",
  120. "-framework IOKit",
  121. }
  122. configuration {}
  123. end
  124. if _OPTIONS["with-ovr"] then
  125. links {
  126. "winmm",
  127. "ws2_32",
  128. }
  129. configuration { "x32" }
  130. libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Win32", _ACTION) }
  131. configuration { "x64" }
  132. libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/x64", _ACTION) }
  133. configuration { "x32", "Debug" }
  134. links { "libovrd" }
  135. configuration { "x32", "Release" }
  136. links { "libovr" }
  137. configuration { "x64", "Debug" }
  138. links { "libovr64d" }
  139. configuration { "x64", "Release" }
  140. links { "libovr64" }
  141. configuration {}
  142. end
  143. configuration { "vs*" }
  144. linkoptions {
  145. "/ignore:4199", -- LNK4199: /DELAYLOAD:*.dll ignored; no imports found from *.dll
  146. }
  147. links { -- this is needed only for testing with GLES2/3 on Windows with VS2008
  148. "DelayImp",
  149. }
  150. configuration { "vs201*" }
  151. linkoptions { -- this is needed only for testing with GLES2/3 on Windows with VS201x
  152. "/DELAYLOAD:\"libEGL.dll\"",
  153. "/DELAYLOAD:\"libGLESv2.dll\"",
  154. }
  155. configuration { "mingw*" }
  156. targetextension ".exe"
  157. configuration { "vs20* or mingw*" }
  158. links {
  159. "gdi32",
  160. "psapi",
  161. }
  162. configuration { "winphone8*"}
  163. removelinks {
  164. "DelayImp",
  165. "gdi32",
  166. "psapi"
  167. }
  168. links {
  169. "d3d11",
  170. "dxgi"
  171. }
  172. linkoptions {
  173. "/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
  174. }
  175. -- WinRT targets need their own output directories are build files stomp over each other
  176. targetdir (path.join(BGFX_BUILD_DIR, "arm_" .. _ACTION, "bin", _name))
  177. objdir (path.join(BGFX_BUILD_DIR, "arm_" .. _ACTION, "obj", _name))
  178. configuration { "mingw-clang" }
  179. kind "ConsoleApp"
  180. configuration { "android*" }
  181. kind "ConsoleApp"
  182. targetextension ".so"
  183. linkoptions {
  184. "-shared",
  185. }
  186. links {
  187. "EGL",
  188. "GLESv2",
  189. }
  190. configuration { "nacl*" }
  191. kind "ConsoleApp"
  192. targetextension ".nexe"
  193. links {
  194. "ppapi",
  195. "ppapi_gles2",
  196. "pthread",
  197. }
  198. configuration { "pnacl" }
  199. kind "ConsoleApp"
  200. targetextension ".pexe"
  201. links {
  202. "ppapi",
  203. "ppapi_gles2",
  204. "pthread",
  205. }
  206. configuration { "asmjs" }
  207. kind "ConsoleApp"
  208. targetextension ".bc"
  209. configuration { "linux-*" }
  210. links {
  211. "X11",
  212. "GL",
  213. "pthread",
  214. }
  215. configuration { "rpi" }
  216. links {
  217. "X11",
  218. "GLESv2",
  219. "EGL",
  220. "bcm_host",
  221. "vcos",
  222. "vchiq_arm",
  223. "pthread",
  224. }
  225. configuration { "osx" }
  226. files {
  227. path.join(BGFX_DIR, "examples/common/**.mm"),
  228. }
  229. links {
  230. "Cocoa.framework",
  231. "OpenGL.framework",
  232. }
  233. configuration { "ios*" }
  234. kind "ConsoleApp"
  235. files {
  236. path.join(BGFX_DIR, "examples/common/**.mm"),
  237. }
  238. linkoptions {
  239. "-framework CoreFoundation",
  240. "-framework Foundation",
  241. "-framework OpenGLES",
  242. "-framework UIKit",
  243. "-framework QuartzCore",
  244. }
  245. configuration { "xcode4", "ios" }
  246. kind "WindowedApp"
  247. files {
  248. path.join(BGFX_DIR, "examples/runtime/iOS-Info.plist"),
  249. }
  250. configuration { "qnx*" }
  251. targetextension ""
  252. links {
  253. "EGL",
  254. "GLESv2",
  255. }
  256. configuration {}
  257. strip()
  258. end
  259. dofile "bgfx.lua"
  260. group "examples"
  261. dofile "example-common.lua"
  262. group "libs"
  263. bgfxProject("", "StaticLib", {})
  264. group "examples"
  265. exampleProject("00-helloworld")
  266. exampleProject("01-cubes")
  267. exampleProject("02-metaballs")
  268. exampleProject("03-raymarch")
  269. exampleProject("04-mesh")
  270. exampleProject("05-instancing")
  271. exampleProject("06-bump")
  272. exampleProject("07-callback")
  273. exampleProject("08-update")
  274. exampleProject("09-hdr")
  275. exampleProject("10-font")
  276. exampleProject("11-fontsdf")
  277. exampleProject("12-lod")
  278. exampleProject("13-stencil")
  279. exampleProject("14-shadowvolumes")
  280. exampleProject("15-shadowmaps-simple")
  281. exampleProject("16-shadowmaps")
  282. exampleProject("17-drawstress")
  283. exampleProject("18-ibl")
  284. exampleProject("19-oit")
  285. exampleProject("20-nanovg")
  286. exampleProject("21-deferred")
  287. exampleProject("22-windows")
  288. exampleProject("23-vectordisplay")
  289. exampleProject("24-nbody")
  290. exampleProject("25-c99")
  291. if _OPTIONS["with-shared-lib"] then
  292. group "libs"
  293. bgfxProject("-shared-lib", "SharedLib", {})
  294. end
  295. if _OPTIONS["with-tools"] then
  296. group "tools"
  297. dofile "makedisttex.lua"
  298. dofile "shaderc.lua"
  299. dofile "texturec.lua"
  300. dofile "geometryc.lua"
  301. end