genie.lua 9.1 KB

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