1import("../third_party.gni") 2 3template("spirv_core_tables") { 4 version = invoker.version 5 action("spirv_core_tables_" + target_name) { 6 script = "../externals/spirv-tools/utils/generate_grammar_tables.py" 7 sources = [ 8 "../externals/spirv-headers/include/spirv/$version/spirv.core.grammar.json", 9 ] 10 outputs = [ 11 "$root_out_dir/spirv-tools/core.insts-$version.inc", 12 "$root_out_dir/spirv-tools/operand.kinds-$version.inc", 13 ] 14 args = [ 15 "--spirv-core-grammar=" + rebase_path( 16 "../externals/spirv-headers/include/spirv/$version/spirv.core.grammar.json", 17 root_build_dir), 18 "--core-insts-output=" + 19 rebase_path("$root_out_dir/spirv-tools/core.insts-$version.inc", 20 root_build_dir), 21 "--operand-kinds-output=" + 22 rebase_path("$root_out_dir/spirv-tools/operand.kinds-$version.inc", 23 root_build_dir), 24 ] 25 } 26} 27 28spirv_core_tables("1.0") { 29 version = "1.0" 30} 31 32spirv_core_tables("1.1") { 33 version = "1.1" 34} 35 36spirv_core_tables("1.2") { 37 version = "1.2" 38} 39 40action("spirv_glsl_tables") { 41 script = "../externals/spirv-tools/utils/generate_grammar_tables.py" 42 sources = [ 43 "../externals/spirv-headers/include/spirv/1.0/extinst.glsl.std.450.grammar.json", 44 "../externals/spirv-headers/include/spirv/1.0/spirv.core.grammar.json", 45 ] 46 outputs = [ 47 "$root_out_dir/spirv-tools/glsl.std.450.insts-1.0.inc", 48 ] 49 args = [ 50 "--spirv-core-grammar=" + rebase_path( 51 "../externals/spirv-headers/include/spirv/1.0/spirv.core.grammar.json", 52 root_build_dir), 53 "--extinst-glsl-grammar=" + 54 rebase_path("../externals/spirv-headers/include/spirv/1.0/" + 55 "extinst.glsl.std.450.grammar.json", 56 root_build_dir), 57 "--glsl-insts-output=" + 58 rebase_path("$root_out_dir/spirv-tools/glsl.std.450.insts-1.0.inc", 59 root_build_dir), 60 ] 61} 62 63action("spirv_extension_enum") { 64 script = "../externals/spirv-tools/utils/generate_grammar_tables.py" 65 sources = [ 66 "../externals/spirv-headers/include/spirv/1.0/extinst.glsl.std.450.grammar.json", 67 "../externals/spirv-headers/include/spirv/1.0/spirv.core.grammar.json", 68 ] 69 outputs = [ 70 "$root_out_dir/spirv-tools/extension_enum.inc", 71 ] 72 args = [ 73 "--spirv-core-grammar=" + rebase_path( 74 "../externals/spirv-headers/include/spirv/1.0/spirv.core.grammar.json", 75 root_build_dir), 76 "--extension-enum-output=" + 77 rebase_path("$root_out_dir/spirv-tools/extension_enum.inc", 78 root_build_dir), 79 "--enum-string-mapping-output=" + 80 rebase_path("$root_out_dir/spirv-tools/enum_string_mapping.inc", 81 root_build_dir), 82 ] 83} 84 85action("spirv_opencl_tables") { 86 script = "../externals/spirv-tools/utils/generate_grammar_tables.py" 87 sources = [ 88 "../externals/spirv-headers/include/spirv/1.0/extinst.opencl.std.100.grammar.json", 89 "../externals/spirv-headers/include/spirv/1.0/spirv.core.grammar.json", 90 ] 91 outputs = [ 92 "$root_out_dir/spirv-tools/opencl.std.insts-1.0.inc", 93 ] 94 args = [ 95 "--spirv-core-grammar=" + rebase_path( 96 "../externals/spirv-headers/include/spirv/1.0/spirv.core.grammar.json", 97 root_build_dir), 98 "--extinst-opencl-grammar=" + 99 rebase_path("../externals/spirv-headers/include/spirv/1.0/" + 100 "extinst.glsl.std.450.grammar.json", 101 root_build_dir), 102 "--opencl-insts-output=" + 103 rebase_path("$root_out_dir/spirv-tools/opencl.std.insts-1.0.inc", 104 root_build_dir), 105 ] 106} 107 108template("spirv_vendor_tables") { 109 vendor_table = invoker.vendor_table 110 action("spirv_vendor_tables_" + target_name) { 111 script = "../externals/spirv-tools/utils/generate_grammar_tables.py" 112 sources = [ 113 "../externals/spirv-tools/source/extinst.$vendor_table.grammar.json", 114 ] 115 outputs = [ 116 "$root_out_dir/spirv-tools/$vendor_table.insts.inc", 117 ] 118 args = [ 119 "--extinst-vendor-grammar=" + rebase_path( 120 "../externals/spirv-tools/source/extinst.$vendor_table.grammar.json", 121 root_build_dir), 122 "--vendor-insts-output=" + 123 rebase_path("$root_out_dir/spirv-tools/$vendor_table.insts.inc", 124 root_build_dir), 125 ] 126 } 127} 128 129spirv_vendor_tables("amd_shader_explicit_vertex_parameter") { 130 vendor_table = "spv-amd-shader-explicit-vertex-parameter" 131} 132 133spirv_vendor_tables("amd_shader_trinary_minmax") { 134 vendor_table = "spv-amd-shader-trinary-minmax" 135} 136 137spirv_vendor_tables("amd_shader_gcn_shader") { 138 vendor_table = "spv-amd-gcn-shader" 139} 140 141spirv_vendor_tables("amd_shader_ballot") { 142 vendor_table = "spv-amd-shader-ballot" 143} 144 145action("spirv_build_version") { 146 script = "../externals/spirv-tools/utils/update_build_version.py" 147 sources = [ 148 "../externals/spirv-tools/CHANGES", 149 ] 150 outputs = [ 151 "$root_out_dir/spirv-tools/build-version.inc", 152 ] 153 args = [ 154 rebase_path("../externals/spirv-tools", root_build_dir), 155 rebase_path("$root_out_dir/spirv-tools/build-version.inc", root_build_dir), 156 ] 157} 158 159action("spirv_generators") { 160 script = "../externals/spirv-tools/utils/generate_registry_tables.py" 161 sources = [ 162 "../externals/spirv-headers/include/spirv/spir-v.xml", 163 ] 164 outputs = [ 165 "$root_out_dir/spirv-tools/generators.inc", 166 ] 167 args = [ 168 "--xml=" + 169 rebase_path("../externals/spirv-headers/include/spirv/spir-v.xml", 170 root_build_dir), 171 "--generator-output=" + 172 rebase_path("$root_out_dir/spirv-tools/generators.inc", 173 root_build_dir, 174 root_build_dir), 175 ] 176} 177 178third_party("spirv-tools") { 179 public_include_dirs = [ 180 "../externals/spirv-tools/include", 181 "../externals/spirv-tools/source", 182 "$root_out_dir/spirv-tools", 183 ] 184 deps = [ 185 ":spirv_build_version", 186 ":spirv_core_tables_1.0", 187 ":spirv_core_tables_1.1", 188 ":spirv_core_tables_1.2", 189 ":spirv_extension_enum", 190 ":spirv_generators", 191 ":spirv_glsl_tables", 192 ":spirv_opencl_tables", 193 ":spirv_vendor_tables_amd_shader_ballot", 194 ":spirv_vendor_tables_amd_shader_explicit_vertex_parameter", 195 ":spirv_vendor_tables_amd_shader_gcn_shader", 196 ":spirv_vendor_tables_amd_shader_trinary_minmax", 197 "//third_party/spirv-headers", 198 ] 199 sources = [ 200 "../externals/spirv-tools/source/assembly_grammar.cpp", 201 "../externals/spirv-tools/source/binary.cpp", 202 "../externals/spirv-tools/source/diagnostic.cpp", 203 "../externals/spirv-tools/source/disassemble.cpp", 204 "../externals/spirv-tools/source/enum_string_mapping.cpp", 205 "../externals/spirv-tools/source/ext_inst.cpp", 206 "../externals/spirv-tools/source/extensions.cpp", 207 "../externals/spirv-tools/source/libspirv.cpp", 208 "../externals/spirv-tools/source/message.cpp", 209 "../externals/spirv-tools/source/name_mapper.cpp", 210 "../externals/spirv-tools/source/opcode.cpp", 211 "../externals/spirv-tools/source/operand.cpp", 212 "../externals/spirv-tools/source/opt/aggressive_dead_code_elim_pass.cpp", 213 "../externals/spirv-tools/source/opt/basic_block.cpp", 214 "../externals/spirv-tools/source/opt/block_merge_pass.cpp", 215 "../externals/spirv-tools/source/opt/build_module.cpp", 216 "../externals/spirv-tools/source/opt/compact_ids_pass.cpp", 217 "../externals/spirv-tools/source/opt/dead_branch_elim_pass.cpp", 218 "../externals/spirv-tools/source/opt/def_use_manager.cpp", 219 "../externals/spirv-tools/source/opt/eliminate_dead_constant_pass.cpp", 220 "../externals/spirv-tools/source/opt/flatten_decoration_pass.cpp", 221 "../externals/spirv-tools/source/opt/fold_spec_constant_op_and_composite_pass.cpp", 222 "../externals/spirv-tools/source/opt/freeze_spec_constant_value_pass.cpp", 223 "../externals/spirv-tools/source/opt/function.cpp", 224 "../externals/spirv-tools/source/opt/inline_pass.cpp", 225 "../externals/spirv-tools/source/opt/insert_extract_elim.cpp", 226 "../externals/spirv-tools/source/opt/instruction.cpp", 227 "../externals/spirv-tools/source/opt/ir_loader.cpp", 228 "../externals/spirv-tools/source/opt/local_access_chain_convert_pass.cpp", 229 "../externals/spirv-tools/source/opt/local_single_block_elim_pass.cpp", 230 "../externals/spirv-tools/source/opt/local_single_store_elim_pass.cpp", 231 "../externals/spirv-tools/source/opt/local_ssa_elim_pass.cpp", 232 "../externals/spirv-tools/source/opt/module.cpp", 233 "../externals/spirv-tools/source/opt/optimizer.cpp", 234 "../externals/spirv-tools/source/opt/pass_manager.cpp", 235 "../externals/spirv-tools/source/opt/set_spec_constant_default_value_pass.cpp", 236 "../externals/spirv-tools/source/opt/strip_debug_info_pass.cpp", 237 "../externals/spirv-tools/source/opt/type_manager.cpp", 238 "../externals/spirv-tools/source/opt/types.cpp", 239 "../externals/spirv-tools/source/opt/unify_const_pass.cpp", 240 "../externals/spirv-tools/source/parsed_operand.cpp", 241 "../externals/spirv-tools/source/print.cpp", 242 "../externals/spirv-tools/source/software_version.cpp", 243 "../externals/spirv-tools/source/spirv_endian.cpp", 244 "../externals/spirv-tools/source/spirv_target_env.cpp", 245 "../externals/spirv-tools/source/spirv_validator_options.cpp", 246 "../externals/spirv-tools/source/table.cpp", 247 "../externals/spirv-tools/source/text.cpp", 248 "../externals/spirv-tools/source/text_handler.cpp", 249 "../externals/spirv-tools/source/util/parse_number.cpp", 250 "../externals/spirv-tools/source/util/string_utils.cpp", 251 "../externals/spirv-tools/source/val/basic_block.cpp", 252 "../externals/spirv-tools/source/val/construct.cpp", 253 "../externals/spirv-tools/source/val/function.cpp", 254 "../externals/spirv-tools/source/val/instruction.cpp", 255 "../externals/spirv-tools/source/val/validation_state.cpp", 256 "../externals/spirv-tools/source/validate.cpp", 257 "../externals/spirv-tools/source/validate_capability.cpp", 258 "../externals/spirv-tools/source/validate_cfg.cpp", 259 "../externals/spirv-tools/source/validate_datarules.cpp", 260 "../externals/spirv-tools/source/validate_decorations.cpp", 261 "../externals/spirv-tools/source/validate_id.cpp", 262 "../externals/spirv-tools/source/validate_instruction.cpp", 263 "../externals/spirv-tools/source/validate_layout.cpp", 264 "../externals/spirv-tools/source/validate_type_unique.cpp", 265 ] 266} 267