genie.lua 8.7 KB

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