1 """Constants and macros for spirv-tools BUILD."""
4 "-DSPIRV_CHECK_CONTEXT",
5 "-DSPIRV_COLOR_TERMINAL",
7 "@platforms//os:windows": [],
8 "//conditions:default": [
10 "-DSPIRV_TIMER_ENABLED",
11 "-fvisibility=hidden",
17 "-Wno-missing-field-initializers",
23 "-Wno-sign-conversion",
27 TEST_COPTS = COMMON_COPTS + [
29 "@platforms//os:windows": [
30 # Disable C4503 "decorated name length exceeded" warning,
31 # triggered by some heavily templated types.
32 # We don't care much about that in test code.
33 # Important to do since we have warnings-as-errors.
36 "//conditions:default": [
40 "-Wno-unused-parameter",
44 def incompatible_with(incompatible_constraints):
45 return select(_merge_dicts([{"//conditions:default": []}, {
46 constraint: ["@platforms//:incompatible"]
47 for constraint in incompatible_constraints
50 DEBUGINFO_GRAMMAR_JSON_FILE = "@spirv_headers//:spirv_ext_inst_debuginfo_grammar_unified1"
51 CLDEBUGINFO100_GRAMMAR_JSON_FILE = "@spirv_headers//:spirv_ext_inst_opencl_debuginfo_100_grammar_unified1"
52 SHDEBUGINFO100_GRAMMAR_JSON_FILE = "@spirv_headers//:spirv_ext_inst_nonsemantic_shader_debuginfo_100_grammar_unified1"
54 def _merge_dicts(dicts):
60 def generate_core_tables(version):
62 fail("Must specify version", "version")
65 core_grammar = "@spirv_headers//:spirv_core_grammar_{}".format(version),
66 debuginfo_grammar = DEBUGINFO_GRAMMAR_JSON_FILE,
67 cldebuginfo_grammar = CLDEBUGINFO100_GRAMMAR_JSON_FILE,
71 core_insts_output = "core.insts-{}.inc".format(version),
72 operand_kinds_output = "operand.kinds-{}.inc".format(version),
76 "$(location :generate_grammar_tables)" +
77 " --spirv-core-grammar=$(location {core_grammar})" +
78 " --extinst-debuginfo-grammar=$(location {debuginfo_grammar})" +
79 " --extinst-cldebuginfo100-grammar=$(location {cldebuginfo_grammar})" +
80 " --core-insts-output=$(location {core_insts_output})" +
81 " --operand-kinds-output=$(location {operand_kinds_output})" +
82 " --output-language=c++"
83 ).format(**_merge_dicts([grammars, outs]))
86 name = "gen_core_tables_" + version,
87 srcs = grammars.values(),
91 tools = [":generate_grammar_tables"],
92 visibility = ["//visibility:private"],
95 def generate_enum_string_mapping(version):
97 fail("Must specify version", "version")
100 core_grammar = "@spirv_headers//:spirv_core_grammar_{}".format(version),
101 debuginfo_grammar = DEBUGINFO_GRAMMAR_JSON_FILE,
102 cldebuginfo_grammar = CLDEBUGINFO100_GRAMMAR_JSON_FILE,
106 extension_enum_ouput = "extension_enum.inc",
107 enum_string_mapping_output = "enum_string_mapping.inc",
111 "$(location :generate_grammar_tables)" +
112 " --spirv-core-grammar=$(location {core_grammar})" +
113 " --extinst-debuginfo-grammar=$(location {debuginfo_grammar})" +
114 " --extinst-cldebuginfo100-grammar=$(location {cldebuginfo_grammar})" +
115 " --extension-enum-output=$(location {extension_enum_ouput})" +
116 " --enum-string-mapping-output=$(location {enum_string_mapping_output})" +
117 " --output-language=c++"
118 ).format(**_merge_dicts([grammars, outs]))
121 name = "gen_enum_string_mapping",
122 srcs = grammars.values(),
123 outs = outs.values(),
126 tools = [":generate_grammar_tables"],
127 visibility = ["//visibility:private"],
130 def generate_opencl_tables(version):
132 fail("Must specify version", "version")
135 opencl_grammar = "@spirv_headers//:spirv_opencl_grammar_{}".format(version),
139 opencl_insts_output = "opencl.std.insts.inc",
143 "$(location :generate_grammar_tables)" +
144 " --extinst-opencl-grammar=$(location {opencl_grammar})" +
145 " --opencl-insts-output=$(location {opencl_insts_output})"
146 ).format(**_merge_dicts([grammars, outs]))
149 name = "gen_opencl_tables_" + version,
150 srcs = grammars.values(),
151 outs = outs.values(),
154 tools = [":generate_grammar_tables"],
155 visibility = ["//visibility:private"],
158 def generate_glsl_tables(version):
160 fail("Must specify version", "version")
163 gsls_grammar = "@spirv_headers//:spirv_glsl_grammar_{}".format(version),
166 gsls_insts_outs = "glsl.std.450.insts.inc",
170 "$(location :generate_grammar_tables)" +
171 " --extinst-glsl-grammar=$(location {gsls_grammar})" +
172 " --glsl-insts-output=$(location {gsls_insts_outs})" +
173 " --output-language=c++"
174 ).format(**_merge_dicts([grammars, outs]))
177 name = "gen_glsl_tables_" + version,
178 srcs = grammars.values(),
179 outs = outs.values(),
182 tools = [":generate_grammar_tables"],
183 visibility = ["//visibility:private"],
186 def generate_vendor_tables(extension, operand_kind_prefix = ""):
188 fail("Must specify extension", "extension")
190 extension_rule = extension.replace("-", "_").replace(".", "_")
192 vendor_grammar = "@spirv_headers//:spirv_ext_inst_{}_grammar_unified1".format(extension_rule),
195 vendor_insts_output = "{}.insts.inc".format(extension),
198 "$(location :generate_grammar_tables)" +
199 " --extinst-vendor-grammar=$(location {vendor_grammar})" +
200 " --vendor-insts-output=$(location {vendor_insts_output})" +
201 " --vendor-operand-kind-prefix={operand_kind_prefix}"
202 ).format(operand_kind_prefix = operand_kind_prefix, **_merge_dicts([grammars, outs]))
205 name = "gen_vendor_tables_" + extension_rule,
206 srcs = grammars.values(),
207 outs = outs.values(),
210 tools = [":generate_grammar_tables"],
211 visibility = ["//visibility:private"],
214 def generate_extinst_lang_headers(name, grammar = None):
216 fail("Must specify grammar", "grammar")
218 extinst_output_path = name + ".h",
221 "$(location :generate_language_headers)" +
222 " --extinst-grammar=$<" +
223 " --extinst-output-path=$(location {extinst_output_path})"
227 name = "gen_extinst_lang_headers_{}".format(name),
229 outs = outs.values(),
232 tools = [":generate_language_headers"],
233 visibility = ["//visibility:private"],