genie.lua 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  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-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. BIMG_DIR = path.getabsolute(path.join(BGFX_DIR, "../bimg"))
  63. BX_DIR = os.getenv("BX_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 os.isdir(BX_DIR) then
  70. print("bx not found at " .. BX_DIR)
  71. print("For more info see: https://bkaradzic.github.io/bgfx/build.html")
  72. os.exit()
  73. end
  74. dofile (path.join(BX_DIR, "scripts/toolchain.lua"))
  75. if not toolchain(BGFX_BUILD_DIR, BGFX_THIRD_PARTY_DIR) then
  76. return -- no action specified
  77. end
  78. function copyLib()
  79. end
  80. if _OPTIONS["with-sdl"] then
  81. if os.is("windows") then
  82. if not os.getenv("SDL2_DIR") then
  83. print("Set SDL2_DIR enviroment variable.")
  84. end
  85. end
  86. end
  87. if _OPTIONS["with-profiler"] then
  88. defines {
  89. "ENTRY_CONFIG_PROFILER=1",
  90. "BGFX_CONFIG_PROFILER_REMOTERY=1",
  91. "_WINSOCKAPI_"
  92. }
  93. end
  94. function exampleProject(_name)
  95. project ("example-" .. _name)
  96. uuid (os.uuid("example-" .. _name))
  97. kind "WindowedApp"
  98. configuration {}
  99. debugdir (path.join(BGFX_DIR, "examples/runtime"))
  100. includedirs {
  101. path.join(BX_DIR, "include"),
  102. path.join(BIMG_DIR, "include"),
  103. path.join(BGFX_DIR, "include"),
  104. path.join(BGFX_DIR, "3rdparty"),
  105. path.join(BGFX_DIR, "examples/common"),
  106. }
  107. files {
  108. path.join(BGFX_DIR, "examples", _name, "**.c"),
  109. path.join(BGFX_DIR, "examples", _name, "**.cpp"),
  110. path.join(BGFX_DIR, "examples", _name, "**.h"),
  111. }
  112. removefiles {
  113. path.join(BGFX_DIR, "examples", _name, "**.bin.h"),
  114. }
  115. flags {
  116. "FatalWarnings",
  117. }
  118. links {
  119. "example-common",
  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. dofile "bgfx.lua"
  303. group "libs"
  304. bgfxProject("", "StaticLib", {})
  305. dofile(path.join(BX_DIR, "scripts/bx.lua"))
  306. dofile(path.join(BIMG_DIR, "scripts/bimg.lua"))
  307. dofile(path.join(BIMG_DIR, "scripts/bimg_decode.lua"))
  308. if _OPTIONS["with-tools"] then
  309. dofile(path.join(BIMG_DIR, "scripts/bimg_encode.lua"))
  310. end
  311. if _OPTIONS["with-examples"] or _OPTIONS["with-tools"] then
  312. group "examples"
  313. dofile "example-common.lua"
  314. end
  315. if _OPTIONS["with-examples"] then
  316. group "examples"
  317. exampleProject("00-helloworld")
  318. exampleProject("01-cubes")
  319. exampleProject("02-metaballs")
  320. exampleProject("03-raymarch")
  321. exampleProject("04-mesh")
  322. exampleProject("05-instancing")
  323. exampleProject("06-bump")
  324. exampleProject("07-callback")
  325. exampleProject("08-update")
  326. exampleProject("09-hdr")
  327. exampleProject("10-font")
  328. exampleProject("11-fontsdf")
  329. exampleProject("12-lod")
  330. exampleProject("13-stencil")
  331. exampleProject("14-shadowvolumes")
  332. exampleProject("15-shadowmaps-simple")
  333. exampleProject("16-shadowmaps")
  334. exampleProject("17-drawstress")
  335. exampleProject("18-ibl")
  336. exampleProject("19-oit")
  337. exampleProject("20-nanovg")
  338. exampleProject("21-deferred")
  339. exampleProject("22-windows")
  340. exampleProject("23-vectordisplay")
  341. exampleProject("24-nbody")
  342. exampleProject("26-occlusion")
  343. exampleProject("27-terrain")
  344. exampleProject("28-wireframe")
  345. exampleProject("29-debugdraw")
  346. exampleProject("30-picking")
  347. exampleProject("31-rsm")
  348. exampleProject("32-particles")
  349. exampleProject("33-pom")
  350. -- C99 source doesn't compile under WinRT settings
  351. if not premake.vstudio.iswinrt() then
  352. exampleProject("25-c99")
  353. end
  354. end
  355. if _OPTIONS["with-shared-lib"] then
  356. group "libs"
  357. bgfxProject("-shared-lib", "SharedLib", {})
  358. end
  359. if _OPTIONS["with-tools"] then
  360. group "tools"
  361. dofile "shaderc.lua"
  362. dofile "texturec.lua"
  363. dofile "texturev.lua"
  364. dofile "geometryc.lua"
  365. end