genie.lua 9.4 KB

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