shaderc.lua 5.6 KB

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