genie.lua 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  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. links {
  142. "winmm",
  143. "ws2_32",
  144. }
  145. configuration { "x32", "Debug" }
  146. libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Windows/Win32/Debug", _ACTION) }
  147. configuration { "x32", "Release" }
  148. libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Windows/Win32/Release", _ACTION) }
  149. configuration { "x64", "Debug" }
  150. libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Windows/x64/Debug", _ACTION) }
  151. configuration { "x64", "Release" }
  152. libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Windows/x64/Release", _ACTION) }
  153. configuration { "x32 or x64" }
  154. links { "libovr" }
  155. configuration {}
  156. end
  157. configuration { "vs*", "x32 or x64" }
  158. linkoptions {
  159. "/ignore:4199", -- LNK4199: /DELAYLOAD:*.dll ignored; no imports found from *.dll
  160. }
  161. links { -- this is needed only for testing with GLES2/3 on Windows with VS2008
  162. "DelayImp",
  163. }
  164. configuration { "vs201*", "x32 or x64" }
  165. linkoptions { -- this is needed only for testing with GLES2/3 on Windows with VS201x
  166. "/DELAYLOAD:\"libEGL.dll\"",
  167. "/DELAYLOAD:\"libGLESv2.dll\"",
  168. }
  169. configuration { "mingw*" }
  170. targetextension ".exe"
  171. links {
  172. "gdi32",
  173. "psapi",
  174. }
  175. configuration { "vs20*", "x32 or x64" }
  176. links {
  177. "gdi32",
  178. "psapi",
  179. }
  180. configuration { "durango" }
  181. links {
  182. "d3d11_x",
  183. "d3d12_x",
  184. "combase",
  185. "kernelx",
  186. }
  187. configuration { "winphone8* or winstore8*" }
  188. removelinks {
  189. "DelayImp",
  190. "gdi32",
  191. "psapi"
  192. }
  193. links {
  194. "d3d11",
  195. "dxgi"
  196. }
  197. linkoptions {
  198. "/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
  199. }
  200. -- WinRT targets need their own output directories or build files stomp over each other
  201. configuration { "x32", "winphone8* or winstore8*" }
  202. targetdir (path.join(BGFX_BUILD_DIR, "win32_" .. _ACTION, "bin", _name))
  203. objdir (path.join(BGFX_BUILD_DIR, "win32_" .. _ACTION, "obj", _name))
  204. configuration { "x64", "winphone8* or winstore8*" }
  205. targetdir (path.join(BGFX_BUILD_DIR, "win64_" .. _ACTION, "bin", _name))
  206. objdir (path.join(BGFX_BUILD_DIR, "win64_" .. _ACTION, "obj", _name))
  207. configuration { "ARM", "winphone8* or winstore8*" }
  208. targetdir (path.join(BGFX_BUILD_DIR, "arm_" .. _ACTION, "bin", _name))
  209. objdir (path.join(BGFX_BUILD_DIR, "arm_" .. _ACTION, "obj", _name))
  210. configuration { "mingw-clang" }
  211. kind "ConsoleApp"
  212. configuration { "android*" }
  213. kind "ConsoleApp"
  214. targetextension ".so"
  215. linkoptions {
  216. "-shared",
  217. }
  218. links {
  219. "EGL",
  220. "GLESv2",
  221. }
  222. configuration { "nacl*" }
  223. kind "ConsoleApp"
  224. targetextension ".nexe"
  225. links {
  226. "ppapi",
  227. "ppapi_gles2",
  228. "pthread",
  229. }
  230. configuration { "pnacl" }
  231. kind "ConsoleApp"
  232. targetextension ".pexe"
  233. links {
  234. "ppapi",
  235. "ppapi_gles2",
  236. "pthread",
  237. }
  238. configuration { "asmjs" }
  239. kind "ConsoleApp"
  240. targetextension ".bc"
  241. configuration { "linux-* or freebsd", "not linux-steamlink" }
  242. links {
  243. "X11",
  244. "GL",
  245. "pthread",
  246. }
  247. configuration { "linux-steamlink" }
  248. links {
  249. "EGL",
  250. "GLESv2",
  251. "SDL2",
  252. "pthread",
  253. }
  254. configuration { "rpi" }
  255. links {
  256. "X11",
  257. "GLESv2",
  258. "EGL",
  259. "bcm_host",
  260. "vcos",
  261. "vchiq_arm",
  262. "pthread",
  263. }
  264. configuration { "osx" }
  265. linkoptions {
  266. "-framework Cocoa",
  267. "-framework QuartzCore",
  268. "-framework OpenGL",
  269. "-weak_framework Metal",
  270. }
  271. configuration { "ios* or tvos*" }
  272. kind "ConsoleApp"
  273. linkoptions {
  274. "-framework CoreFoundation",
  275. "-framework Foundation",
  276. "-framework OpenGLES",
  277. "-framework UIKit",
  278. "-framework QuartzCore",
  279. "-weak_framework Metal",
  280. }
  281. configuration { "xcode4", "ios" }
  282. kind "WindowedApp"
  283. files {
  284. path.join(BGFX_DIR, "examples/runtime/iOS-Info.plist"),
  285. }
  286. configuration { "xcode4", "tvos" }
  287. kind "WindowedApp"
  288. files {
  289. path.join(BGFX_DIR, "examples/runtime/tvOS-Info.plist"),
  290. }
  291. configuration { "qnx*" }
  292. targetextension ""
  293. links {
  294. "EGL",
  295. "GLESv2",
  296. }
  297. configuration {}
  298. strip()
  299. end
  300. dofile "bgfx.lua"
  301. group "examples"
  302. dofile "example-common.lua"
  303. group "libs"
  304. bgfxProject("", "StaticLib", {})
  305. group "examples"
  306. exampleProject("00-helloworld")
  307. exampleProject("01-cubes")
  308. exampleProject("02-metaballs")
  309. exampleProject("03-raymarch")
  310. exampleProject("04-mesh")
  311. exampleProject("05-instancing")
  312. exampleProject("06-bump")
  313. exampleProject("07-callback")
  314. exampleProject("08-update")
  315. exampleProject("09-hdr")
  316. exampleProject("10-font")
  317. exampleProject("11-fontsdf")
  318. exampleProject("12-lod")
  319. exampleProject("13-stencil")
  320. exampleProject("14-shadowvolumes")
  321. exampleProject("15-shadowmaps-simple")
  322. exampleProject("16-shadowmaps")
  323. exampleProject("17-drawstress")
  324. exampleProject("18-ibl")
  325. exampleProject("19-oit")
  326. exampleProject("20-nanovg")
  327. exampleProject("21-deferred")
  328. exampleProject("22-windows")
  329. exampleProject("23-vectordisplay")
  330. exampleProject("24-nbody")
  331. exampleProject("26-occlusion")
  332. exampleProject("27-terrain")
  333. exampleProject("28-wireframe")
  334. exampleProject("29-debugdraw")
  335. -- C99 source doesn't compile under WinRT settings
  336. if not premake.vstudio.iswinrt() then
  337. exampleProject("25-c99")
  338. end
  339. if _OPTIONS["with-shared-lib"] then
  340. group "libs"
  341. bgfxProject("-shared-lib", "SharedLib", {})
  342. end
  343. if _OPTIONS["with-tools"] then
  344. group "tools"
  345. dofile "shaderc.lua"
  346. dofile "texturec.lua"
  347. dofile "geometryc.lua"
  348. end