shaderc.lua 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. --
  2. -- Copyright 2010-2017 Branimir Karadzic. All rights reserved.
  3. -- License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
  4. --
  5. project "glslang"
  6. kind "StaticLib"
  7. local GLSLANG = path.join(BGFX_DIR, "3rdparty/glslang")
  8. configuration { "vs2012" }
  9. defines {
  10. "atoll=_atoi64",
  11. "strtoll=_strtoi64",
  12. "strtoull=_strtoui64",
  13. }
  14. configuration { "vs*" }
  15. buildoptions {
  16. "/wd4005", -- warning C4005: '_CRT_SECURE_NO_WARNINGS': macro redefinition
  17. "/wd4100", -- error C4100: 'inclusionDepth' : unreferenced formal parameter
  18. }
  19. configuration { "not vs*" }
  20. buildoptions {
  21. "-Wno-deprecated-register",
  22. "-Wno-ignored-qualifiers",
  23. "-Wno-inconsistent-missing-override",
  24. "-Wno-missing-field-initializers",
  25. "-Wno-reorder",
  26. "-Wno-return-type",
  27. "-Wno-shadow",
  28. "-Wno-sign-compare",
  29. "-Wno-undef",
  30. "-Wno-unknown-pragmas",
  31. "-Wno-unused-parameter",
  32. "-Wno-unused-variable",
  33. }
  34. configuration { "osx" }
  35. buildoptions {
  36. "-Wno-c++11-extensions",
  37. "-Wno-unused-const-variable",
  38. }
  39. configuration { "linux-*" }
  40. buildoptions {
  41. "-Wno-unused-but-set-variable",
  42. }
  43. configuration {}
  44. defines {
  45. "ENABLE_HLSL=1",
  46. }
  47. includedirs {
  48. GLSLANG,
  49. }
  50. files {
  51. path.join(GLSLANG, "glslang/**.cpp"),
  52. path.join(GLSLANG, "glslang/**.h"),
  53. path.join(GLSLANG, "hlsl/**.cpp"),
  54. path.join(GLSLANG, "hlsl/**.h"),
  55. path.join(GLSLANG, "SPIRV/**.cpp"),
  56. path.join(GLSLANG, "SPIRV/**.h"),
  57. path.join(GLSLANG, "OGLCompilersDLL/**.cpp"),
  58. path.join(GLSLANG, "OGLCompilersDLL/**.h"),
  59. }
  60. removefiles {
  61. path.join(GLSLANG, "glslang/OSDependent/Unix/main.cpp"),
  62. path.join(GLSLANG, "glslang/OSDependent/Windows/main.cpp"),
  63. }
  64. configuration { "windows" }
  65. removefiles {
  66. path.join(GLSLANG, "glslang/OSDependent/Unix/**.cpp"),
  67. path.join(GLSLANG, "glslang/OSDependent/Unix/**.h"),
  68. }
  69. configuration { "not windows" }
  70. removefiles {
  71. path.join(GLSLANG, "glslang/OSDependent/Windows/**.cpp"),
  72. path.join(GLSLANG, "glslang/OSDependent/Windows/**.h"),
  73. }
  74. configuration {}
  75. project "shaderc"
  76. kind "ConsoleApp"
  77. local GLSL_OPTIMIZER = path.join(BGFX_DIR, "3rdparty/glsl-optimizer")
  78. local FCPP_DIR = path.join(BGFX_DIR, "3rdparty/fcpp")
  79. includedirs {
  80. path.join(GLSL_OPTIMIZER, "src"),
  81. }
  82. links {
  83. "bx",
  84. }
  85. configuration { "Release" }
  86. flags {
  87. "Optimize",
  88. }
  89. removeflags {
  90. -- GCC 4.9 -O2 + -fno-strict-aliasing don't work together...
  91. "OptimizeSpeed",
  92. }
  93. configuration { "vs*" }
  94. includedirs {
  95. path.join(GLSL_OPTIMIZER, "src/glsl/msvc"),
  96. }
  97. defines { -- glsl-optimizer
  98. "__STDC__",
  99. "__STDC_VERSION__=199901L",
  100. "strdup=_strdup",
  101. "alloca=_alloca",
  102. "isascii=__isascii",
  103. }
  104. buildoptions {
  105. "/wd4996" -- warning C4996: 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup.
  106. }
  107. configuration { "mingw-*" }
  108. targetextension ".exe"
  109. configuration { "mingw* or linux or osx" }
  110. buildoptions {
  111. "-fno-strict-aliasing", -- glsl-optimizer has bugs if strict aliasing is used.
  112. "-Wno-unused-parameter",
  113. }
  114. removebuildoptions {
  115. "-Wshadow", -- glsl-optimizer is full of -Wshadow warnings ignore it.
  116. }
  117. configuration { "osx" }
  118. links {
  119. "Cocoa.framework",
  120. }
  121. configuration { "vs*" }
  122. includedirs {
  123. path.join(GLSL_OPTIMIZER, "include/c99"),
  124. }
  125. configuration { "vs20* or mingw*" }
  126. links {
  127. "psapi",
  128. }
  129. configuration {}
  130. defines { -- fcpp
  131. "NINCLUDE=64",
  132. "NWORK=65536",
  133. "NBUFF=65536",
  134. "OLD_PREPROCESSOR=0",
  135. }
  136. includedirs {
  137. path.join(BX_DIR, "include"),
  138. path.join(BGFX_DIR, "include"),
  139. path.join(BGFX_DIR, "3rdparty/dxsdk/include"),
  140. FCPP_DIR,
  141. path.join(BGFX_DIR, "3rdparty/glslang/glslang/Public"),
  142. path.join(BGFX_DIR, "3rdparty/glslang/glslang/Include"),
  143. path.join(BGFX_DIR, "3rdparty/glslang"),
  144. -- path.join(BGFX_DIR, "3rdparty/spirv-tools/include"),
  145. path.join(GLSL_OPTIMIZER, "include"),
  146. path.join(GLSL_OPTIMIZER, "src/mesa"),
  147. path.join(GLSL_OPTIMIZER, "src/mapi"),
  148. path.join(GLSL_OPTIMIZER, "src/glsl"),
  149. }
  150. files {
  151. path.join(BGFX_DIR, "tools/shaderc/**.cpp"),
  152. path.join(BGFX_DIR, "tools/shaderc/**.h"),
  153. path.join(BGFX_DIR, "src/vertexdecl.**"),
  154. path.join(BGFX_DIR, "src/shader_spirv.**"),
  155. path.join(FCPP_DIR, "**.h"),
  156. path.join(FCPP_DIR, "cpp1.c"),
  157. path.join(FCPP_DIR, "cpp2.c"),
  158. path.join(FCPP_DIR, "cpp3.c"),
  159. path.join(FCPP_DIR, "cpp4.c"),
  160. path.join(FCPP_DIR, "cpp5.c"),
  161. path.join(FCPP_DIR, "cpp6.c"),
  162. path.join(FCPP_DIR, "cpp6.c"),
  163. path.join(GLSL_OPTIMIZER, "src/mesa/**.c"),
  164. path.join(GLSL_OPTIMIZER, "src/glsl/**.cpp"),
  165. path.join(GLSL_OPTIMIZER, "src/mesa/**.h"),
  166. path.join(GLSL_OPTIMIZER, "src/glsl/**.c"),
  167. path.join(GLSL_OPTIMIZER, "src/glsl/**.cpp"),
  168. path.join(GLSL_OPTIMIZER, "src/glsl/**.h"),
  169. path.join(GLSL_OPTIMIZER, "src/util/**.c"),
  170. path.join(GLSL_OPTIMIZER, "src/util/**.h"),
  171. }
  172. removefiles {
  173. path.join(GLSL_OPTIMIZER, "src/glsl/glcpp/glcpp.c"),
  174. path.join(GLSL_OPTIMIZER, "src/glsl/glcpp/tests/**"),
  175. path.join(GLSL_OPTIMIZER, "src/glsl/glcpp/**.l"),
  176. path.join(GLSL_OPTIMIZER, "src/glsl/glcpp/**.y"),
  177. path.join(GLSL_OPTIMIZER, "src/glsl/ir_set_program_inouts.cpp"),
  178. path.join(GLSL_OPTIMIZER, "src/glsl/main.cpp"),
  179. path.join(GLSL_OPTIMIZER, "src/glsl/builtin_stubs.cpp"),
  180. }
  181. links {
  182. "glslang",
  183. }
  184. if filesexist(BGFX_DIR, path.join(BGFX_DIR, "../bgfx-ext"), {
  185. path.join(BGFX_DIR, "scripts/shaderc.lua"), }) then
  186. if filesexist(BGFX_DIR, path.join(BGFX_DIR, "../bgfx-ext"), {
  187. path.join(BGFX_DIR, "tools/shaderc/shaderc_pssl.cpp"), }) then
  188. removefiles {
  189. path.join(BGFX_DIR, "tools/shaderc/shaderc_pssl.cpp"),
  190. }
  191. end
  192. dofile(path.join(BGFX_DIR, "../bgfx-ext/scripts/shaderc.lua") )
  193. end
  194. configuration { "osx or linux*" }
  195. links {
  196. "pthread",
  197. }
  198. configuration {}
  199. strip()