shaderc.lua 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  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. files {
  92. path.join(GLSL_OPTIMIZER, "src/mesa/**.c"),
  93. path.join(GLSL_OPTIMIZER, "src/glsl/**.cpp"),
  94. path.join(GLSL_OPTIMIZER, "src/mesa/**.h"),
  95. path.join(GLSL_OPTIMIZER, "src/glsl/**.c"),
  96. path.join(GLSL_OPTIMIZER, "src/glsl/**.cpp"),
  97. path.join(GLSL_OPTIMIZER, "src/glsl/**.h"),
  98. path.join(GLSL_OPTIMIZER, "src/util/**.c"),
  99. path.join(GLSL_OPTIMIZER, "src/util/**.h"),
  100. }
  101. removefiles {
  102. path.join(GLSL_OPTIMIZER, "src/glsl/glcpp/glcpp.c"),
  103. path.join(GLSL_OPTIMIZER, "src/glsl/glcpp/tests/**"),
  104. path.join(GLSL_OPTIMIZER, "src/glsl/glcpp/**.l"),
  105. path.join(GLSL_OPTIMIZER, "src/glsl/glcpp/**.y"),
  106. path.join(GLSL_OPTIMIZER, "src/glsl/ir_set_program_inouts.cpp"),
  107. path.join(GLSL_OPTIMIZER, "src/glsl/main.cpp"),
  108. path.join(GLSL_OPTIMIZER, "src/glsl/builtin_stubs.cpp"),
  109. }
  110. configuration { "Release" }
  111. flags {
  112. "Optimize",
  113. }
  114. removeflags {
  115. -- GCC 4.9 -O2 + -fno-strict-aliasing don't work together...
  116. "OptimizeSpeed",
  117. }
  118. configuration { "vs*" }
  119. includedirs {
  120. path.join(GLSL_OPTIMIZER, "src/glsl/msvc"),
  121. }
  122. defines { -- glsl-optimizer
  123. "__STDC__",
  124. "__STDC_VERSION__=199901L",
  125. "strdup=_strdup",
  126. "alloca=_alloca",
  127. "isascii=__isascii",
  128. }
  129. buildoptions {
  130. "/wd4100", -- error C4100: '' : unreferenced formal parameter
  131. "/wd4127", -- warning C4127: conditional expression is constant
  132. "/wd4132", -- warning C4132: 'deleted_key_value': const object should be initialized
  133. "/wd4189", -- warning C4189: 'interface_type': local variable is initialized but not referenced
  134. "/wd4204", -- warning C4204: nonstandard extension used: non-constant aggregate initializer
  135. "/wd4244", -- warning C4244: '=': conversion from 'const flex_int32_t' to 'YY_CHAR', possible loss of data
  136. "/wd4389", -- warning C4389: '!=': signed/unsigned mismatch
  137. "/wd4245", -- warning C4245: 'return': conversion from 'int' to 'unsigned int', signed/unsigned mismatch
  138. "/wd4701", -- warning C4701: potentially uninitialized local variable 'lower' used
  139. "/wd4702", -- warning C4702: unreachable code
  140. "/wd4706", -- warning C4706: assignment within conditional expression
  141. "/wd4996" -- warning C4996: 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup.
  142. }
  143. configuration { "mingw* or linux or osx" }
  144. buildoptions {
  145. "-fno-strict-aliasing", -- glsl-optimizer has bugs if strict aliasing is used.
  146. "-Wno-unused-parameter",
  147. }
  148. removebuildoptions {
  149. "-Wshadow", -- glsl-optimizer is full of -Wshadow warnings ignore it.
  150. }
  151. configuration {}
  152. project "shaderc"
  153. kind "ConsoleApp"
  154. includedirs {
  155. path.join(GLSL_OPTIMIZER, "include"),
  156. }
  157. links {
  158. "bx",
  159. "glslang",
  160. "glsl-optimizer",
  161. }
  162. defines { -- fcpp
  163. "NINCLUDE=64",
  164. "NWORK=65536",
  165. "NBUFF=65536",
  166. "OLD_PREPROCESSOR=0",
  167. }
  168. includedirs {
  169. path.join(BX_DIR, "include"),
  170. path.join(BGFX_DIR, "include"),
  171. path.join(BGFX_DIR, "3rdparty/dxsdk/include"),
  172. FCPP_DIR,
  173. path.join(BGFX_DIR, "3rdparty/glslang/glslang/Public"),
  174. path.join(BGFX_DIR, "3rdparty/glslang/glslang/Include"),
  175. path.join(BGFX_DIR, "3rdparty/glslang"),
  176. -- path.join(BGFX_DIR, "3rdparty/spirv-tools/include"),
  177. path.join(GLSL_OPTIMIZER, "include"),
  178. path.join(GLSL_OPTIMIZER, "src/mesa"),
  179. path.join(GLSL_OPTIMIZER, "src/mapi"),
  180. path.join(GLSL_OPTIMIZER, "src/glsl"),
  181. }
  182. files {
  183. path.join(BGFX_DIR, "tools/shaderc/**.cpp"),
  184. path.join(BGFX_DIR, "tools/shaderc/**.h"),
  185. path.join(BGFX_DIR, "src/vertexdecl.**"),
  186. path.join(BGFX_DIR, "src/shader_spirv.**"),
  187. path.join(FCPP_DIR, "**.h"),
  188. path.join(FCPP_DIR, "cpp1.c"),
  189. path.join(FCPP_DIR, "cpp2.c"),
  190. path.join(FCPP_DIR, "cpp3.c"),
  191. path.join(FCPP_DIR, "cpp4.c"),
  192. path.join(FCPP_DIR, "cpp5.c"),
  193. path.join(FCPP_DIR, "cpp6.c"),
  194. path.join(FCPP_DIR, "cpp6.c"),
  195. }
  196. configuration { "mingw-*" }
  197. targetextension ".exe"
  198. configuration { "osx" }
  199. links {
  200. "Cocoa.framework",
  201. }
  202. configuration { "vs*" }
  203. includedirs {
  204. path.join(GLSL_OPTIMIZER, "include/c99"),
  205. }
  206. configuration { "vs20* or mingw*" }
  207. links {
  208. "psapi",
  209. }
  210. configuration {}
  211. if filesexist(BGFX_DIR, path.join(BGFX_DIR, "../bgfx-ext"), {
  212. path.join(BGFX_DIR, "scripts/shaderc.lua"), }) then
  213. if filesexist(BGFX_DIR, path.join(BGFX_DIR, "../bgfx-ext"), {
  214. path.join(BGFX_DIR, "tools/shaderc/shaderc_pssl.cpp"), }) then
  215. removefiles {
  216. path.join(BGFX_DIR, "tools/shaderc/shaderc_pssl.cpp"),
  217. }
  218. end
  219. dofile(path.join(BGFX_DIR, "../bgfx-ext/scripts/shaderc.lua") )
  220. end
  221. configuration { "osx or linux*" }
  222. links {
  223. "pthread",
  224. }
  225. configuration {}
  226. strip()