genie.lua 8.9 KB

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