shaderc.lua 7.5 KB

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