genie.lua 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503
  1. --
  2. -- Copyright 2010-2017 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 { "winphone8* or winstore8*" }
  190. removelinks {
  191. "DelayImp",
  192. "gdi32",
  193. "psapi"
  194. }
  195. links {
  196. "d3d11",
  197. "dxgi"
  198. }
  199. linkoptions {
  200. "/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
  201. }
  202. -- WinRT targets need their own output directories or build files stomp over each other
  203. configuration { "x32", "winphone8* or winstore8*" }
  204. targetdir (path.join(BGFX_BUILD_DIR, "win32_" .. _ACTION, "bin", _name))
  205. objdir (path.join(BGFX_BUILD_DIR, "win32_" .. _ACTION, "obj", _name))
  206. configuration { "x64", "winphone8* or winstore8*" }
  207. targetdir (path.join(BGFX_BUILD_DIR, "win64_" .. _ACTION, "bin", _name))
  208. objdir (path.join(BGFX_BUILD_DIR, "win64_" .. _ACTION, "obj", _name))
  209. configuration { "ARM", "winphone8* or winstore8*" }
  210. targetdir (path.join(BGFX_BUILD_DIR, "arm_" .. _ACTION, "bin", _name))
  211. objdir (path.join(BGFX_BUILD_DIR, "arm_" .. _ACTION, "obj", _name))
  212. configuration { "mingw-clang" }
  213. kind "ConsoleApp"
  214. configuration { "android*" }
  215. kind "ConsoleApp"
  216. targetextension ".so"
  217. linkoptions {
  218. "-shared",
  219. }
  220. links {
  221. "EGL",
  222. "GLESv2",
  223. }
  224. configuration { "nacl*" }
  225. kind "ConsoleApp"
  226. targetextension ".nexe"
  227. links {
  228. "ppapi",
  229. "ppapi_gles2",
  230. "pthread",
  231. }
  232. configuration { "pnacl" }
  233. kind "ConsoleApp"
  234. targetextension ".pexe"
  235. links {
  236. "ppapi",
  237. "ppapi_gles2",
  238. "pthread",
  239. }
  240. configuration { "asmjs" }
  241. kind "ConsoleApp"
  242. targetextension ".bc"
  243. configuration { "linux-* or freebsd", "not linux-steamlink" }
  244. links {
  245. "X11",
  246. "GL",
  247. "pthread",
  248. }
  249. configuration { "linux-steamlink" }
  250. links {
  251. "EGL",
  252. "GLESv2",
  253. "SDL2",
  254. "pthread",
  255. }
  256. configuration { "rpi" }
  257. links {
  258. "X11",
  259. "GLESv2",
  260. "EGL",
  261. "bcm_host",
  262. "vcos",
  263. "vchiq_arm",
  264. "pthread",
  265. }
  266. configuration { "osx" }
  267. linkoptions {
  268. "-framework Cocoa",
  269. "-framework QuartzCore",
  270. "-framework OpenGL",
  271. "-weak_framework Metal",
  272. }
  273. configuration { "ios* or tvos*" }
  274. kind "ConsoleApp"
  275. linkoptions {
  276. "-framework CoreFoundation",
  277. "-framework Foundation",
  278. "-framework OpenGLES",
  279. "-framework UIKit",
  280. "-framework QuartzCore",
  281. "-weak_framework Metal",
  282. }
  283. configuration { "xcode4", "ios" }
  284. kind "WindowedApp"
  285. files {
  286. path.join(BGFX_DIR, "examples/runtime/iOS-Info.plist"),
  287. }
  288. configuration { "xcode4", "tvos" }
  289. kind "WindowedApp"
  290. files {
  291. path.join(BGFX_DIR, "examples/runtime/tvOS-Info.plist"),
  292. }
  293. configuration { "qnx*" }
  294. targetextension ""
  295. links {
  296. "EGL",
  297. "GLESv2",
  298. }
  299. configuration {}
  300. strip()
  301. end
  302. function exampleProject(_combined, ...)
  303. if _combined then
  304. project ("examples")
  305. uuid (os.uuid("examples"))
  306. kind "WindowedApp"
  307. for _, name in ipairs({...}) do
  308. files {
  309. path.join(BGFX_DIR, "examples", name, "**.c"),
  310. path.join(BGFX_DIR, "examples", name, "**.cpp"),
  311. path.join(BGFX_DIR, "examples", name, "**.h"),
  312. }
  313. removefiles {
  314. path.join(BGFX_DIR, "examples", name, "**.bin.h"),
  315. }
  316. end
  317. files {
  318. path.join(BGFX_DIR, "examples/25-c99/helloworld.c"), -- hack for _main_
  319. }
  320. exampleProjectDefaults()
  321. else
  322. for _, name in ipairs({...}) do
  323. project ("example-" .. name)
  324. uuid (os.uuid("example-" .. name))
  325. kind "WindowedApp"
  326. files {
  327. path.join(BGFX_DIR, "examples", name, "**.c"),
  328. path.join(BGFX_DIR, "examples", name, "**.cpp"),
  329. path.join(BGFX_DIR, "examples", name, "**.h"),
  330. }
  331. removefiles {
  332. path.join(BGFX_DIR, "examples", name, "**.bin.h"),
  333. }
  334. defines {
  335. "ENTRY_CONFIG_IMPLEMENT_MAIN=1",
  336. }
  337. exampleProjectDefaults()
  338. end
  339. end
  340. end
  341. dofile "bgfx.lua"
  342. group "libs"
  343. bgfxProject("", "StaticLib", {})
  344. dofile(path.join(BX_DIR, "scripts/bx.lua"))
  345. dofile(path.join(BIMG_DIR, "scripts/bimg.lua"))
  346. dofile(path.join(BIMG_DIR, "scripts/bimg_decode.lua"))
  347. if _OPTIONS["with-tools"] then
  348. dofile(path.join(BIMG_DIR, "scripts/bimg_encode.lua"))
  349. end
  350. if _OPTIONS["with-examples"]
  351. or _OPTIONS["with-combined-examples"]
  352. or _OPTIONS["with-tools"] then
  353. group "examples"
  354. dofile "example-common.lua"
  355. end
  356. if _OPTIONS["with-examples"]
  357. or _OPTIONS["with-combined-examples"] then
  358. group "examples"
  359. exampleProject(_OPTIONS["with-combined-examples"]
  360. , "00-helloworld"
  361. , "01-cubes"
  362. , "02-metaballs"
  363. , "03-raymarch"
  364. , "04-mesh"
  365. , "05-instancing"
  366. , "06-bump"
  367. , "07-callback"
  368. , "08-update"
  369. , "09-hdr"
  370. , "10-font"
  371. , "11-fontsdf"
  372. , "12-lod"
  373. , "13-stencil"
  374. , "14-shadowvolumes"
  375. , "15-shadowmaps-simple"
  376. , "16-shadowmaps"
  377. , "17-drawstress"
  378. , "18-ibl"
  379. , "19-oit"
  380. , "20-nanovg"
  381. , "21-deferred"
  382. , "22-windows"
  383. , "23-vectordisplay"
  384. , "24-nbody"
  385. , "26-occlusion"
  386. , "27-terrain"
  387. , "28-wireframe"
  388. , "29-debugdraw"
  389. , "30-picking"
  390. , "31-rsm"
  391. , "32-particles"
  392. , "33-pom"
  393. , "34-mvs"
  394. , "35-dynamic"
  395. , "36-sky"
  396. )
  397. -- C99 source doesn't compile under WinRT settings
  398. if not premake.vstudio.iswinrt() then
  399. exampleProject(false, "25-c99")
  400. end
  401. end
  402. if _OPTIONS["with-shared-lib"] then
  403. group "libs"
  404. bgfxProject("-shared-lib", "SharedLib", {})
  405. end
  406. if _OPTIONS["with-tools"] then
  407. group "tools"
  408. dofile "shaderc.lua"
  409. dofile "texturec.lua"
  410. dofile "texturev.lua"
  411. dofile "geometryc.lua"
  412. end