genie.lua 8.1 KB

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