shaderc.lua 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. --
  2. -- Copyright 2010-2017 Branimir Karadzic. All rights reserved.
  3. -- License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
  4. --
  5. group "tools/shaderc"
  6. local GLSL_OPTIMIZER = path.join(BGFX_DIR, "3rdparty/glsl-optimizer")
  7. local FCPP_DIR = path.join(BGFX_DIR, "3rdparty/fcpp")
  8. project "glslang"
  9. kind "StaticLib"
  10. local GLSLANG = path.join(BGFX_DIR, "3rdparty/glslang")
  11. configuration { "vs2012" }
  12. defines {
  13. "atoll=_atoi64",
  14. "strtoll=_strtoi64",
  15. "strtoull=_strtoui64",
  16. }
  17. configuration { "vs*" }
  18. buildoptions {
  19. "/wd4005", -- warning C4005: '_CRT_SECURE_NO_WARNINGS': macro redefinition
  20. "/wd4100", -- warning C4100: 'inclusionDepth' : unreferenced formal parameter
  21. "/wd4127", -- warning C4127: conditional expression is constant
  22. "/wd4244", -- warning C4244: '=': conversion from 'int' to 'char', possible loss of data
  23. "/wd4456", -- warning C4456: declaration of 'feature' hides previous local declaration
  24. "/wd4457", -- warning C4457: declaration of 'token' hides function parameter
  25. "/wd4458", -- warning C4458: declaration of 'language' hides class member
  26. "/wd4702", -- warning C4702: unreachable code
  27. }
  28. configuration { "not vs*" }
  29. buildoptions {
  30. -- "-Wno-deprecated-register",
  31. "-Wno-ignored-qualifiers",
  32. -- "-Wno-inconsistent-missing-override",
  33. "-Wno-missing-field-initializers",
  34. "-Wno-reorder",
  35. "-Wno-return-type",
  36. "-Wno-shadow",
  37. "-Wno-sign-compare",
  38. "-Wno-undef",
  39. "-Wno-unknown-pragmas",
  40. "-Wno-unused-function",
  41. "-Wno-unused-parameter",
  42. "-Wno-unused-variable",
  43. }
  44. configuration { "osx" }
  45. buildoptions {
  46. "-Wno-c++11-extensions",
  47. "-Wno-unused-const-variable",
  48. }
  49. configuration { "linux-*" }
  50. buildoptions {
  51. "-Wno-unused-but-set-variable",
  52. }
  53. configuration {}
  54. defines {
  55. "ENABLE_HLSL=1",
  56. }
  57. includedirs {
  58. GLSLANG,
  59. }
  60. files {
  61. path.join(GLSLANG, "glslang/**.cpp"),
  62. path.join(GLSLANG, "glslang/**.h"),
  63. path.join(GLSLANG, "hlsl/**.cpp"),
  64. path.join(GLSLANG, "hlsl/**.h"),
  65. path.join(GLSLANG, "SPIRV/**.cpp"),
  66. path.join(GLSLANG, "SPIRV/**.h"),
  67. path.join(GLSLANG, "OGLCompilersDLL/**.cpp"),
  68. path.join(GLSLANG, "OGLCompilersDLL/**.h"),
  69. }
  70. removefiles {
  71. path.join(GLSLANG, "glslang/OSDependent/Unix/main.cpp"),
  72. path.join(GLSLANG, "glslang/OSDependent/Windows/main.cpp"),
  73. }
  74. configuration { "windows" }
  75. removefiles {
  76. path.join(GLSLANG, "glslang/OSDependent/Unix/**.cpp"),
  77. path.join(GLSLANG, "glslang/OSDependent/Unix/**.h"),
  78. }
  79. configuration { "not windows" }
  80. removefiles {
  81. path.join(GLSLANG, "glslang/OSDependent/Windows/**.cpp"),
  82. path.join(GLSLANG, "glslang/OSDependent/Windows/**.h"),
  83. }
  84. configuration {}
  85. project "glsl-optimizer"
  86. kind "StaticLib"
  87. includedirs {
  88. path.join(GLSL_OPTIMIZER, "src"),
  89. path.join(GLSL_OPTIMIZER, "include"),
  90. path.join(GLSL_OPTIMIZER, "src/mesa"),
  91. path.join(GLSL_OPTIMIZER, "src/mapi"),
  92. path.join(GLSL_OPTIMIZER, "src/glsl"),
  93. }
  94. files {
  95. path.join(GLSL_OPTIMIZER, "src/mesa/**.c"),
  96. path.join(GLSL_OPTIMIZER, "src/glsl/**.cpp"),
  97. path.join(GLSL_OPTIMIZER, "src/mesa/**.h"),
  98. path.join(GLSL_OPTIMIZER, "src/glsl/**.c"),
  99. path.join(GLSL_OPTIMIZER, "src/glsl/**.cpp"),
  100. path.join(GLSL_OPTIMIZER, "src/glsl/**.h"),
  101. path.join(GLSL_OPTIMIZER, "src/util/**.c"),
  102. path.join(GLSL_OPTIMIZER, "src/util/**.h"),
  103. }
  104. removefiles {
  105. path.join(GLSL_OPTIMIZER, "src/glsl/glcpp/glcpp.c"),
  106. path.join(GLSL_OPTIMIZER, "src/glsl/glcpp/tests/**"),
  107. path.join(GLSL_OPTIMIZER, "src/glsl/glcpp/**.l"),
  108. path.join(GLSL_OPTIMIZER, "src/glsl/glcpp/**.y"),
  109. path.join(GLSL_OPTIMIZER, "src/glsl/ir_set_program_inouts.cpp"),
  110. path.join(GLSL_OPTIMIZER, "src/glsl/main.cpp"),
  111. path.join(GLSL_OPTIMIZER, "src/glsl/builtin_stubs.cpp"),
  112. }
  113. configuration { "Release" }
  114. flags {
  115. "Optimize",
  116. }
  117. removeflags {
  118. -- GCC 4.9 -O2 + -fno-strict-aliasing don't work together...
  119. "OptimizeSpeed",
  120. }
  121. configuration { "vs*" }
  122. includedirs {
  123. path.join(GLSL_OPTIMIZER, "src/glsl/msvc"),
  124. }
  125. defines { -- glsl-optimizer
  126. "__STDC__",
  127. "__STDC_VERSION__=199901L",
  128. "strdup=_strdup",
  129. "alloca=_alloca",
  130. "isascii=__isascii",
  131. }
  132. buildoptions {
  133. "/wd4100", -- error C4100: '' : unreferenced formal parameter
  134. "/wd4127", -- warning C4127: conditional expression is constant
  135. "/wd4132", -- warning C4132: 'deleted_key_value': const object should be initialized
  136. "/wd4189", -- warning C4189: 'interface_type': local variable is initialized but not referenced
  137. "/wd4204", -- warning C4204: nonstandard extension used: non-constant aggregate initializer
  138. "/wd4244", -- warning C4244: '=': conversion from 'const flex_int32_t' to 'YY_CHAR', possible loss of data
  139. "/wd4389", -- warning C4389: '!=': signed/unsigned mismatch
  140. "/wd4245", -- warning C4245: 'return': conversion from 'int' to 'unsigned int', signed/unsigned mismatch
  141. "/wd4701", -- warning C4701: potentially uninitialized local variable 'lower' used
  142. "/wd4702", -- warning C4702: unreachable code
  143. "/wd4706", -- warning C4706: assignment within conditional expression
  144. "/wd4996" -- warning C4996: 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup.
  145. }
  146. configuration { "mingw* or linux or osx" }
  147. buildoptions {
  148. "-fno-strict-aliasing", -- glsl-optimizer has bugs if strict aliasing is used.
  149. "-Wno-unused-parameter",
  150. }
  151. removebuildoptions {
  152. "-Wshadow", -- glsl-optimizer is full of -Wshadow warnings ignore it.
  153. }
  154. configuration {}
  155. project "fcpp"
  156. kind "StaticLib"
  157. defines { -- fcpp
  158. "NINCLUDE=64",
  159. "NWORK=65536",
  160. "NBUFF=65536",
  161. "OLD_PREPROCESSOR=0",
  162. }
  163. files {
  164. path.join(FCPP_DIR, "**.h"),
  165. path.join(FCPP_DIR, "cpp1.c"),
  166. path.join(FCPP_DIR, "cpp2.c"),
  167. path.join(FCPP_DIR, "cpp3.c"),
  168. path.join(FCPP_DIR, "cpp4.c"),
  169. path.join(FCPP_DIR, "cpp5.c"),
  170. path.join(FCPP_DIR, "cpp6.c"),
  171. path.join(FCPP_DIR, "cpp6.c"),
  172. }
  173. configuration { "vs*" }
  174. buildoptions {
  175. "/wd4055", -- warning C4055: 'type cast': from data pointer 'void *' to function pointer 'void (__cdecl *)(char *,void *)'
  176. "/wd4244", -- warning C4244: '=': conversion from 'const flex_int32_t' to 'YY_CHAR', possible loss of data
  177. "/wd4701", -- warning C4701: potentially uninitialized local variable 'lower' used
  178. "/wd4706", -- warning C4706: assignment within conditional expression
  179. }
  180. configuration { "not vs*" }
  181. buildoptions {
  182. "-Wno-implicit-fallthrough",
  183. }
  184. configuration {}
  185. project "shaderc"
  186. kind "ConsoleApp"
  187. includedirs {
  188. path.join(BX_DIR, "include"),
  189. path.join(BIMG_DIR, "include"),
  190. path.join(BGFX_DIR, "include"),
  191. path.join(BGFX_DIR, "3rdparty/dxsdk/include"),
  192. FCPP_DIR,
  193. path.join(BGFX_DIR, "3rdparty/glslang/glslang/Public"),
  194. path.join(BGFX_DIR, "3rdparty/glslang/glslang/Include"),
  195. path.join(BGFX_DIR, "3rdparty/glslang"),
  196. path.join(GLSL_OPTIMIZER, "include"),
  197. path.join(GLSL_OPTIMIZER, "src/glsl"),
  198. }
  199. links {
  200. "bx",
  201. "fcpp",
  202. "glslang",
  203. "glsl-optimizer",
  204. }
  205. files {
  206. path.join(BGFX_DIR, "tools/shaderc/**.cpp"),
  207. path.join(BGFX_DIR, "tools/shaderc/**.h"),
  208. path.join(BGFX_DIR, "src/vertexdecl.**"),
  209. path.join(BGFX_DIR, "src/shader_spirv.**"),
  210. }
  211. configuration { "mingw-*" }
  212. targetextension ".exe"
  213. configuration { "osx" }
  214. links {
  215. "Cocoa.framework",
  216. }
  217. configuration { "vs*" }
  218. includedirs {
  219. path.join(GLSL_OPTIMIZER, "include/c99"),
  220. }
  221. configuration { "vs20* or mingw*" }
  222. links {
  223. "psapi",
  224. }
  225. configuration {}
  226. if filesexist(BGFX_DIR, path.join(BGFX_DIR, "../bgfx-ext"), {
  227. path.join(BGFX_DIR, "scripts/shaderc.lua"), }) then
  228. if filesexist(BGFX_DIR, path.join(BGFX_DIR, "../bgfx-ext"), {
  229. path.join(BGFX_DIR, "tools/shaderc/shaderc_pssl.cpp"), }) then
  230. removefiles {
  231. path.join(BGFX_DIR, "tools/shaderc/shaderc_pssl.cpp"),
  232. }
  233. end
  234. dofile(path.join(BGFX_DIR, "../bgfx-ext/scripts/shaderc.lua") )
  235. end
  236. configuration { "osx or linux*" }
  237. links {
  238. "pthread",
  239. }
  240. configuration {}
  241. strip()
  242. group "tools"