premake4.lua 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  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. { "mingw", "MinGW" },
  22. { "nacl", "Google Native Client" },
  23. }
  24. }
  25. -- Avoid error when invoking premake4 --help.
  26. if (_ACTION == nil) then return end
  27. ROOT_DIR = (path.getabsolute("..") .. "/")
  28. BUILD_DIR = (ROOT_DIR .. ".build/")
  29. THIRD_PARTY_DIR = (ROOT_DIR .. "3rdparty/")
  30. local XEDK = os.getenv("XEDK")
  31. if not XEDK then XEDK = "<you must install XBOX SDK>" end
  32. location (BUILD_DIR .. "projects/" .. _ACTION)
  33. if _ACTION == "gmake" then
  34. flags {
  35. "ExtraWarnings",
  36. }
  37. if "linux" ~= os.get() and nil == _OPTIONS["gcc"] then
  38. print("GCC flavor must be specified!")
  39. os.exit(1)
  40. end
  41. if "mingw" == _OPTIONS["gcc"] then
  42. premake.gcc.cc = "$(MINGW)/bin/mingw32-gcc"
  43. premake.gcc.cxx = "$(MINGW)/bin/mingw32-g++"
  44. premake.gcc.ar = "$(MINGW)/bin/ar"
  45. end
  46. if "nacl" == _OPTIONS["gcc"] then
  47. if not os.getenv("NACL") then
  48. print("Set NACL enviroment variables.")
  49. end
  50. premake.gcc.cc = "$(NACL)/bin/x86_64-nacl-gcc"
  51. premake.gcc.cxx = "$(NACL)/bin/x86_64-nacl-g++"
  52. premake.gcc.ar = "$(NACL)/bin/x86_64-nacl-ar"
  53. location (BUILD_DIR .. "projects/" .. _ACTION .. "-nacl")
  54. end
  55. end
  56. flags {
  57. "StaticRuntime",
  58. "NoMinimalRebuild",
  59. "NoPCH",
  60. "NativeWChar",
  61. "NoRTTI",
  62. "NoExceptions",
  63. "NoEditAndContinue",
  64. "Symbols",
  65. }
  66. includedirs {
  67. ROOT_DIR .. "../bx/include",
  68. }
  69. configuration "Debug"
  70. targetsuffix "Debug"
  71. configuration "Release"
  72. flags {
  73. "OptimizeSpeed",
  74. }
  75. targetsuffix "Release"
  76. configuration { "vs*" }
  77. defines {
  78. "_HAS_EXCEPTIONS=0",
  79. "_HAS_ITERATOR_DEBUGGING=0",
  80. "_SCL_SECURE=0",
  81. "_CRT_SECURE_NO_WARNINGS",
  82. "_CRT_SECURE_NO_DEPRECATE",
  83. "__STDC_LIMIT_MACROS",
  84. "__STDC_FORMAT_MACROS",
  85. "__STDC_CONSTANT_MACROS",
  86. }
  87. configuration { "x32", "vs*" }
  88. defines { "WIN32" }
  89. targetdir (BUILD_DIR .. "win32_" .. _ACTION .. "/bin")
  90. objdir (BUILD_DIR .. "win32_" .. _ACTION .. "/obj")
  91. includedirs { THIRD_PARTY_DIR .. "compiler/msvc" }
  92. configuration { "x64", "vs*" }
  93. defines { "WIN32" }
  94. targetdir (BUILD_DIR .. "win64_" .. _ACTION .. "/bin")
  95. objdir (BUILD_DIR .. "win64_" .. _ACTION .. "/obj")
  96. includedirs { THIRD_PARTY_DIR .. "compiler/msvc" }
  97. configuration { "x32", "mingw" }
  98. defines { "WIN32" }
  99. targetdir (BUILD_DIR .. "win32_mingw" .. "/bin")
  100. objdir (BUILD_DIR .. "win32_mingw" .. "/obj")
  101. includedirs { THIRD_PARTY_DIR .. "compiler/mingw" }
  102. configuration { "x64", "mingw" }
  103. defines { "WIN32" }
  104. targetdir (BUILD_DIR .. "win64_mingw" .. "/bin")
  105. objdir (BUILD_DIR .. "win64_mingw" .. "/obj")
  106. includedirs { THIRD_PARTY_DIR .. "compiler/mingw" }
  107. configuration { "nacl" }
  108. defines { "_BSD_SOURCE=1", "_POSIX_C_SOURCE=199506", "_XOPEN_SOURCE=600" }
  109. links {
  110. "ppapi",
  111. "ppapi_gles2",
  112. }
  113. includedirs { THIRD_PARTY_DIR .. "compiler/nacl" }
  114. buildoptions {
  115. "-std=c++0x",
  116. "-U__STRICT_ANSI__",
  117. "-pthread",
  118. "-fno-stack-protector",
  119. "-fdiagnostics-show-option",
  120. "-Wunused-value",
  121. "-fdata-sections",
  122. "-ffunction-sections",
  123. "-mfpmath=sse", -- force SSE to get 32-bit and 64-bit builds deterministic.
  124. "-msse2",
  125. -- "-fmerge-all-constants",
  126. }
  127. linkoptions {
  128. "-Wl,--gc-sections",
  129. }
  130. configuration { "x32", "nacl" }
  131. targetdir (BUILD_DIR .. "nacl-x86" .. "/bin")
  132. objdir (BUILD_DIR .. "nacl-x86" .. "/obj")
  133. libdirs { THIRD_PARTY_DIR .. "lib/nacl-x86" }
  134. linkoptions {
  135. "-melf32_nacl",
  136. }
  137. configuration { "x64", "nacl" }
  138. targetdir (BUILD_DIR .. "nacl-x64" .. "/bin")
  139. objdir (BUILD_DIR .. "nacl-x64" .. "/obj")
  140. libdirs { THIRD_PARTY_DIR .. "lib/nacl-x64" }
  141. linkoptions {
  142. "-melf64_nacl",
  143. }
  144. configuration { "x32", "linux" }
  145. targetdir (BUILD_DIR .. "linux32" .. "/bin")
  146. objdir (BUILD_DIR .. "linux32" .. "/obj")
  147. configuration { "x64", "linux" }
  148. targetdir (BUILD_DIR .. "linux64" .. "/bin")
  149. objdir (BUILD_DIR .. "linux64" .. "/obj")
  150. configuration { "Xbox360" }
  151. defines { "_XBOX", "NOMINMAX" }
  152. targetdir (BUILD_DIR .. "xbox360" .. "/bin")
  153. objdir (BUILD_DIR .. "xbox360" .. "/obj")
  154. includedirs { THIRD_PARTY_DIR .. "compiler/msvc" }
  155. configuration {} -- reset configuration
  156. project "bgfx"
  157. uuid "f4c51860-ebf4-11e0-9572-0800200c9a66"
  158. kind "StaticLib"
  159. includedirs {
  160. "../include",
  161. ROOT_DIR .. "../bx/include",
  162. THIRD_PARTY_DIR .. "glew-1.5.4/include",
  163. }
  164. files {
  165. "../include/**.h",
  166. "../src/**.cpp",
  167. "../src/**.h",
  168. }
  169. project "shaderc"
  170. uuid "f3cd2e90-52a4-11e1-b86c-0800200c9a66"
  171. kind "ConsoleApp"
  172. local GLSL_OPTIMIZER = (THIRD_PARTY_DIR .. "glsl-optimizer/")
  173. configuration { "vs*" }
  174. includedirs { GLSL_OPTIMIZER .. "src/glsl/msvc" }
  175. configuration {}
  176. includedirs {
  177. ROOT_DIR .. "../bx/include",
  178. THIRD_PARTY_DIR .. "fcpp",
  179. GLSL_OPTIMIZER .. "include",
  180. GLSL_OPTIMIZER .. "include/c99",
  181. GLSL_OPTIMIZER .. "src/mesa",
  182. GLSL_OPTIMIZER .. "src/mapi",
  183. GLSL_OPTIMIZER .. "src/glsl",
  184. }
  185. files {
  186. ROOT_DIR .. "tools/shaderc.cpp",
  187. THIRD_PARTY_DIR .. "fcpp/**.h",
  188. THIRD_PARTY_DIR .. "fcpp/cpp1.c",
  189. THIRD_PARTY_DIR .. "fcpp/cpp2.c",
  190. THIRD_PARTY_DIR .. "fcpp/cpp3.c",
  191. THIRD_PARTY_DIR .. "fcpp/cpp4.c",
  192. THIRD_PARTY_DIR .. "fcpp/cpp5.c",
  193. THIRD_PARTY_DIR .. "fcpp/cpp6.c",
  194. THIRD_PARTY_DIR .. "fcpp/cpp6.c",
  195. GLSL_OPTIMIZER .. "src/mesa/**.c",
  196. GLSL_OPTIMIZER .. "src/glsl/**.cpp",
  197. GLSL_OPTIMIZER .. "src/mesa/**.h",
  198. GLSL_OPTIMIZER .. "src/glsl/**.c",
  199. GLSL_OPTIMIZER .. "src/glsl/**.cpp",
  200. GLSL_OPTIMIZER .. "src/glsl/**.h",
  201. }
  202. excludes {
  203. GLSL_OPTIMIZER .. "src/glsl/glcpp/glcpp.c",
  204. GLSL_OPTIMIZER .. "src/glsl/glcpp/tests/**",
  205. GLSL_OPTIMIZER .. "src/glsl/main.cpp",
  206. GLSL_OPTIMIZER .. "src/glsl/builtin_stubs.cpp",
  207. }
  208. links {
  209. "d3dx9",
  210. }
  211. project "ddsdump"
  212. uuid "838801ee-7bc3-11e1-9f19-eae7d36e7d26"
  213. kind "ConsoleApp"
  214. includedirs {
  215. ROOT_DIR .. "../bx/include",
  216. ROOT_DIR .. "include",
  217. ROOT_DIR .. "src",
  218. }
  219. files {
  220. ROOT_DIR .. "src/dds.*",
  221. ROOT_DIR .. "tools/ddsdump.cpp",
  222. }
  223. links {
  224. "bgfx",
  225. }
  226. project "makedisttex"
  227. uuid "b0561b30-91bb-11e1-b06e-023ad46e7d26"
  228. kind "ConsoleApp"
  229. includedirs {
  230. ROOT_DIR .. "../bx/include",
  231. THIRD_PARTY_DIR .. "edtaa3",
  232. THIRD_PARTY_DIR .. "stb_image",
  233. }
  234. files {
  235. THIRD_PARTY_DIR .. "edtaa3/**",
  236. ROOT_DIR .. "tools/makedisttex.cpp",
  237. }
  238. project "helloworld"
  239. uuid "ff2c8450-ebf4-11e0-9572-0800200c9a66"
  240. kind "WindowedApp"
  241. includedirs {
  242. ROOT_DIR .. "include",
  243. }
  244. files {
  245. ROOT_DIR .. "examples/common/**.cpp",
  246. ROOT_DIR .. "examples/common/**.h",
  247. ROOT_DIR .. "examples/helloworld/**.cpp",
  248. ROOT_DIR .. "examples/helloworld/**.h",
  249. }
  250. links {
  251. "bgfx",
  252. }
  253. configuration { "nacl" }
  254. targetextension ".nexe"
  255. configuration { "nacl", "Release" }
  256. postbuildcommands {
  257. "@echo Stripping symbols.",
  258. "@$(NACL)/bin/x86_64-nacl-strip -s \"$(TARGET)\""
  259. }