genie.lua 8.2 KB

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