shaderc.lua 7.3 KB

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