BUILD.gn 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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.EXT.h",
  57. "SPIRV/GLSL.ext.KHR.h",
  58. "SPIRV/GLSL.std.450.h",
  59. "SPIRV/GlslangToSpv.cpp",
  60. "SPIRV/GlslangToSpv.h",
  61. "SPIRV/InReadableOrder.cpp",
  62. "SPIRV/Logger.cpp",
  63. "SPIRV/Logger.h",
  64. "SPIRV/SPVRemapper.cpp",
  65. "SPIRV/SPVRemapper.h",
  66. "SPIRV/SpvBuilder.cpp",
  67. "SPIRV/SpvBuilder.h",
  68. "SPIRV/SpvPostProcess.cpp",
  69. "SPIRV/SpvTools.cpp",
  70. "SPIRV/SpvTools.h",
  71. "SPIRV/bitutils.h",
  72. "SPIRV/disassemble.cpp",
  73. "SPIRV/disassemble.h",
  74. "SPIRV/doc.cpp",
  75. "SPIRV/doc.h",
  76. "SPIRV/hex_float.h",
  77. "SPIRV/spirv.hpp",
  78. "SPIRV/spvIR.h",
  79. "glslang/GenericCodeGen/CodeGen.cpp",
  80. "glslang/GenericCodeGen/Link.cpp",
  81. "glslang/Include/BaseTypes.h",
  82. "glslang/Include/Common.h",
  83. "glslang/Include/ConstantUnion.h",
  84. "glslang/Include/InfoSink.h",
  85. "glslang/Include/InitializeGlobals.h",
  86. "glslang/Include/PoolAlloc.h",
  87. "glslang/Include/ResourceLimits.h",
  88. "glslang/Include/ShHandle.h",
  89. "glslang/Include/Types.h",
  90. "glslang/Include/arrays.h",
  91. "glslang/Include/intermediate.h",
  92. "glslang/Include/revision.h",
  93. "glslang/MachineIndependent/Constant.cpp",
  94. "glslang/MachineIndependent/InfoSink.cpp",
  95. "glslang/MachineIndependent/Initialize.cpp",
  96. "glslang/MachineIndependent/Initialize.h",
  97. "glslang/MachineIndependent/IntermTraverse.cpp",
  98. "glslang/MachineIndependent/Intermediate.cpp",
  99. "glslang/MachineIndependent/LiveTraverser.h",
  100. "glslang/MachineIndependent/ParseContextBase.cpp",
  101. "glslang/MachineIndependent/ParseHelper.cpp",
  102. "glslang/MachineIndependent/ParseHelper.h",
  103. "glslang/MachineIndependent/PoolAlloc.cpp",
  104. "glslang/MachineIndependent/RemoveTree.cpp",
  105. "glslang/MachineIndependent/RemoveTree.h",
  106. "glslang/MachineIndependent/Scan.cpp",
  107. "glslang/MachineIndependent/Scan.h",
  108. "glslang/MachineIndependent/ScanContext.h",
  109. "glslang/MachineIndependent/ShaderLang.cpp",
  110. "glslang/MachineIndependent/SymbolTable.cpp",
  111. "glslang/MachineIndependent/SymbolTable.h",
  112. "glslang/MachineIndependent/Versions.cpp",
  113. "glslang/MachineIndependent/Versions.h",
  114. "glslang/MachineIndependent/attribute.cpp",
  115. "glslang/MachineIndependent/attribute.h",
  116. "glslang/MachineIndependent/gl_types.h",
  117. "glslang/MachineIndependent/glslang_tab.cpp",
  118. "glslang/MachineIndependent/glslang_tab.cpp.h",
  119. "glslang/MachineIndependent/intermOut.cpp",
  120. "glslang/MachineIndependent/iomapper.cpp",
  121. "glslang/MachineIndependent/iomapper.h",
  122. "glslang/MachineIndependent/limits.cpp",
  123. "glslang/MachineIndependent/linkValidate.cpp",
  124. "glslang/MachineIndependent/localintermediate.h",
  125. "glslang/MachineIndependent/parseConst.cpp",
  126. "glslang/MachineIndependent/parseVersions.h",
  127. "glslang/MachineIndependent/preprocessor/Pp.cpp",
  128. "glslang/MachineIndependent/preprocessor/PpAtom.cpp",
  129. "glslang/MachineIndependent/preprocessor/PpContext.cpp",
  130. "glslang/MachineIndependent/preprocessor/PpContext.h",
  131. "glslang/MachineIndependent/preprocessor/PpScanner.cpp",
  132. "glslang/MachineIndependent/preprocessor/PpTokens.cpp",
  133. "glslang/MachineIndependent/preprocessor/PpTokens.h",
  134. "glslang/MachineIndependent/propagateNoContraction.cpp",
  135. "glslang/MachineIndependent/propagateNoContraction.h",
  136. "glslang/MachineIndependent/reflection.cpp",
  137. "glslang/MachineIndependent/reflection.h",
  138. "glslang/OSDependent/osinclude.h",
  139. "glslang/Public/ShaderLang.h",
  140. "hlsl/hlslAttributes.cpp",
  141. "hlsl/hlslAttributes.h",
  142. "hlsl/hlslGrammar.cpp",
  143. "hlsl/hlslGrammar.h",
  144. "hlsl/hlslOpMap.cpp",
  145. "hlsl/hlslOpMap.h",
  146. "hlsl/hlslParseHelper.cpp",
  147. "hlsl/hlslParseHelper.h",
  148. "hlsl/hlslParseables.cpp",
  149. "hlsl/hlslParseables.h",
  150. "hlsl/hlslScanContext.cpp",
  151. "hlsl/hlslScanContext.h",
  152. "hlsl/hlslTokenStream.cpp",
  153. "hlsl/hlslTokenStream.h",
  154. "hlsl/hlslTokens.h",
  155. ]
  156. defines = [ "ENABLE_OPT=1" ]
  157. if (is_win) {
  158. sources += [ "glslang/OSDependent/Windows/ossource.cpp" ]
  159. defines += [ "GLSLANG_OSINCLUDE_WIN32" ]
  160. } else {
  161. sources += [ "glslang/OSDependent/Unix/ossource.cpp" ]
  162. defines += [ "GLSLANG_OSINCLUDE_UNIX" ]
  163. }
  164. if (is_clang) {
  165. cflags = [
  166. "-Wno-extra-semi",
  167. "-Wno-ignored-qualifiers",
  168. "-Wno-implicit-fallthrough",
  169. "-Wno-inconsistent-missing-override",
  170. "-Wno-sign-compare",
  171. "-Wno-unused-variable",
  172. "-Wno-missing-field-initializers",
  173. "-Wno-newline-eof",
  174. ]
  175. }
  176. if (is_win && !is_clang) {
  177. cflags = [
  178. "/wd4018", # signed/unsigned mismatch
  179. "/wd4189", # local variable is initialized but not referenced
  180. ]
  181. }
  182. deps = [
  183. "${spirv_tools_dir}:spvtools_opt",
  184. "${spirv_tools_dir}:spvtools_val",
  185. ]
  186. configs -= _configs_to_remove
  187. configs += _configs_to_add
  188. }
  189. source_set("glslang_default_resource_limits_sources") {
  190. sources = [
  191. "StandAlone/ResourceLimits.cpp",
  192. "StandAlone/ResourceLimits.h",
  193. ]
  194. deps = [
  195. ":glslang_sources",
  196. ]
  197. public_configs = [ ":glslang_public" ]
  198. configs -= _configs_to_remove
  199. configs += _configs_to_add
  200. }
  201. executable("glslang_validator") {
  202. sources = [
  203. "StandAlone/DirStackFileIncluder.h",
  204. "StandAlone/StandAlone.cpp",
  205. ]
  206. if (!is_win) {
  207. cflags = [ "-Woverflow" ]
  208. }
  209. defines = [ "ENABLE_OPT=1" ]
  210. deps = [
  211. ":glslang_default_resource_limits_sources",
  212. ":glslang_sources",
  213. ]
  214. configs -= _configs_to_remove
  215. configs += _configs_to_add
  216. }
  217. executable("spirv-remap") {
  218. sources = [
  219. "StandAlone/spirv-remap.cpp",
  220. ]
  221. defines = [ "ENABLE_OPT=1" ]
  222. deps = [
  223. ":glslang_sources",
  224. ]
  225. configs -= _configs_to_remove
  226. configs += _configs_to_add
  227. }