genie.lua 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  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 { "x32", "windows" }
  119. libdirs { "$(SDL2_DIR)/lib/x86" }
  120. configuration { "x64", "windows" }
  121. libdirs { "$(SDL2_DIR)/lib/x64" }
  122. configuration {}
  123. end
  124. if _OPTIONS["with-glfw"] then
  125. defines { "ENTRY_CONFIG_USE_GLFW=1" }
  126. links {
  127. "glfw3"
  128. }
  129. configuration { "linux or freebsd" }
  130. links {
  131. "Xrandr",
  132. "Xinerama",
  133. "Xi",
  134. "Xxf86vm",
  135. "Xcursor",
  136. }
  137. configuration { "osx" }
  138. linkoptions {
  139. "-framework CoreVideo",
  140. "-framework IOKit",
  141. }
  142. configuration {}
  143. end
  144. if _OPTIONS["with-ovr"] then
  145. links {
  146. "winmm",
  147. "ws2_32",
  148. }
  149. -- Check for LibOVR 5.0+
  150. if os.isdir(path.join(os.getenv("OVR_DIR"), "LibOVR/Lib/Windows/Win32/Debug/VS2012")) then
  151. configuration { "x32", "Debug" }
  152. libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Windows/Win32/Debug", _ACTION) }
  153. configuration { "x32", "Release" }
  154. libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Windows/Win32/Release", _ACTION) }
  155. configuration { "x64", "Debug" }
  156. libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Windows/x64/Debug", _ACTION) }
  157. configuration { "x64", "Release" }
  158. libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Windows/x64/Release", _ACTION) }
  159. configuration { "x32 or x64" }
  160. links { "libovr" }
  161. else
  162. configuration { "x32" }
  163. libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Win32", _ACTION) }
  164. configuration { "x64" }
  165. libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/x64", _ACTION) }
  166. configuration { "x32", "Debug" }
  167. links { "libovrd" }
  168. configuration { "x32", "Release" }
  169. links { "libovr" }
  170. configuration { "x64", "Debug" }
  171. links { "libovr64d" }
  172. configuration { "x64", "Release" }
  173. links { "libovr64" }
  174. end
  175. configuration {}
  176. end
  177. configuration { "vs*" }
  178. linkoptions {
  179. "/ignore:4199", -- LNK4199: /DELAYLOAD:*.dll ignored; no imports found from *.dll
  180. }
  181. links { -- this is needed only for testing with GLES2/3 on Windows with VS2008
  182. "DelayImp",
  183. }
  184. configuration { "vs201*" }
  185. linkoptions { -- this is needed only for testing with GLES2/3 on Windows with VS201x
  186. "/DELAYLOAD:\"libEGL.dll\"",
  187. "/DELAYLOAD:\"libGLESv2.dll\"",
  188. }
  189. configuration { "mingw*" }
  190. targetextension ".exe"
  191. configuration { "vs20* or mingw*" }
  192. links {
  193. "gdi32",
  194. "psapi",
  195. }
  196. configuration { "winphone8* or winstore8*" }
  197. removelinks {
  198. "DelayImp",
  199. "gdi32",
  200. "psapi"
  201. }
  202. links {
  203. "d3d11",
  204. "dxgi"
  205. }
  206. linkoptions {
  207. "/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
  208. }
  209. -- WinRT targets need their own output directories or build files stomp over each other
  210. configuration { "x32", "winphone8* or winstore8*" }
  211. targetdir (path.join(BGFX_BUILD_DIR, "win32_" .. _ACTION, "bin", _name))
  212. objdir (path.join(BGFX_BUILD_DIR, "win32_" .. _ACTION, "obj", _name))
  213. configuration { "x64", "winphone8* or winstore8*" }
  214. targetdir (path.join(BGFX_BUILD_DIR, "win64_" .. _ACTION, "bin", _name))
  215. objdir (path.join(BGFX_BUILD_DIR, "win64_" .. _ACTION, "obj", _name))
  216. configuration { "ARM", "winphone8* or winstore8*" }
  217. targetdir (path.join(BGFX_BUILD_DIR, "arm_" .. _ACTION, "bin", _name))
  218. objdir (path.join(BGFX_BUILD_DIR, "arm_" .. _ACTION, "obj", _name))
  219. configuration { "mingw-clang" }
  220. kind "ConsoleApp"
  221. configuration { "android*" }
  222. kind "ConsoleApp"
  223. targetextension ".so"
  224. linkoptions {
  225. "-shared",
  226. }
  227. links {
  228. "EGL",
  229. "GLESv2",
  230. }
  231. configuration { "nacl*" }
  232. kind "ConsoleApp"
  233. targetextension ".nexe"
  234. links {
  235. "ppapi",
  236. "ppapi_gles2",
  237. "pthread",
  238. }
  239. configuration { "pnacl" }
  240. kind "ConsoleApp"
  241. targetextension ".pexe"
  242. links {
  243. "ppapi",
  244. "ppapi_gles2",
  245. "pthread",
  246. }
  247. configuration { "asmjs" }
  248. kind "ConsoleApp"
  249. targetextension ".bc"
  250. configuration { "linux-* or freebsd" }
  251. links {
  252. "X11",
  253. "GL",
  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 "examples"
  304. dofile "example-common.lua"
  305. group "libs"
  306. bgfxProject("", "StaticLib", {})
  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. -- 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 "makedisttex.lua"
  346. dofile "shaderc.lua"
  347. dofile "texturec.lua"
  348. dofile "geometryc.lua"
  349. end