genie.lua 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  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. debugdir (path.join(BGFX_DIR, "examples/runtime"))
  74. includedirs {
  75. path.join(BX_DIR, "include"),
  76. path.join(BGFX_DIR, "include"),
  77. path.join(BGFX_DIR, "3rdparty"),
  78. path.join(BGFX_DIR, "examples/common"),
  79. }
  80. files {
  81. path.join(BGFX_DIR, "examples", _name, "**.c"),
  82. path.join(BGFX_DIR, "examples", _name, "**.cpp"),
  83. path.join(BGFX_DIR, "examples", _name, "**.h"),
  84. }
  85. removefiles {
  86. path.join(BGFX_DIR, "examples", _name, "**.bin.h"),
  87. }
  88. links {
  89. "bgfx",
  90. "example-common",
  91. }
  92. if _OPTIONS["with-sdl"] then
  93. defines { "ENTRY_CONFIG_USE_SDL=1" }
  94. links { "SDL2" }
  95. configuration { "x32", "windows" }
  96. libdirs { "$(SDL2_DIR)/lib/x86" }
  97. configuration { "x64", "windows" }
  98. libdirs { "$(SDL2_DIR)/lib/x64" }
  99. configuration {}
  100. end
  101. if _OPTIONS["with-glfw"] then
  102. defines { "ENTRY_CONFIG_USE_GLFW=1" }
  103. links {
  104. "glfw3"
  105. }
  106. configuration { "linux or freebsd" }
  107. links {
  108. "Xrandr",
  109. "Xinerama",
  110. "Xi",
  111. "Xxf86vm",
  112. "Xcursor",
  113. }
  114. configuration { "osx" }
  115. linkoptions {
  116. "-framework CoreVideo",
  117. "-framework IOKit",
  118. }
  119. configuration {}
  120. end
  121. if _OPTIONS["with-ovr"] then
  122. links {
  123. "winmm",
  124. "ws2_32",
  125. }
  126. -- Check for LibOVR 5.0+
  127. if os.isdir(path.join(os.getenv("OVR_DIR"), "LibOVR/Lib/Windows/Win32/Debug/VS2012")) then
  128. configuration { "x32", "Debug" }
  129. libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Windows/Win32/Debug", _ACTION) }
  130. configuration { "x32", "Release" }
  131. libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Windows/Win32/Release", _ACTION) }
  132. configuration { "x64", "Debug" }
  133. libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Windows/x64/Debug", _ACTION) }
  134. configuration { "x64", "Release" }
  135. libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Windows/x64/Release", _ACTION) }
  136. configuration { "x32 or x64" }
  137. links { "libovr" }
  138. else
  139. configuration { "x32" }
  140. libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Win32", _ACTION) }
  141. configuration { "x64" }
  142. libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/x64", _ACTION) }
  143. configuration { "x32", "Debug" }
  144. links { "libovrd" }
  145. configuration { "x32", "Release" }
  146. links { "libovr" }
  147. configuration { "x64", "Debug" }
  148. links { "libovr64d" }
  149. configuration { "x64", "Release" }
  150. links { "libovr64" }
  151. end
  152. configuration {}
  153. end
  154. configuration { "vs*" }
  155. linkoptions {
  156. "/ignore:4199", -- LNK4199: /DELAYLOAD:*.dll ignored; no imports found from *.dll
  157. }
  158. links { -- this is needed only for testing with GLES2/3 on Windows with VS2008
  159. "DelayImp",
  160. }
  161. configuration { "vs201*" }
  162. linkoptions { -- this is needed only for testing with GLES2/3 on Windows with VS201x
  163. "/DELAYLOAD:\"libEGL.dll\"",
  164. "/DELAYLOAD:\"libGLESv2.dll\"",
  165. }
  166. configuration { "mingw*" }
  167. targetextension ".exe"
  168. configuration { "vs20* or mingw*" }
  169. links {
  170. "gdi32",
  171. "psapi",
  172. }
  173. configuration { "winphone8* or winstore8*" }
  174. removelinks {
  175. "DelayImp",
  176. "gdi32",
  177. "psapi"
  178. }
  179. links {
  180. "d3d11",
  181. "dxgi"
  182. }
  183. linkoptions {
  184. "/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
  185. }
  186. -- WinRT targets need their own output directories or build files stomp over each other
  187. configuration { "x32", "winphone8* or winstore8*" }
  188. targetdir (path.join(BGFX_BUILD_DIR, "win32_" .. _ACTION, "bin", _name))
  189. objdir (path.join(BGFX_BUILD_DIR, "win32_" .. _ACTION, "obj", _name))
  190. configuration { "x64", "winphone8* or winstore8*" }
  191. targetdir (path.join(BGFX_BUILD_DIR, "win64_" .. _ACTION, "bin", _name))
  192. objdir (path.join(BGFX_BUILD_DIR, "win64_" .. _ACTION, "obj", _name))
  193. configuration { "ARM", "winphone8* or winstore8*" }
  194. targetdir (path.join(BGFX_BUILD_DIR, "arm_" .. _ACTION, "bin", _name))
  195. objdir (path.join(BGFX_BUILD_DIR, "arm_" .. _ACTION, "obj", _name))
  196. configuration { "mingw-clang" }
  197. kind "ConsoleApp"
  198. configuration { "android*" }
  199. kind "ConsoleApp"
  200. targetextension ".so"
  201. linkoptions {
  202. "-shared",
  203. }
  204. links {
  205. "EGL",
  206. "GLESv2",
  207. }
  208. configuration { "nacl*" }
  209. kind "ConsoleApp"
  210. targetextension ".nexe"
  211. links {
  212. "ppapi",
  213. "ppapi_gles2",
  214. "pthread",
  215. }
  216. configuration { "pnacl" }
  217. kind "ConsoleApp"
  218. targetextension ".pexe"
  219. links {
  220. "ppapi",
  221. "ppapi_gles2",
  222. "pthread",
  223. }
  224. configuration { "asmjs" }
  225. kind "ConsoleApp"
  226. targetextension ".bc"
  227. configuration { "linux-* or freebsd" }
  228. links {
  229. "X11",
  230. "GL",
  231. "pthread",
  232. }
  233. configuration { "rpi" }
  234. links {
  235. "X11",
  236. "GLESv2",
  237. "EGL",
  238. "bcm_host",
  239. "vcos",
  240. "vchiq_arm",
  241. "pthread",
  242. }
  243. configuration { "osx" }
  244. files {
  245. path.join(BGFX_DIR, "examples/common/**.mm"),
  246. }
  247. links {
  248. "Cocoa.framework",
  249. "OpenGL.framework",
  250. }
  251. configuration { "ios*" }
  252. kind "ConsoleApp"
  253. files {
  254. path.join(BGFX_DIR, "examples/common/**.mm"),
  255. }
  256. linkoptions {
  257. "-framework CoreFoundation",
  258. "-framework Foundation",
  259. "-framework OpenGLES",
  260. "-framework UIKit",
  261. "-framework QuartzCore",
  262. }
  263. configuration { "xcode4", "ios" }
  264. kind "WindowedApp"
  265. files {
  266. path.join(BGFX_DIR, "examples/runtime/iOS-Info.plist"),
  267. }
  268. configuration { "qnx*" }
  269. targetextension ""
  270. links {
  271. "EGL",
  272. "GLESv2",
  273. }
  274. configuration {}
  275. strip()
  276. end
  277. dofile "bgfx.lua"
  278. group "examples"
  279. dofile "example-common.lua"
  280. group "libs"
  281. bgfxProject("", "StaticLib", {})
  282. group "examples"
  283. exampleProject("00-helloworld")
  284. exampleProject("01-cubes")
  285. exampleProject("02-metaballs")
  286. exampleProject("03-raymarch")
  287. exampleProject("04-mesh")
  288. exampleProject("05-instancing")
  289. exampleProject("06-bump")
  290. exampleProject("07-callback")
  291. exampleProject("08-update")
  292. exampleProject("09-hdr")
  293. exampleProject("10-font")
  294. exampleProject("11-fontsdf")
  295. exampleProject("12-lod")
  296. exampleProject("13-stencil")
  297. exampleProject("14-shadowvolumes")
  298. exampleProject("15-shadowmaps-simple")
  299. exampleProject("16-shadowmaps")
  300. exampleProject("17-drawstress")
  301. exampleProject("18-ibl")
  302. exampleProject("19-oit")
  303. exampleProject("20-nanovg")
  304. exampleProject("21-deferred")
  305. exampleProject("22-windows")
  306. exampleProject("23-vectordisplay")
  307. exampleProject("24-nbody")
  308. -- C99 source doesn't compile under WinRT settings
  309. if not premake.vstudio.iswinrt() then
  310. exampleProject("25-c99")
  311. end
  312. if _OPTIONS["with-shared-lib"] then
  313. group "libs"
  314. bgfxProject("-shared-lib", "SharedLib", {})
  315. end
  316. if _OPTIONS["with-tools"] then
  317. group "tools"
  318. dofile "makedisttex.lua"
  319. dofile "shaderc.lua"
  320. dofile "texturec.lua"
  321. dofile "geometryc.lua"
  322. end