genie.lua 9.0 KB

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