genie.lua 8.5 KB

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