genie.lua 8.6 KB

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