BUILD.gn 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. # Copyright (C) 2018 Google, Inc.
  2. #
  3. # All rights reserved.
  4. #
  5. # Redistribution and use in source and binary forms, with or without
  6. # modification, are permitted provided that the following conditions
  7. # are met:
  8. #
  9. # Redistributions of source code must retain the above copyright
  10. # notice, this list of conditions and the following disclaimer.
  11. #
  12. # Redistributions in binary form must reproduce the above
  13. # copyright notice, this list of conditions and the following
  14. # disclaimer in the documentation and/or other materials provided
  15. # with the distribution.
  16. #
  17. # Neither the name of Google Inc. nor the names of its
  18. # contributors may be used to endorse or promote products derived
  19. # from this software without specific prior written permission.
  20. #
  21. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  24. # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  25. # COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  26. # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  27. # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  28. # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  29. # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  30. # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  31. # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  32. # POSSIBILITY OF SUCH DAMAGE.
  33. import("//build_overrides/glslang.gni")
  34. # Both Chromium and Fuchsia use by default a set of warning errors
  35. # that is far too strict to compile this project. These are also
  36. # typically appended after |cflags|, overriding target-specific
  37. # definitions. To work around this, determine which configs to
  38. # add and remove in order to succesfully build the project.
  39. if (defined(is_fuchsia_tree) && is_fuchsia_tree) {
  40. _configs_to_remove = [ "//build/config:default_warnings" ]
  41. _configs_to_add = []
  42. } else {
  43. _configs_to_remove = [ "//build/config/compiler:chromium_code" ]
  44. _configs_to_add = [ "//build/config/compiler:no_chromium_code" ]
  45. }
  46. spirv_tools_dir = glslang_spirv_tools_dir
  47. config("glslang_public") {
  48. include_dirs = [ "." ]
  49. defines = [ "ENABLE_HLSL=1" ]
  50. }
  51. source_set("glslang_sources") {
  52. public_configs = [ ":glslang_public" ]
  53. sources = [
  54. "OGLCompilersDLL/InitializeDll.cpp",
  55. "OGLCompilersDLL/InitializeDll.h",
  56. "SPIRV/GLSL.ext.AMD.h",
  57. "SPIRV/GLSL.ext.EXT.h",
  58. "SPIRV/GLSL.ext.KHR.h",
  59. "SPIRV/GLSL.ext.NV.h",
  60. "SPIRV/GLSL.std.450.h",
  61. "SPIRV/GlslangToSpv.cpp",
  62. "SPIRV/GlslangToSpv.h",
  63. "SPIRV/InReadableOrder.cpp",
  64. "SPIRV/Logger.cpp",
  65. "SPIRV/Logger.h",
  66. "SPIRV/NonSemanticDebugPrintf.h",
  67. "SPIRV/SPVRemapper.cpp",
  68. "SPIRV/SPVRemapper.h",
  69. "SPIRV/SpvBuilder.cpp",
  70. "SPIRV/SpvBuilder.h",
  71. "SPIRV/SpvPostProcess.cpp",
  72. "SPIRV/SpvTools.cpp",
  73. "SPIRV/SpvTools.h",
  74. "SPIRV/bitutils.h",
  75. "SPIRV/disassemble.cpp",
  76. "SPIRV/disassemble.h",
  77. "SPIRV/doc.cpp",
  78. "SPIRV/doc.h",
  79. "SPIRV/hex_float.h",
  80. "SPIRV/spirv.hpp",
  81. "SPIRV/spvIR.h",
  82. "glslang/GenericCodeGen/CodeGen.cpp",
  83. "glslang/GenericCodeGen/Link.cpp",
  84. "glslang/HLSL/hlslAttributes.cpp",
  85. "glslang/HLSL/hlslAttributes.h",
  86. "glslang/HLSL/hlslGrammar.cpp",
  87. "glslang/HLSL/hlslGrammar.h",
  88. "glslang/HLSL/hlslOpMap.cpp",
  89. "glslang/HLSL/hlslOpMap.h",
  90. "glslang/HLSL/hlslParseables.cpp",
  91. "glslang/HLSL/hlslParseables.h",
  92. "glslang/HLSL/hlslParseHelper.cpp",
  93. "glslang/HLSL/hlslParseHelper.h",
  94. "glslang/HLSL/hlslScanContext.cpp",
  95. "glslang/HLSL/hlslScanContext.h",
  96. "glslang/HLSL/hlslTokens.h",
  97. "glslang/HLSL/hlslTokenStream.cpp",
  98. "glslang/HLSL/hlslTokenStream.h",
  99. "glslang/Include/BaseTypes.h",
  100. "glslang/Include/Common.h",
  101. "glslang/Include/ConstantUnion.h",
  102. "glslang/Include/InfoSink.h",
  103. "glslang/Include/InitializeGlobals.h",
  104. "glslang/Include/PoolAlloc.h",
  105. "glslang/Include/ResourceLimits.h",
  106. "glslang/Include/ShHandle.h",
  107. "glslang/Include/Types.h",
  108. "glslang/Include/arrays.h",
  109. "glslang/Include/intermediate.h",
  110. "glslang/Include/revision.h",
  111. "glslang/MachineIndependent/Constant.cpp",
  112. "glslang/MachineIndependent/InfoSink.cpp",
  113. "glslang/MachineIndependent/Initialize.cpp",
  114. "glslang/MachineIndependent/Initialize.h",
  115. "glslang/MachineIndependent/IntermTraverse.cpp",
  116. "glslang/MachineIndependent/Intermediate.cpp",
  117. "glslang/MachineIndependent/LiveTraverser.h",
  118. "glslang/MachineIndependent/ParseContextBase.cpp",
  119. "glslang/MachineIndependent/ParseHelper.cpp",
  120. "glslang/MachineIndependent/ParseHelper.h",
  121. "glslang/MachineIndependent/PoolAlloc.cpp",
  122. "glslang/MachineIndependent/RemoveTree.cpp",
  123. "glslang/MachineIndependent/RemoveTree.h",
  124. "glslang/MachineIndependent/Scan.cpp",
  125. "glslang/MachineIndependent/Scan.h",
  126. "glslang/MachineIndependent/ScanContext.h",
  127. "glslang/MachineIndependent/ShaderLang.cpp",
  128. "glslang/MachineIndependent/SymbolTable.cpp",
  129. "glslang/MachineIndependent/SymbolTable.h",
  130. "glslang/MachineIndependent/Versions.cpp",
  131. "glslang/MachineIndependent/Versions.h",
  132. "glslang/MachineIndependent/attribute.cpp",
  133. "glslang/MachineIndependent/attribute.h",
  134. "glslang/MachineIndependent/gl_types.h",
  135. "glslang/MachineIndependent/glslang_tab.cpp",
  136. "glslang/MachineIndependent/glslang_tab.cpp.h",
  137. "glslang/MachineIndependent/intermOut.cpp",
  138. "glslang/MachineIndependent/iomapper.cpp",
  139. "glslang/MachineIndependent/iomapper.h",
  140. "glslang/MachineIndependent/limits.cpp",
  141. "glslang/MachineIndependent/linkValidate.cpp",
  142. "glslang/MachineIndependent/localintermediate.h",
  143. "glslang/MachineIndependent/parseConst.cpp",
  144. "glslang/MachineIndependent/parseVersions.h",
  145. "glslang/MachineIndependent/preprocessor/Pp.cpp",
  146. "glslang/MachineIndependent/preprocessor/PpAtom.cpp",
  147. "glslang/MachineIndependent/preprocessor/PpContext.cpp",
  148. "glslang/MachineIndependent/preprocessor/PpContext.h",
  149. "glslang/MachineIndependent/preprocessor/PpScanner.cpp",
  150. "glslang/MachineIndependent/preprocessor/PpTokens.cpp",
  151. "glslang/MachineIndependent/preprocessor/PpTokens.h",
  152. "glslang/MachineIndependent/propagateNoContraction.cpp",
  153. "glslang/MachineIndependent/propagateNoContraction.h",
  154. "glslang/MachineIndependent/reflection.cpp",
  155. "glslang/MachineIndependent/reflection.h",
  156. "glslang/OSDependent/osinclude.h",
  157. "glslang/Public/ShaderLang.h",
  158. ]
  159. defines = [ "ENABLE_OPT=1" ]
  160. if (is_win) {
  161. sources += [ "glslang/OSDependent/Windows/ossource.cpp" ]
  162. defines += [ "GLSLANG_OSINCLUDE_WIN32" ]
  163. } else {
  164. sources += [ "glslang/OSDependent/Unix/ossource.cpp" ]
  165. defines += [ "GLSLANG_OSINCLUDE_UNIX" ]
  166. }
  167. if (is_clang) {
  168. cflags = [
  169. "-Wno-extra-semi",
  170. "-Wno-ignored-qualifiers",
  171. "-Wno-implicit-fallthrough",
  172. "-Wno-inconsistent-missing-override",
  173. "-Wno-sign-compare",
  174. "-Wno-unused-variable",
  175. "-Wno-missing-field-initializers",
  176. "-Wno-newline-eof",
  177. ]
  178. }
  179. if (is_win && !is_clang) {
  180. cflags = [
  181. "/wd4018", # signed/unsigned mismatch
  182. "/wd4189", # local variable is initialized but not referenced
  183. ]
  184. }
  185. deps = [
  186. "${spirv_tools_dir}:spvtools_opt",
  187. "${spirv_tools_dir}:spvtools_val",
  188. ]
  189. configs -= _configs_to_remove
  190. configs += _configs_to_add
  191. }
  192. source_set("glslang_default_resource_limits_sources") {
  193. sources = [
  194. "StandAlone/ResourceLimits.cpp",
  195. "StandAlone/ResourceLimits.h",
  196. ]
  197. deps = [
  198. ":glslang_sources",
  199. ]
  200. public_configs = [ ":glslang_public" ]
  201. configs -= _configs_to_remove
  202. configs += _configs_to_add
  203. }
  204. executable("glslang_validator") {
  205. sources = [
  206. "StandAlone/DirStackFileIncluder.h",
  207. "StandAlone/StandAlone.cpp",
  208. ]
  209. if (!is_win) {
  210. cflags = [ "-Woverflow" ]
  211. }
  212. defines = [ "ENABLE_OPT=1" ]
  213. deps = [
  214. ":glslang_default_resource_limits_sources",
  215. ":glslang_sources",
  216. ]
  217. configs -= _configs_to_remove
  218. configs += _configs_to_add
  219. }
  220. executable("spirv-remap") {
  221. sources = [
  222. "StandAlone/spirv-remap.cpp",
  223. ]
  224. defines = [ "ENABLE_OPT=1" ]
  225. deps = [
  226. ":glslang_sources",
  227. ]
  228. configs -= _configs_to_remove
  229. configs += _configs_to_add
  230. }