genie.lua 8.2 KB

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