premake4.lua 6.5 KB

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