premake4.lua 5.8 KB

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