genie.lua 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  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 or freebsd" }
  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. -- Check for LibOVR 5.0+
  130. if os.isdir(path.join(os.getenv("OVR_DIR"), "LibOVR/Lib/Windows/Win32/Debug/VS2012")) then
  131. configuration { "x32", "Debug" }
  132. libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Windows/Win32/Debug", _ACTION) }
  133. configuration { "x32", "Release" }
  134. libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Windows/Win32/Release", _ACTION) }
  135. configuration { "x64", "Debug" }
  136. libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Windows/x64/Debug", _ACTION) }
  137. configuration { "x64", "Release" }
  138. libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Windows/x64/Release", _ACTION) }
  139. configuration { "x32 or x64" }
  140. links { "libovr" }
  141. else
  142. configuration { "x32" }
  143. libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Win32", _ACTION) }
  144. configuration { "x64" }
  145. libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/x64", _ACTION) }
  146. configuration { "x32", "Debug" }
  147. links { "libovrd" }
  148. configuration { "x32", "Release" }
  149. links { "libovr" }
  150. configuration { "x64", "Debug" }
  151. links { "libovr64d" }
  152. configuration { "x64", "Release" }
  153. links { "libovr64" }
  154. end
  155. configuration {}
  156. end
  157. configuration { "vs*" }
  158. linkoptions {
  159. "/ignore:4199", -- LNK4199: /DELAYLOAD:*.dll ignored; no imports found from *.dll
  160. }
  161. links { -- this is needed only for testing with GLES2/3 on Windows with VS2008
  162. "DelayImp",
  163. }
  164. configuration { "vs201*" }
  165. linkoptions { -- this is needed only for testing with GLES2/3 on Windows with VS201x
  166. "/DELAYLOAD:\"libEGL.dll\"",
  167. "/DELAYLOAD:\"libGLESv2.dll\"",
  168. }
  169. configuration { "mingw*" }
  170. targetextension ".exe"
  171. configuration { "vs20* or mingw*" }
  172. links {
  173. "gdi32",
  174. "psapi",
  175. }
  176. configuration { "winphone8*"}
  177. removelinks {
  178. "DelayImp",
  179. "gdi32",
  180. "psapi"
  181. }
  182. links {
  183. "d3d11",
  184. "dxgi"
  185. }
  186. linkoptions {
  187. "/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
  188. }
  189. -- WinRT targets need their own output directories are build files stomp over each other
  190. targetdir (path.join(BGFX_BUILD_DIR, "arm_" .. _ACTION, "bin", _name))
  191. objdir (path.join(BGFX_BUILD_DIR, "arm_" .. _ACTION, "obj", _name))
  192. configuration { "mingw-clang" }
  193. kind "ConsoleApp"
  194. configuration { "android*" }
  195. kind "ConsoleApp"
  196. targetextension ".so"
  197. linkoptions {
  198. "-shared",
  199. }
  200. links {
  201. "EGL",
  202. "GLESv2",
  203. }
  204. configuration { "nacl*" }
  205. kind "ConsoleApp"
  206. targetextension ".nexe"
  207. links {
  208. "ppapi",
  209. "ppapi_gles2",
  210. "pthread",
  211. }
  212. configuration { "pnacl" }
  213. kind "ConsoleApp"
  214. targetextension ".pexe"
  215. links {
  216. "ppapi",
  217. "ppapi_gles2",
  218. "pthread",
  219. }
  220. configuration { "asmjs" }
  221. kind "ConsoleApp"
  222. targetextension ".bc"
  223. configuration { "linux-* or freebsd" }
  224. links {
  225. "X11",
  226. "GL",
  227. "pthread",
  228. }
  229. configuration { "rpi" }
  230. links {
  231. "X11",
  232. "GLESv2",
  233. "EGL",
  234. "bcm_host",
  235. "vcos",
  236. "vchiq_arm",
  237. "pthread",
  238. }
  239. configuration { "osx" }
  240. files {
  241. path.join(BGFX_DIR, "examples/common/**.mm"),
  242. }
  243. links {
  244. "Cocoa.framework",
  245. "OpenGL.framework",
  246. }
  247. configuration { "ios*" }
  248. kind "ConsoleApp"
  249. files {
  250. path.join(BGFX_DIR, "examples/common/**.mm"),
  251. }
  252. linkoptions {
  253. "-framework CoreFoundation",
  254. "-framework Foundation",
  255. "-framework OpenGLES",
  256. "-framework UIKit",
  257. "-framework QuartzCore",
  258. }
  259. configuration { "xcode4", "ios" }
  260. kind "WindowedApp"
  261. files {
  262. path.join(BGFX_DIR, "examples/runtime/iOS-Info.plist"),
  263. }
  264. configuration { "qnx*" }
  265. targetextension ""
  266. links {
  267. "EGL",
  268. "GLESv2",
  269. }
  270. configuration {}
  271. strip()
  272. end
  273. dofile "bgfx.lua"
  274. group "examples"
  275. dofile "example-common.lua"
  276. group "libs"
  277. bgfxProject("", "StaticLib", {})
  278. group "examples"
  279. exampleProject("00-helloworld")
  280. exampleProject("01-cubes")
  281. exampleProject("02-metaballs")
  282. exampleProject("03-raymarch")
  283. exampleProject("04-mesh")
  284. exampleProject("05-instancing")
  285. exampleProject("06-bump")
  286. exampleProject("07-callback")
  287. exampleProject("08-update")
  288. exampleProject("09-hdr")
  289. exampleProject("10-font")
  290. exampleProject("11-fontsdf")
  291. exampleProject("12-lod")
  292. exampleProject("13-stencil")
  293. exampleProject("14-shadowvolumes")
  294. exampleProject("15-shadowmaps-simple")
  295. exampleProject("16-shadowmaps")
  296. exampleProject("17-drawstress")
  297. exampleProject("18-ibl")
  298. exampleProject("19-oit")
  299. exampleProject("20-nanovg")
  300. exampleProject("21-deferred")
  301. exampleProject("22-windows")
  302. exampleProject("23-vectordisplay")
  303. exampleProject("24-nbody")
  304. exampleProject("25-c99")
  305. if _OPTIONS["with-shared-lib"] then
  306. group "libs"
  307. bgfxProject("-shared-lib", "SharedLib", {})
  308. end
  309. if _OPTIONS["with-tools"] then
  310. group "tools"
  311. dofile "makedisttex.lua"
  312. dofile "shaderc.lua"
  313. dofile "texturec.lua"
  314. dofile "geometryc.lua"
  315. end