genie.lua 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  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. "d3d12_x",
  200. "combase",
  201. "kernelx",
  202. }
  203. configuration { "winphone8* or winstore8*" }
  204. removelinks {
  205. "DelayImp",
  206. "gdi32",
  207. "psapi"
  208. }
  209. links {
  210. "d3d11",
  211. "dxgi"
  212. }
  213. linkoptions {
  214. "/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
  215. }
  216. -- WinRT targets need their own output directories or build files stomp over each other
  217. configuration { "x32", "winphone8* or winstore8*" }
  218. targetdir (path.join(BGFX_BUILD_DIR, "win32_" .. _ACTION, "bin", _name))
  219. objdir (path.join(BGFX_BUILD_DIR, "win32_" .. _ACTION, "obj", _name))
  220. configuration { "x64", "winphone8* or winstore8*" }
  221. targetdir (path.join(BGFX_BUILD_DIR, "win64_" .. _ACTION, "bin", _name))
  222. objdir (path.join(BGFX_BUILD_DIR, "win64_" .. _ACTION, "obj", _name))
  223. configuration { "ARM", "winphone8* or winstore8*" }
  224. targetdir (path.join(BGFX_BUILD_DIR, "arm_" .. _ACTION, "bin", _name))
  225. objdir (path.join(BGFX_BUILD_DIR, "arm_" .. _ACTION, "obj", _name))
  226. configuration { "mingw-clang" }
  227. kind "ConsoleApp"
  228. configuration { "android*" }
  229. kind "ConsoleApp"
  230. targetextension ".so"
  231. linkoptions {
  232. "-shared",
  233. }
  234. links {
  235. "EGL",
  236. "GLESv2",
  237. }
  238. configuration { "nacl*" }
  239. kind "ConsoleApp"
  240. targetextension ".nexe"
  241. links {
  242. "ppapi",
  243. "ppapi_gles2",
  244. "pthread",
  245. }
  246. configuration { "pnacl" }
  247. kind "ConsoleApp"
  248. targetextension ".pexe"
  249. links {
  250. "ppapi",
  251. "ppapi_gles2",
  252. "pthread",
  253. }
  254. configuration { "asmjs" }
  255. kind "ConsoleApp"
  256. targetextension ".bc"
  257. configuration { "linux-* or freebsd", "not linux-steamlink" }
  258. links {
  259. "X11",
  260. "GL",
  261. "pthread",
  262. }
  263. configuration { "linux-steamlink" }
  264. links {
  265. "EGL",
  266. "GLESv2",
  267. "SDL2",
  268. "pthread",
  269. }
  270. configuration { "rpi" }
  271. links {
  272. "X11",
  273. "GLESv2",
  274. "EGL",
  275. "bcm_host",
  276. "vcos",
  277. "vchiq_arm",
  278. "pthread",
  279. }
  280. configuration { "osx" }
  281. linkoptions {
  282. "-framework Cocoa",
  283. "-framework QuartzCore",
  284. "-framework OpenGL",
  285. "-weak_framework Metal",
  286. }
  287. configuration { "ios* or tvos*" }
  288. kind "ConsoleApp"
  289. linkoptions {
  290. "-framework CoreFoundation",
  291. "-framework Foundation",
  292. "-framework OpenGLES",
  293. "-framework UIKit",
  294. "-framework QuartzCore",
  295. "-weak_framework Metal",
  296. }
  297. configuration { "xcode4", "ios" }
  298. kind "WindowedApp"
  299. files {
  300. path.join(BGFX_DIR, "examples/runtime/iOS-Info.plist"),
  301. }
  302. configuration { "xcode4", "tvos" }
  303. kind "WindowedApp"
  304. files {
  305. path.join(BGFX_DIR, "examples/runtime/tvOS-Info.plist"),
  306. }
  307. configuration { "qnx*" }
  308. targetextension ""
  309. links {
  310. "EGL",
  311. "GLESv2",
  312. }
  313. configuration {}
  314. strip()
  315. end
  316. dofile "bgfx.lua"
  317. group "examples"
  318. dofile "example-common.lua"
  319. group "libs"
  320. bgfxProject("", "StaticLib", {})
  321. group "examples"
  322. exampleProject("00-helloworld")
  323. exampleProject("01-cubes")
  324. exampleProject("02-metaballs")
  325. exampleProject("03-raymarch")
  326. exampleProject("04-mesh")
  327. exampleProject("05-instancing")
  328. exampleProject("06-bump")
  329. exampleProject("07-callback")
  330. exampleProject("08-update")
  331. exampleProject("09-hdr")
  332. exampleProject("10-font")
  333. exampleProject("11-fontsdf")
  334. exampleProject("12-lod")
  335. exampleProject("13-stencil")
  336. exampleProject("14-shadowvolumes")
  337. exampleProject("15-shadowmaps-simple")
  338. exampleProject("16-shadowmaps")
  339. exampleProject("17-drawstress")
  340. exampleProject("18-ibl")
  341. exampleProject("19-oit")
  342. exampleProject("20-nanovg")
  343. exampleProject("21-deferred")
  344. exampleProject("22-windows")
  345. exampleProject("23-vectordisplay")
  346. exampleProject("24-nbody")
  347. exampleProject("26-occlusion")
  348. exampleProject("27-terrain")
  349. exampleProject("28-wireframe")
  350. exampleProject("29-debugdraw")
  351. -- C99 source doesn't compile under WinRT settings
  352. if not premake.vstudio.iswinrt() then
  353. exampleProject("25-c99")
  354. end
  355. if _OPTIONS["with-shared-lib"] then
  356. group "libs"
  357. bgfxProject("-shared-lib", "SharedLib", {})
  358. end
  359. if _OPTIONS["with-tools"] then
  360. group "tools"
  361. dofile "shaderc.lua"
  362. dofile "texturec.lua"
  363. dofile "geometryc.lua"
  364. end