shaderc.lua 7.6 KB

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