genie.lua 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504
  1. --
  2. -- Copyright 2010-2019 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-sdl",
  11. description = "Enable SDL entry.",
  12. }
  13. newoption {
  14. trigger = "with-glfw",
  15. description = "Enable GLFW entry.",
  16. }
  17. newoption {
  18. trigger = "with-wayland",
  19. description = "Use Wayland backend.",
  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-combined-examples",
  39. description = "Enable building examples (combined as single executable).",
  40. }
  41. newoption {
  42. trigger = "with-examples",
  43. description = "Enable building examples.",
  44. }
  45. dofile "bgfx-idl.lua"
  46. newaction {
  47. trigger = "idl",
  48. description = "Generate bgfx interface source code",
  49. execute = doIdl
  50. }
  51. solution "bgfx"
  52. configurations {
  53. "Debug",
  54. "Release",
  55. }
  56. if _ACTION == "xcode4" then
  57. platforms {
  58. "Universal",
  59. }
  60. else
  61. platforms {
  62. "x32",
  63. "x64",
  64. -- "Xbox360",
  65. "Native", -- for targets where bitness is not specified
  66. }
  67. end
  68. language "C++"
  69. startproject "example-00-helloworld"
  70. MODULE_DIR = path.getabsolute("../")
  71. BGFX_DIR = path.getabsolute("..")
  72. BX_DIR = os.getenv("BX_DIR")
  73. BIMG_DIR = os.getenv("BIMG_DIR")
  74. local BGFX_BUILD_DIR = path.join(BGFX_DIR, ".build")
  75. local BGFX_THIRD_PARTY_DIR = path.join(BGFX_DIR, "3rdparty")
  76. if not BX_DIR then
  77. BX_DIR = path.getabsolute(path.join(BGFX_DIR, "../bx"))
  78. end
  79. if not BIMG_DIR then
  80. BIMG_DIR = path.getabsolute(path.join(BGFX_DIR, "../bimg"))
  81. end
  82. if not os.isdir(BX_DIR) or not os.isdir(BIMG_DIR) then
  83. if not os.isdir(BX_DIR) then
  84. print("bx not found at " .. BX_DIR)
  85. end
  86. if not os.isdir(BIMG_DIR) then
  87. print("bimg not found at " .. BIMG_DIR)
  88. end
  89. print("For more info see: https://bkaradzic.github.io/bgfx/build.html")
  90. os.exit()
  91. end
  92. dofile (path.join(BX_DIR, "scripts/toolchain.lua"))
  93. if not toolchain(BGFX_BUILD_DIR, BGFX_THIRD_PARTY_DIR) then
  94. return -- no action specified
  95. end
  96. function copyLib()
  97. end
  98. if _OPTIONS["with-wayland"] then
  99. defines { "BGFX_USE_WAYLAND=1" }
  100. else
  101. defines { "BGFX_USE_WAYLAND=0" }
  102. end
  103. if _OPTIONS["with-sdl"] then
  104. if os.is("windows") then
  105. if not os.getenv("SDL2_DIR") then
  106. print("Set SDL2_DIR enviroment variable.")
  107. end
  108. end
  109. end
  110. if _OPTIONS["with-profiler"] then
  111. defines {
  112. "ENTRY_CONFIG_PROFILER=1",
  113. "BGFX_CONFIG_PROFILER=1",
  114. }
  115. end
  116. function exampleProjectDefaults()
  117. debugdir (path.join(BGFX_DIR, "examples/runtime"))
  118. includedirs {
  119. path.join(BX_DIR, "include"),
  120. path.join(BIMG_DIR, "include"),
  121. path.join(BGFX_DIR, "include"),
  122. path.join(BGFX_DIR, "3rdparty"),
  123. path.join(BGFX_DIR, "examples/common"),
  124. }
  125. flags {
  126. "FatalWarnings",
  127. }
  128. links {
  129. "example-common",
  130. "example-glue",
  131. "bgfx",
  132. "bimg_decode",
  133. "bimg",
  134. "bx",
  135. }
  136. if _OPTIONS["with-sdl"] then
  137. defines { "ENTRY_CONFIG_USE_SDL=1" }
  138. links { "SDL2" }
  139. configuration { "linux or freebsd" }
  140. if _OPTIONS["with-wayland"] then
  141. links {
  142. "wayland-egl",
  143. }
  144. end
  145. configuration { "osx" }
  146. libdirs { "$(SDL2_DIR)/lib" }
  147. configuration {}
  148. end
  149. if _OPTIONS["with-glfw"] then
  150. defines { "ENTRY_CONFIG_USE_GLFW=1" }
  151. links { "glfw3" }
  152. configuration { "linux or freebsd" }
  153. if _OPTIONS["with-wayland"] then
  154. links {
  155. "wayland-egl",
  156. }
  157. else
  158. links {
  159. "Xrandr",
  160. "Xinerama",
  161. "Xi",
  162. "Xxf86vm",
  163. "Xcursor",
  164. }
  165. end
  166. configuration { "osx" }
  167. linkoptions {
  168. "-framework CoreVideo",
  169. "-framework IOKit",
  170. }
  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 { "winstore*" }
  204. removelinks {
  205. "DelayImp",
  206. "gdi32",
  207. "psapi"
  208. }
  209. links {
  210. "d3d11",
  211. "d3d12",
  212. "dxgi"
  213. }
  214. linkoptions {
  215. "/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
  216. }
  217. -- WinRT targets need their own output directories or build files stomp over each other
  218. configuration { "x32", "winstore*" }
  219. targetdir (path.join(BGFX_BUILD_DIR, "win32_" .. _ACTION, "bin", _name))
  220. objdir (path.join(BGFX_BUILD_DIR, "win32_" .. _ACTION, "obj", _name))
  221. configuration { "x64", "winstore*" }
  222. targetdir (path.join(BGFX_BUILD_DIR, "win64_" .. _ACTION, "bin", _name))
  223. objdir (path.join(BGFX_BUILD_DIR, "win64_" .. _ACTION, "obj", _name))
  224. configuration { "ARM", "winstore*" }
  225. targetdir (path.join(BGFX_BUILD_DIR, "arm_" .. _ACTION, "bin", _name))
  226. objdir (path.join(BGFX_BUILD_DIR, "arm_" .. _ACTION, "obj", _name))
  227. configuration { "mingw-clang" }
  228. kind "ConsoleApp"
  229. configuration { "android*" }
  230. kind "ConsoleApp"
  231. targetextension ".so"
  232. linkoptions {
  233. "-shared",
  234. }
  235. links {
  236. "EGL",
  237. "GLESv2",
  238. }
  239. configuration { "asmjs" }
  240. kind "ConsoleApp"
  241. targetextension ".bc"
  242. configuration { "linux-* or freebsd", "not linux-steamlink" }
  243. links {
  244. "X11",
  245. "GL",
  246. "pthread",
  247. }
  248. configuration { "linux-steamlink" }
  249. links {
  250. "EGL",
  251. "GLESv2",
  252. "SDL2",
  253. "pthread",
  254. }
  255. configuration { "rpi" }
  256. links {
  257. "X11",
  258. "brcmGLESv2",
  259. "brcmEGL",
  260. "bcm_host",
  261. "vcos",
  262. "vchiq_arm",
  263. "pthread",
  264. }
  265. configuration { "osx" }
  266. linkoptions {
  267. "-framework Cocoa",
  268. "-framework QuartzCore",
  269. "-framework OpenGL",
  270. "-weak_framework Metal",
  271. }
  272. configuration { "ios* or tvos*" }
  273. kind "ConsoleApp"
  274. linkoptions {
  275. "-framework CoreFoundation",
  276. "-framework Foundation",
  277. "-framework OpenGLES",
  278. "-framework UIKit",
  279. "-framework QuartzCore",
  280. "-weak_framework Metal",
  281. }
  282. configuration { "xcode4", "ios" }
  283. kind "WindowedApp"
  284. files {
  285. path.join(BGFX_DIR, "examples/runtime/iOS-Info.plist"),
  286. }
  287. configuration { "xcode4", "tvos" }
  288. kind "WindowedApp"
  289. files {
  290. path.join(BGFX_DIR, "examples/runtime/tvOS-Info.plist"),
  291. }
  292. configuration { "qnx*" }
  293. targetextension ""
  294. links {
  295. "EGL",
  296. "GLESv2",
  297. }
  298. configuration {}
  299. strip()
  300. end
  301. function exampleProject(_combined, ...)
  302. if _combined then
  303. project ("examples")
  304. uuid (os.uuid("examples"))
  305. kind "WindowedApp"
  306. for _, name in ipairs({...}) do
  307. files {
  308. path.join(BGFX_DIR, "examples", name, "**.c"),
  309. path.join(BGFX_DIR, "examples", name, "**.cpp"),
  310. path.join(BGFX_DIR, "examples", name, "**.h"),
  311. }
  312. removefiles {
  313. path.join(BGFX_DIR, "examples", name, "**.bin.h"),
  314. }
  315. end
  316. files {
  317. path.join(BGFX_DIR, "examples/25-c99/helloworld.c"), -- hack for _main_
  318. }
  319. exampleProjectDefaults()
  320. else
  321. for _, name in ipairs({...}) do
  322. project ("example-" .. name)
  323. uuid (os.uuid("example-" .. name))
  324. kind "WindowedApp"
  325. files {
  326. path.join(BGFX_DIR, "examples", name, "**.c"),
  327. path.join(BGFX_DIR, "examples", name, "**.cpp"),
  328. path.join(BGFX_DIR, "examples", name, "**.h"),
  329. }
  330. removefiles {
  331. path.join(BGFX_DIR, "examples", name, "**.bin.h"),
  332. }
  333. defines {
  334. "ENTRY_CONFIG_IMPLEMENT_MAIN=1",
  335. }
  336. exampleProjectDefaults()
  337. end
  338. end
  339. end
  340. dofile "bgfx.lua"
  341. group "libs"
  342. bgfxProject("", "StaticLib", {})
  343. dofile(path.join(BX_DIR, "scripts/bx.lua"))
  344. dofile(path.join(BIMG_DIR, "scripts/bimg.lua"))
  345. dofile(path.join(BIMG_DIR, "scripts/bimg_decode.lua"))
  346. if _OPTIONS["with-tools"] then
  347. dofile(path.join(BIMG_DIR, "scripts/bimg_encode.lua"))
  348. end
  349. if _OPTIONS["with-examples"]
  350. or _OPTIONS["with-combined-examples"]
  351. or _OPTIONS["with-tools"] then
  352. group "examples"
  353. dofile "example-common.lua"
  354. end
  355. if _OPTIONS["with-examples"]
  356. or _OPTIONS["with-combined-examples"] then
  357. group "examples"
  358. exampleProject(_OPTIONS["with-combined-examples"]
  359. , "00-helloworld"
  360. , "01-cubes"
  361. , "02-metaballs"
  362. , "03-raymarch"
  363. , "04-mesh"
  364. , "05-instancing"
  365. , "06-bump"
  366. , "07-callback"
  367. , "08-update"
  368. , "09-hdr"
  369. , "10-font"
  370. , "11-fontsdf"
  371. , "12-lod"
  372. , "13-stencil"
  373. , "14-shadowvolumes"
  374. , "15-shadowmaps-simple"
  375. , "16-shadowmaps"
  376. , "17-drawstress"
  377. , "18-ibl"
  378. , "19-oit"
  379. , "20-nanovg"
  380. , "21-deferred"
  381. , "22-windows"
  382. , "23-vectordisplay"
  383. , "24-nbody"
  384. , "26-occlusion"
  385. , "27-terrain"
  386. , "28-wireframe"
  387. , "29-debugdraw"
  388. , "30-picking"
  389. , "31-rsm"
  390. , "32-particles"
  391. , "33-pom"
  392. , "34-mvs"
  393. , "35-dynamic"
  394. , "36-sky"
  395. , "37-gpudrivenrendering"
  396. , "38-bloom"
  397. , "39-assao"
  398. , "40-svt"
  399. )
  400. -- C99 source doesn't compile under WinRT settings
  401. if not premake.vstudio.iswinrt() then
  402. exampleProject(false, "25-c99")
  403. end
  404. end
  405. if _OPTIONS["with-shared-lib"] then
  406. group "libs"
  407. bgfxProject("-shared-lib", "SharedLib", {})
  408. end
  409. if _OPTIONS["with-tools"] then
  410. group "tools"
  411. dofile "shaderc.lua"
  412. dofile "texturec.lua"
  413. dofile "texturev.lua"
  414. dofile "geometryc.lua"
  415. end