genie.lua 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502
  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 { "WL_EGL_PLATFORM=1" }
  100. end
  101. if _OPTIONS["with-sdl"] then
  102. if os.is("windows") then
  103. if not os.getenv("SDL2_DIR") then
  104. print("Set SDL2_DIR enviroment variable.")
  105. end
  106. end
  107. end
  108. if _OPTIONS["with-profiler"] then
  109. defines {
  110. "ENTRY_CONFIG_PROFILER=1",
  111. "BGFX_CONFIG_PROFILER=1",
  112. }
  113. end
  114. function exampleProjectDefaults()
  115. debugdir (path.join(BGFX_DIR, "examples/runtime"))
  116. includedirs {
  117. path.join(BX_DIR, "include"),
  118. path.join(BIMG_DIR, "include"),
  119. path.join(BGFX_DIR, "include"),
  120. path.join(BGFX_DIR, "3rdparty"),
  121. path.join(BGFX_DIR, "examples/common"),
  122. }
  123. flags {
  124. "FatalWarnings",
  125. }
  126. links {
  127. "example-common",
  128. "example-glue",
  129. "bgfx",
  130. "bimg_decode",
  131. "bimg",
  132. "bx",
  133. }
  134. if _OPTIONS["with-sdl"] then
  135. defines { "ENTRY_CONFIG_USE_SDL=1" }
  136. links { "SDL2" }
  137. configuration { "linux or freebsd" }
  138. if _OPTIONS["with-wayland"] then
  139. links {
  140. "wayland-egl",
  141. }
  142. end
  143. configuration { "osx" }
  144. libdirs { "$(SDL2_DIR)/lib" }
  145. configuration {}
  146. end
  147. if _OPTIONS["with-glfw"] then
  148. defines { "ENTRY_CONFIG_USE_GLFW=1" }
  149. links { "glfw3" }
  150. configuration { "linux or freebsd" }
  151. if _OPTIONS["with-wayland"] then
  152. links {
  153. "wayland-egl",
  154. }
  155. else
  156. links {
  157. "Xrandr",
  158. "Xinerama",
  159. "Xi",
  160. "Xxf86vm",
  161. "Xcursor",
  162. }
  163. end
  164. configuration { "osx" }
  165. linkoptions {
  166. "-framework CoreVideo",
  167. "-framework IOKit",
  168. }
  169. configuration {}
  170. end
  171. configuration { "vs*", "x32 or x64" }
  172. linkoptions {
  173. "/ignore:4199", -- LNK4199: /DELAYLOAD:*.dll ignored; no imports found from *.dll
  174. }
  175. links { -- this is needed only for testing with GLES2/3 on Windows with VS2008
  176. "DelayImp",
  177. }
  178. configuration { "vs201*", "x32 or x64" }
  179. linkoptions { -- this is needed only for testing with GLES2/3 on Windows with VS201x
  180. "/DELAYLOAD:\"libEGL.dll\"",
  181. "/DELAYLOAD:\"libGLESv2.dll\"",
  182. }
  183. configuration { "mingw*" }
  184. targetextension ".exe"
  185. links {
  186. "gdi32",
  187. "psapi",
  188. }
  189. configuration { "vs20*", "x32 or x64" }
  190. links {
  191. "gdi32",
  192. "psapi",
  193. }
  194. configuration { "durango" }
  195. links {
  196. "d3d11_x",
  197. "d3d12_x",
  198. "combase",
  199. "kernelx",
  200. }
  201. configuration { "winstore*" }
  202. removelinks {
  203. "DelayImp",
  204. "gdi32",
  205. "psapi"
  206. }
  207. links {
  208. "d3d11",
  209. "d3d12",
  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", "winstore*" }
  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", "winstore*" }
  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", "winstore*" }
  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 { "asmjs" }
  238. kind "ConsoleApp"
  239. targetextension ".bc"
  240. configuration { "linux-* or freebsd", "not linux-steamlink" }
  241. links {
  242. "X11",
  243. "GL",
  244. "pthread",
  245. }
  246. configuration { "linux-steamlink" }
  247. links {
  248. "EGL",
  249. "GLESv2",
  250. "SDL2",
  251. "pthread",
  252. }
  253. configuration { "rpi" }
  254. links {
  255. "X11",
  256. "brcmGLESv2",
  257. "brcmEGL",
  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. function exampleProject(_combined, ...)
  300. if _combined then
  301. project ("examples")
  302. uuid (os.uuid("examples"))
  303. kind "WindowedApp"
  304. for _, name in ipairs({...}) do
  305. files {
  306. path.join(BGFX_DIR, "examples", name, "**.c"),
  307. path.join(BGFX_DIR, "examples", name, "**.cpp"),
  308. path.join(BGFX_DIR, "examples", name, "**.h"),
  309. }
  310. removefiles {
  311. path.join(BGFX_DIR, "examples", name, "**.bin.h"),
  312. }
  313. end
  314. files {
  315. path.join(BGFX_DIR, "examples/25-c99/helloworld.c"), -- hack for _main_
  316. }
  317. exampleProjectDefaults()
  318. else
  319. for _, name in ipairs({...}) do
  320. project ("example-" .. name)
  321. uuid (os.uuid("example-" .. name))
  322. kind "WindowedApp"
  323. files {
  324. path.join(BGFX_DIR, "examples", name, "**.c"),
  325. path.join(BGFX_DIR, "examples", name, "**.cpp"),
  326. path.join(BGFX_DIR, "examples", name, "**.h"),
  327. }
  328. removefiles {
  329. path.join(BGFX_DIR, "examples", name, "**.bin.h"),
  330. }
  331. defines {
  332. "ENTRY_CONFIG_IMPLEMENT_MAIN=1",
  333. }
  334. exampleProjectDefaults()
  335. end
  336. end
  337. end
  338. dofile "bgfx.lua"
  339. group "libs"
  340. bgfxProject("", "StaticLib", {})
  341. dofile(path.join(BX_DIR, "scripts/bx.lua"))
  342. dofile(path.join(BIMG_DIR, "scripts/bimg.lua"))
  343. dofile(path.join(BIMG_DIR, "scripts/bimg_decode.lua"))
  344. if _OPTIONS["with-tools"] then
  345. dofile(path.join(BIMG_DIR, "scripts/bimg_encode.lua"))
  346. end
  347. if _OPTIONS["with-examples"]
  348. or _OPTIONS["with-combined-examples"]
  349. or _OPTIONS["with-tools"] then
  350. group "examples"
  351. dofile "example-common.lua"
  352. end
  353. if _OPTIONS["with-examples"]
  354. or _OPTIONS["with-combined-examples"] then
  355. group "examples"
  356. exampleProject(_OPTIONS["with-combined-examples"]
  357. , "00-helloworld"
  358. , "01-cubes"
  359. , "02-metaballs"
  360. , "03-raymarch"
  361. , "04-mesh"
  362. , "05-instancing"
  363. , "06-bump"
  364. , "07-callback"
  365. , "08-update"
  366. , "09-hdr"
  367. , "10-font"
  368. , "11-fontsdf"
  369. , "12-lod"
  370. , "13-stencil"
  371. , "14-shadowvolumes"
  372. , "15-shadowmaps-simple"
  373. , "16-shadowmaps"
  374. , "17-drawstress"
  375. , "18-ibl"
  376. , "19-oit"
  377. , "20-nanovg"
  378. , "21-deferred"
  379. , "22-windows"
  380. , "23-vectordisplay"
  381. , "24-nbody"
  382. , "26-occlusion"
  383. , "27-terrain"
  384. , "28-wireframe"
  385. , "29-debugdraw"
  386. , "30-picking"
  387. , "31-rsm"
  388. , "32-particles"
  389. , "33-pom"
  390. , "34-mvs"
  391. , "35-dynamic"
  392. , "36-sky"
  393. , "37-gpudrivenrendering"
  394. , "38-bloom"
  395. , "39-assao"
  396. , "40-svt"
  397. )
  398. -- C99 source doesn't compile under WinRT settings
  399. if not premake.vstudio.iswinrt() then
  400. exampleProject(false, "25-c99")
  401. end
  402. end
  403. if _OPTIONS["with-shared-lib"] then
  404. group "libs"
  405. bgfxProject("-shared-lib", "SharedLib", {})
  406. end
  407. if _OPTIONS["with-tools"] then
  408. group "tools"
  409. dofile "shaderc.lua"
  410. dofile "texturec.lua"
  411. dofile "texturev.lua"
  412. dofile "geometryc.lua"
  413. end