shaderc.lua 7.8 KB

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