premake4.lua 5.6 KB

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