premake4.lua 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. --
  2. -- Copyright 2010-2012 Branimir Karadzic. All rights reserved.
  3. -- License: http://www.opensource.org/licenses/BSD-2-Clause
  4. --
  5. solution "bgfx"
  6. configurations {
  7. "Debug",
  8. "Release",
  9. }
  10. platforms {
  11. "x32",
  12. "x64",
  13. "Xbox360",
  14. }
  15. language "C++"
  16. newoption {
  17. trigger = "gcc",
  18. value = "GCC",
  19. description = "Choose GCC flavor",
  20. allowed = {
  21. { "emscripten", "Emscripten" },
  22. { "linux", "Linux" },
  23. { "mingw", "MinGW" },
  24. { "nacl", "Native Client" },
  25. { "pnacl", "Native Client - PNaCl" },
  26. }
  27. }
  28. -- Avoid error when invoking premake4 --help.
  29. if (_ACTION == nil) then return end
  30. BGFX_DIR = (path.getabsolute("..") .. "/")
  31. local BGFX_BUILD_DIR = (BGFX_DIR .. ".build/")
  32. local BGFX_THIRD_PARTY_DIR = (BGFX_DIR .. "3rdparty/")
  33. BX_DIR = (BGFX_DIR .. "../bx/")
  34. local XEDK = os.getenv("XEDK")
  35. if not XEDK then XEDK = "<you must install XBOX SDK>" end
  36. location (BGFX_BUILD_DIR .. "projects/" .. _ACTION)
  37. if _ACTION == "clean" then
  38. os.rmdir(BUILD_DIR)
  39. end
  40. if _ACTION == "gmake" then
  41. if nil == _OPTIONS["gcc"] then
  42. print("GCC flavor must be specified!")
  43. os.exit(1)
  44. end
  45. flags {
  46. "ExtraWarnings",
  47. }
  48. if "emscripten" == _OPTIONS["gcc"] then
  49. if not os.getenv("EMSCRIPTEN") then
  50. print("Set EMSCRIPTEN enviroment variables.")
  51. end
  52. premake.gcc.cc = "$(EMSCRIPTEN)/emcc"
  53. premake.gcc.cxx = "$(EMSCRIPTEN)/em++"
  54. premake.gcc.ar = "$(EMSCRIPTEN)/emar"
  55. location (BGFX_BUILD_DIR .. "projects/" .. _ACTION .. "-emscripten")
  56. end
  57. if "linux" == _OPTIONS["gcc"] then
  58. location (BGFX_BUILD_DIR .. "projects/" .. _ACTION .. "-linux")
  59. end
  60. if "mingw" == _OPTIONS["gcc"] then
  61. premake.gcc.cc = "$(MINGW)/bin/mingw32-gcc"
  62. premake.gcc.cxx = "$(MINGW)/bin/mingw32-g++"
  63. premake.gcc.ar = "$(MINGW)/bin/ar"
  64. location (BGFX_BUILD_DIR .. "projects/" .. _ACTION .. "-mingw")
  65. end
  66. if "nacl" == _OPTIONS["gcc"] then
  67. if not os.getenv("NACL") then
  68. print("Set NACL enviroment variables.")
  69. end
  70. premake.gcc.cc = "$(NACL)/bin/x86_64-nacl-gcc"
  71. premake.gcc.cxx = "$(NACL)/bin/x86_64-nacl-g++"
  72. premake.gcc.ar = "$(NACL)/bin/x86_64-nacl-ar"
  73. location (BGFX_BUILD_DIR .. "projects/" .. _ACTION .. "-nacl")
  74. end
  75. if "pnacl" == _OPTIONS["gcc"] then
  76. if not os.getenv("PNACL") then
  77. print("Set PNACL enviroment variables.")
  78. end
  79. premake.gcc.cc = "$(PNACL)/bin/pnacl-clang"
  80. premake.gcc.cxx = "$(PNACL)/bin/pnacl-clang++"
  81. premake.gcc.ar = "$(PNACL)/bin/pnacl-ar"
  82. location (BGFX_BUILD_DIR .. "projects/" .. _ACTION .. "-pnacl")
  83. end
  84. end
  85. flags {
  86. "StaticRuntime",
  87. "NoMinimalRebuild",
  88. "NoPCH",
  89. "NativeWChar",
  90. "NoRTTI",
  91. "NoExceptions",
  92. "NoEditAndContinue",
  93. "Symbols",
  94. }
  95. defines {
  96. "__STDC_LIMIT_MACROS",
  97. "__STDC_FORMAT_MACROS",
  98. "__STDC_CONSTANT_MACROS",
  99. }
  100. configuration "Debug"
  101. targetsuffix "Debug"
  102. configuration "Release"
  103. flags {
  104. "OptimizeSpeed",
  105. }
  106. targetsuffix "Release"
  107. configuration { "vs*" }
  108. includedirs { BX_DIR .. "include/compat/msvc" }
  109. defines {
  110. "WIN32",
  111. "_WIN32",
  112. "_HAS_EXCEPTIONS=0",
  113. "_HAS_ITERATOR_DEBUGGING=0",
  114. "_SCL_SECURE=0",
  115. "_SECURE_SCL=0",
  116. "_SCL_SECURE_NO_WARNINGS",
  117. "_CRT_SECURE_NO_WARNINGS",
  118. "_CRT_SECURE_NO_DEPRECATE",
  119. }
  120. buildoptions {
  121. "/Oy-", -- Suppresses creation of frame pointers on the call stack.
  122. "/Ob2", -- The Inline Function Expansion
  123. }
  124. configuration { "x32", "vs*" }
  125. targetdir (BGFX_BUILD_DIR .. "win32_" .. _ACTION .. "/bin")
  126. objdir (BGFX_BUILD_DIR .. "win32_" .. _ACTION .. "/obj")
  127. libdirs { BGFX_THIRD_PARTY_DIR .. "lib/win32_" .. _ACTION }
  128. configuration { "x64", "vs*" }
  129. defines { "_WIN64" }
  130. targetdir (BGFX_BUILD_DIR .. "win64_" .. _ACTION .. "/bin")
  131. objdir (BGFX_BUILD_DIR .. "win64_" .. _ACTION .. "/obj")
  132. libdirs { BGFX_THIRD_PARTY_DIR .. "lib/win64_" .. _ACTION }
  133. configuration { "mingw" }
  134. defines { "WIN32" }
  135. includedirs { BX_DIR .. "include/compat/mingw" }
  136. buildoptions {
  137. "-std=c++0x",
  138. "-U__STRICT_ANSI__",
  139. "-Wunused-value",
  140. "-fdata-sections",
  141. "-ffunction-sections",
  142. -- "-fmerge-all-constants"
  143. }
  144. linkoptions {
  145. "-Wl,--gc-sections",
  146. }
  147. configuration { "x32", "mingw" }
  148. targetdir (BGFX_BUILD_DIR .. "win32_mingw" .. "/bin")
  149. objdir (BGFX_BUILD_DIR .. "win32_mingw" .. "/obj")
  150. libdirs { BGFX_THIRD_PARTY_DIR .. "lib/win32_mingw" }
  151. buildoptions { "-m32" }
  152. configuration { "x64", "mingw" }
  153. targetdir (BGFX_BUILD_DIR .. "win64_mingw" .. "/bin")
  154. objdir (BGFX_BUILD_DIR .. "win64_mingw" .. "/obj")
  155. libdirs { BGFX_THIRD_PARTY_DIR .. "lib/win64_mingw" }
  156. buildoptions { "-m64" }
  157. configuration { "linux" }
  158. buildoptions {
  159. "-std=c++0x",
  160. "-U__STRICT_ANSI__",
  161. "-Wunused-value",
  162. "-mfpmath=sse", -- force SSE to get 32-bit and 64-bit builds deterministic.
  163. "-msse2",
  164. }
  165. links {
  166. "rt",
  167. }
  168. linkoptions {
  169. "-Wl,--gc-sections",
  170. }
  171. configuration { "linux", "x32" }
  172. targetdir (BGFX_BUILD_DIR .. "linux32_gcc" .. "/bin")
  173. objdir (BGFX_BUILD_DIR .. "linux32_gcc" .. "/obj")
  174. libdirs { BGFX_THIRD_PARTY_DIR .. "lib/linux32_gcc" }
  175. buildoptions {
  176. "-m32",
  177. }
  178. configuration { "linux", "x64" }
  179. targetdir (BGFX_BUILD_DIR .. "linux64_gcc" .. "/bin")
  180. objdir (BGFX_BUILD_DIR .. "linux64_gcc" .. "/obj")
  181. libdirs { BGFX_THIRD_PARTY_DIR .. "lib/linux64_gcc" }
  182. buildoptions {
  183. "-m64",
  184. }
  185. configuration { "emscripten" }
  186. targetdir (BGFX_BUILD_DIR .. "emscripten" .. "/bin")
  187. objdir (BGFX_BUILD_DIR .. "emscripten" .. "/obj")
  188. libdirs { BGFX_THIRD_PARTY_DIR .. "lib/emscripten" }
  189. includedirs { "$(EMSCRIPTEN)/system/include" }
  190. buildoptions {
  191. "-pthread",
  192. }
  193. configuration { "nacl" }
  194. defines { "_BSD_SOURCE=1", "_POSIX_C_SOURCE=199506", "_XOPEN_SOURCE=600" }
  195. includedirs { BX_DIR .. "include/compat/nacl" }
  196. buildoptions {
  197. "-std=c++0x",
  198. "-U__STRICT_ANSI__",
  199. "-pthread",
  200. "-fno-stack-protector",
  201. "-fdiagnostics-show-option",
  202. "-Wunused-value",
  203. "-fdata-sections",
  204. "-ffunction-sections",
  205. "-mfpmath=sse", -- force SSE to get 32-bit and 64-bit builds deterministic.
  206. "-msse2",
  207. -- "-fmerge-all-constants",
  208. }
  209. linkoptions {
  210. "-Wl,--gc-sections",
  211. }
  212. configuration { "x32", "nacl" }
  213. targetdir (BGFX_BUILD_DIR .. "nacl-x86" .. "/bin")
  214. objdir (BGFX_BUILD_DIR .. "nacl-x86" .. "/obj")
  215. libdirs { BGFX_THIRD_PARTY_DIR .. "lib/nacl-x86" }
  216. linkoptions { "-melf32_nacl" }
  217. configuration { "x64", "nacl" }
  218. targetdir (BGFX_BUILD_DIR .. "nacl-x64" .. "/bin")
  219. objdir (BGFX_BUILD_DIR .. "nacl-x64" .. "/obj")
  220. libdirs { BGFX_THIRD_PARTY_DIR .. "lib/nacl-x64" }
  221. linkoptions { "-melf64_nacl" }
  222. configuration { "pnacl" }
  223. defines { "_BSD_SOURCE=1", "_POSIX_C_SOURCE=199506", "_XOPEN_SOURCE=600", "__native_client__", "__LITTLE_ENDIAN__" }
  224. includedirs { BX_DIR .. "include/compat/nacl" }
  225. buildoptions {
  226. "-std=c++0x",
  227. "-U__STRICT_ANSI__",
  228. "-fno-stack-protector",
  229. "-fdiagnostics-show-option",
  230. "-Wunused-value",
  231. "-fdata-sections",
  232. "-ffunction-sections",
  233. }
  234. targetdir (BGFX_BUILD_DIR .. "pnacl" .. "/bin")
  235. objdir (BGFX_BUILD_DIR .. "pnacl" .. "/obj")
  236. libdirs { BGFX_THIRD_PARTY_DIR .. "lib/pnacl" }
  237. includedirs { "$(PNACL)/sysroot/include" }
  238. configuration { "Xbox360" }
  239. targetdir (BGFX_BUILD_DIR .. "xbox360" .. "/bin")
  240. objdir (BGFX_BUILD_DIR .. "xbox360" .. "/obj")
  241. includedirs { BX_DIR .. "include/compat/msvc" }
  242. libdirs { BGFX_THIRD_PARTY_DIR .. "lib/xbox360" }
  243. defines {
  244. "NOMINMAX",
  245. "_XBOX",
  246. }
  247. configuration {} -- reset configuration
  248. function copyLib()
  249. end
  250. dofile "bgfx.lua"
  251. dofile "makedisttex.lua"
  252. dofile "shaderc.lua"
  253. dofile "texturec.lua"
  254. dofile "openctm.lua"
  255. dofile "example-00-helloworld.lua"
  256. dofile "example-01-cubes.lua"
  257. dofile "example-02-metaballs.lua"
  258. dofile "example-03-raymarch.lua"
  259. dofile "example-04-mesh.lua"
  260. dofile "example-05-instancing.lua"
  261. dofile "example-06-bump.lua"