genie.lua 8.5 KB

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