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_REMOTERY=1",
  103. "_WINSOCKAPI_"
  104. }
  105. end
  106. function exampleProjectDefaults()
  107. debugdir (path.join(BGFX_DIR, "examples/runtime"))
  108. includedirs {
  109. path.join(BX_DIR, "include"),
  110. path.join(BIMG_DIR, "include"),
  111. path.join(BGFX_DIR, "include"),
  112. path.join(BGFX_DIR, "3rdparty"),
  113. path.join(BGFX_DIR, "examples/common"),
  114. }
  115. flags {
  116. "FatalWarnings",
  117. }
  118. links {
  119. "example-common",
  120. "example-glue",
  121. "bgfx",
  122. "bimg_decode",
  123. "bimg",
  124. "bx",
  125. }
  126. if _OPTIONS["with-sdl"] then
  127. defines { "ENTRY_CONFIG_USE_SDL=1" }
  128. links { "SDL2" }
  129. configuration { "osx" }
  130. libdirs { "$(SDL2_DIR)/lib" }
  131. configuration {}
  132. end
  133. if _OPTIONS["with-glfw"] then
  134. defines { "ENTRY_CONFIG_USE_GLFW=1" }
  135. links { "glfw3" }
  136. configuration { "linux or freebsd" }
  137. links {
  138. "Xrandr",
  139. "Xinerama",
  140. "Xi",
  141. "Xxf86vm",
  142. "Xcursor",
  143. }
  144. configuration { "osx" }
  145. linkoptions {
  146. "-framework CoreVideo",
  147. "-framework IOKit",
  148. }
  149. configuration {}
  150. end
  151. if _OPTIONS["with-ovr"] then
  152. configuration { "x32" }
  153. libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Windows/Win32/Release", _ACTION) }
  154. configuration { "x64" }
  155. libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Windows/x64/Release", _ACTION) }
  156. configuration { "x32 or x64" }
  157. links { "libovr" }
  158. configuration {}
  159. end
  160. configuration { "vs*", "x32 or x64" }
  161. linkoptions {
  162. "/ignore:4199", -- LNK4199: /DELAYLOAD:*.dll ignored; no imports found from *.dll
  163. }
  164. links { -- this is needed only for testing with GLES2/3 on Windows with VS2008
  165. "DelayImp",
  166. }
  167. configuration { "vs201*", "x32 or x64" }
  168. linkoptions { -- this is needed only for testing with GLES2/3 on Windows with VS201x
  169. "/DELAYLOAD:\"libEGL.dll\"",
  170. "/DELAYLOAD:\"libGLESv2.dll\"",
  171. }
  172. configuration { "mingw*" }
  173. targetextension ".exe"
  174. links {
  175. "gdi32",
  176. "psapi",
  177. }
  178. configuration { "vs20*", "x32 or x64" }
  179. links {
  180. "gdi32",
  181. "psapi",
  182. }
  183. configuration { "durango" }
  184. links {
  185. "d3d11_x",
  186. "d3d12_x",
  187. "combase",
  188. "kernelx",
  189. }
  190. configuration { "winphone8* or winstore8*" }
  191. removelinks {
  192. "DelayImp",
  193. "gdi32",
  194. "psapi"
  195. }
  196. links {
  197. "d3d11",
  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", "winphone8* or winstore8*" }
  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", "winphone8* or winstore8*" }
  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", "winphone8* or winstore8*" }
  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 { "nacl*" }
  226. kind "ConsoleApp"
  227. targetextension ".nexe"
  228. links {
  229. "ppapi",
  230. "ppapi_gles2",
  231. "pthread",
  232. }
  233. configuration { "pnacl" }
  234. kind "ConsoleApp"
  235. targetextension ".pexe"
  236. links {
  237. "ppapi",
  238. "ppapi_gles2",
  239. "pthread",
  240. }
  241. configuration { "asmjs" }
  242. kind "ConsoleApp"
  243. targetextension ".bc"
  244. configuration { "linux-* or freebsd", "not linux-steamlink" }
  245. links {
  246. "X11",
  247. "GL",
  248. "pthread",
  249. }
  250. configuration { "linux-steamlink" }
  251. links {
  252. "EGL",
  253. "GLESv2",
  254. "SDL2",
  255. "pthread",
  256. }
  257. configuration { "rpi" }
  258. links {
  259. "X11",
  260. "GLESv2",
  261. "EGL",
  262. "bcm_host",
  263. "vcos",
  264. "vchiq_arm",
  265. "pthread",
  266. }
  267. configuration { "osx" }
  268. linkoptions {
  269. "-framework Cocoa",
  270. "-framework QuartzCore",
  271. "-framework OpenGL",
  272. "-weak_framework Metal",
  273. }
  274. configuration { "ios* or tvos*" }
  275. kind "ConsoleApp"
  276. linkoptions {
  277. "-framework CoreFoundation",
  278. "-framework Foundation",
  279. "-framework OpenGLES",
  280. "-framework UIKit",
  281. "-framework QuartzCore",
  282. "-weak_framework Metal",
  283. }
  284. configuration { "xcode4", "ios" }
  285. kind "WindowedApp"
  286. files {
  287. path.join(BGFX_DIR, "examples/runtime/iOS-Info.plist"),
  288. }
  289. configuration { "xcode4", "tvos" }
  290. kind "WindowedApp"
  291. files {
  292. path.join(BGFX_DIR, "examples/runtime/tvOS-Info.plist"),
  293. }
  294. configuration { "qnx*" }
  295. targetextension ""
  296. links {
  297. "EGL",
  298. "GLESv2",
  299. }
  300. configuration {}
  301. strip()
  302. end
  303. function exampleProject(_combined, ...)
  304. if _combined then
  305. project ("examples")
  306. uuid (os.uuid("examples"))
  307. kind "WindowedApp"
  308. for _, name in ipairs({...}) do
  309. files {
  310. path.join(BGFX_DIR, "examples", name, "**.c"),
  311. path.join(BGFX_DIR, "examples", name, "**.cpp"),
  312. path.join(BGFX_DIR, "examples", name, "**.h"),
  313. }
  314. removefiles {
  315. path.join(BGFX_DIR, "examples", name, "**.bin.h"),
  316. }
  317. end
  318. files {
  319. path.join(BGFX_DIR, "examples/25-c99/helloworld.c"), -- hack for _main_
  320. }
  321. exampleProjectDefaults()
  322. else
  323. for _, name in ipairs({...}) do
  324. project ("example-" .. name)
  325. uuid (os.uuid("example-" .. name))
  326. kind "WindowedApp"
  327. files {
  328. path.join(BGFX_DIR, "examples", name, "**.c"),
  329. path.join(BGFX_DIR, "examples", name, "**.cpp"),
  330. path.join(BGFX_DIR, "examples", name, "**.h"),
  331. }
  332. removefiles {
  333. path.join(BGFX_DIR, "examples", name, "**.bin.h"),
  334. }
  335. defines {
  336. "ENTRY_CONFIG_IMPLEMENT_MAIN=1",
  337. }
  338. exampleProjectDefaults()
  339. end
  340. end
  341. end
  342. dofile "bgfx.lua"
  343. group "libs"
  344. bgfxProject("", "StaticLib", {})
  345. dofile(path.join(BX_DIR, "scripts/bx.lua"))
  346. dofile(path.join(BIMG_DIR, "scripts/bimg.lua"))
  347. dofile(path.join(BIMG_DIR, "scripts/bimg_decode.lua"))
  348. if _OPTIONS["with-tools"] then
  349. dofile(path.join(BIMG_DIR, "scripts/bimg_encode.lua"))
  350. end
  351. if _OPTIONS["with-examples"]
  352. or _OPTIONS["with-combined-examples"]
  353. or _OPTIONS["with-tools"] then
  354. group "examples"
  355. dofile "example-common.lua"
  356. end
  357. if _OPTIONS["with-examples"]
  358. or _OPTIONS["with-combined-examples"] then
  359. group "examples"
  360. exampleProject(_OPTIONS["with-combined-examples"]
  361. , "00-helloworld"
  362. , "01-cubes"
  363. , "02-metaballs"
  364. , "03-raymarch"
  365. , "04-mesh"
  366. , "05-instancing"
  367. , "06-bump"
  368. , "07-callback"
  369. , "08-update"
  370. , "09-hdr"
  371. , "10-font"
  372. , "11-fontsdf"
  373. , "12-lod"
  374. , "13-stencil"
  375. , "14-shadowvolumes"
  376. , "15-shadowmaps-simple"
  377. , "16-shadowmaps"
  378. , "17-drawstress"
  379. , "18-ibl"
  380. , "19-oit"
  381. , "20-nanovg"
  382. , "21-deferred"
  383. , "22-windows"
  384. , "23-vectordisplay"
  385. , "24-nbody"
  386. , "26-occlusion"
  387. , "27-terrain"
  388. , "28-wireframe"
  389. , "29-debugdraw"
  390. , "30-picking"
  391. , "31-rsm"
  392. , "32-particles"
  393. , "33-pom"
  394. , "34-mvs"
  395. , "35-dynamic"
  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