genie.lua 9.3 KB

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