| # Copyright 2017 The Fuchsia Authors |
| # |
| # Permission is hereby granted, free of charge, to any person obtaining a |
| # copy of this software and associated documentation files (the "Software"), |
| # to deal in the Software without restriction, including without limitation |
| # the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| # and/or sell copies of the Software, and to permit persons to whom the |
| # Software is furnished to do so, subject to the following conditions: |
| # |
| # The above copyright notice and this permission notice (including the next |
| # paragraph) shall be included in all copies or substantial portions of the |
| # Software. |
| # |
| # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS |
| # IN THE SOFTWARE. |
| |
| config("spirv_warnings") { |
| visibility = [ ":*" ] |
| cflags_cc = [ |
| "-Wno-delete-non-virtual-dtor", |
| "-Wno-return-std-move", |
| ] |
| } |
| group("generate_include_files") { |
| deps = [ |
| ":build_version_include_file", |
| ":core_and_operands_1_0_include_files", |
| ":core_and_operands_1_1_include_files", |
| ":core_and_operands_1_2_include_files", |
| ":core_and_operands_unified1_include_files", |
| ":debug_info_include_file", |
| ":extension_enum_include_file", |
| ":generators_include_file", |
| ":glsl_1_0_include_file", |
| ":vendor_tables_amd_gcn_shader", |
| ":vendor_tables_amd_shader_ballot", |
| ":vendor_tables_amd_shader_explicit_vertex_parameter", |
| ":vendor_tables_amd_shader_trinary_minmax", |
| ":vendor_tables_debug_info", |
| ] |
| } |
| |
| # The actions below were created by roughly transcribing the actions in |
| # //third_party/shaderc/third_party/spirv-tools/Android.mk |
| |
| # TODO(SCN-649): use GN wizardry to reduce boilerplate in the actions below. |
| |
| action("build_version_include_file") { |
| script = "utils/update_build_version.py" |
| args = [ |
| rebase_path(".", root_build_dir), |
| rebase_path("$target_gen_dir/build-version.inc", root_build_dir), |
| ] |
| sources = [ |
| "CHANGES", |
| ] |
| outputs = [ |
| "$target_gen_dir/build-version.inc", |
| ] |
| } |
| action("glsl_1_0_include_file") { |
| script = "utils/generate_grammar_tables.py" |
| spirv_core_grammar = |
| "external/spirv-headers/include/spirv/1.0/spirv.core.grammar.json" |
| debug_info_grammar = "source/extinst.debuginfo.grammar.json" |
| glsl_grammar = "external/spirv-headers/include/spirv/1.0/extinst.glsl.std.450.grammar.json" |
| output_file = "$target_gen_dir/glsl.std.450.insts-1.0.inc" |
| args = [ |
| "--spirv-core-grammar=" + rebase_path(spirv_core_grammar, root_build_dir), |
| "--extinst-debuginfo-grammar=" + |
| rebase_path(debug_info_grammar, root_build_dir), |
| "--extinst-glsl-grammar=" + rebase_path(glsl_grammar, root_build_dir), |
| "--glsl-insts-output=" + rebase_path(output_file, root_build_dir), |
| ] |
| sources = [ |
| glsl_grammar, |
| spirv_core_grammar, |
| ] |
| outputs = [ |
| output_file, |
| ] |
| } |
| action("core_and_operands_1_0_include_files") { |
| script = "utils/generate_grammar_tables.py" |
| spirv_core_grammar = |
| "external/spirv-headers/include/spirv/1.0/spirv.core.grammar.json" |
| debug_info_grammar = "source/extinst.debuginfo.grammar.json" |
| glsl_grammar = "external/spirv-headers/include/spirv/1.2/extinst.glsl.std.450.grammar.json" |
| opencl_grammar = "external/spirv-headers/include/spirv/1.2/extinst.opencl.std.100.grammar.json" |
| core_insts_output_file = "$target_gen_dir/core.insts-1.0.inc" |
| operand_kinds_output_file = "$target_gen_dir/operand.kinds-1.0.inc" |
| glsl_insts_output_file = "$target_gen_dir/glsl.std.450.insts.inc" |
| opencl_insts_output_file = "$target_gen_dir/opencl.std.insts.inc" |
| args = [ |
| "--spirv-core-grammar=" + rebase_path(spirv_core_grammar, root_build_dir), |
| "--extinst-debuginfo-grammar=" + |
| rebase_path(debug_info_grammar, root_build_dir), |
| "--extinst-glsl-grammar=" + rebase_path(glsl_grammar, root_build_dir), |
| "--extinst-opencl-grammar=" + rebase_path(opencl_grammar, root_build_dir), |
| "--core-insts-output=" + |
| rebase_path(core_insts_output_file, root_build_dir), |
| "--glsl-insts-output=" + |
| rebase_path(glsl_insts_output_file, root_build_dir), |
| "--opencl-insts-output=" + |
| rebase_path(opencl_insts_output_file, root_build_dir), |
| "--operand-kinds-output=" + |
| rebase_path(operand_kinds_output_file, root_build_dir), |
| ] |
| sources = [ |
| spirv_core_grammar, |
| ] |
| outputs = [ |
| core_insts_output_file, |
| operand_kinds_output_file, |
| ] |
| } |
| action("core_and_operands_1_1_include_files") { |
| script = "utils/generate_grammar_tables.py" |
| spirv_core_grammar = |
| "external/spirv-headers/include/spirv/1.1/spirv.core.grammar.json" |
| debug_info_grammar = "source/extinst.debuginfo.grammar.json" |
| core_insts_output_file = "$target_gen_dir/core.insts-1.1.inc" |
| operand_kinds_output_file = "$target_gen_dir/operand.kinds-1.1.inc" |
| args = [ |
| "--spirv-core-grammar=" + rebase_path(spirv_core_grammar, root_build_dir), |
| "--extinst-debuginfo-grammar=" + |
| rebase_path(debug_info_grammar, root_build_dir), |
| "--core-insts-output=" + |
| rebase_path(core_insts_output_file, root_build_dir), |
| "--operand-kinds-output=" + |
| rebase_path(operand_kinds_output_file, root_build_dir), |
| ] |
| sources = [ |
| spirv_core_grammar, |
| ] |
| outputs = [ |
| core_insts_output_file, |
| operand_kinds_output_file, |
| ] |
| } |
| action("core_and_operands_1_2_include_files") { |
| script = "utils/generate_grammar_tables.py" |
| spirv_core_grammar = |
| "external/spirv-headers/include/spirv/1.2/spirv.core.grammar.json" |
| debug_info_grammar = "source/extinst.debuginfo.grammar.json" |
| core_insts_output_file = "$target_gen_dir/core.insts-1.2.inc" |
| operand_kinds_output_file = "$target_gen_dir/operand.kinds-1.2.inc" |
| args = [ |
| "--spirv-core-grammar=" + rebase_path(spirv_core_grammar, root_build_dir), |
| "--extinst-debuginfo-grammar=" + |
| rebase_path(debug_info_grammar, root_build_dir), |
| "--core-insts-output=" + |
| rebase_path(core_insts_output_file, root_build_dir), |
| "--operand-kinds-output=" + |
| rebase_path(operand_kinds_output_file, root_build_dir), |
| ] |
| sources = [ |
| spirv_core_grammar, |
| ] |
| outputs = [ |
| core_insts_output_file, |
| operand_kinds_output_file, |
| ] |
| } |
| action("core_and_operands_unified1_include_files") { |
| script = "utils/generate_grammar_tables.py" |
| spirv_core_grammar = |
| "external/spirv-headers/include/spirv/unified1/spirv.core.grammar.json" |
| debug_info_grammar = "source/extinst.debuginfo.grammar.json" |
| core_insts_output_file = "$target_gen_dir/core.insts-unified1.inc" |
| operand_kinds_output_file = "$target_gen_dir/operand.kinds-unified1.inc" |
| args = [ |
| "--spirv-core-grammar=" + rebase_path(spirv_core_grammar, root_build_dir), |
| "--extinst-debuginfo-grammar=" + |
| rebase_path(debug_info_grammar, root_build_dir), |
| "--core-insts-output=" + |
| rebase_path(core_insts_output_file, root_build_dir), |
| "--operand-kinds-output=" + |
| rebase_path(operand_kinds_output_file, root_build_dir), |
| ] |
| sources = [ |
| spirv_core_grammar, |
| ] |
| outputs = [ |
| core_insts_output_file, |
| operand_kinds_output_file, |
| ] |
| } |
| action("extension_enum_include_file") { |
| script = "utils/generate_grammar_tables.py" |
| |
| # TODO: this must be kept up-to-date |
| spirv_core_latest_grammar = |
| "external/spirv-headers/include/spirv/unified1/spirv.core.grammar.json" |
| debug_info_grammar = "source/extinst.debuginfo.grammar.json" |
| extension_enum_output_file = "$target_gen_dir/extension_enum.inc" |
| enum_string_mapping_output_file = "$target_gen_dir/enum_string_mapping.inc" |
| args = [ |
| "--spirv-core-grammar=" + |
| rebase_path(spirv_core_latest_grammar, root_build_dir), |
| "--extinst-debuginfo-grammar=" + |
| rebase_path(debug_info_grammar, root_build_dir), |
| "--extension-enum-output=" + |
| rebase_path(extension_enum_output_file, root_build_dir), |
| "--enum-string-mapping-output=" + |
| rebase_path(enum_string_mapping_output_file, root_build_dir), |
| ] |
| sources = [ |
| debug_info_grammar, |
| spirv_core_latest_grammar, |
| ] |
| outputs = [ |
| extension_enum_output_file, |
| enum_string_mapping_output_file, |
| ] |
| } |
| action("generators_include_file") { |
| script = "utils/generate_registry_tables.py" |
| input_file = "external/spirv-headers/include/spirv/spir-v.xml" |
| output_file = "$target_gen_dir/generators.inc" |
| args = [ |
| "--xml=" + rebase_path(input_file, root_build_dir), |
| "--generator-output=" + rebase_path(output_file, root_build_dir), |
| ] |
| sources = [ |
| input_file, |
| ] |
| outputs = [ |
| output_file, |
| ] |
| } |
| action("debug_info_include_file") { |
| script = "utils/generate_language_headers.py" |
| debug_info_grammar = "source/extinst.debuginfo.grammar.json" |
| base_filename = "DebugInfo" |
| output_path = "$target_gen_dir/DebugInfo" |
| output_path_with_h = "$target_gen_dir/DebugInfo.h" |
| args = [ |
| "--extinst-name=" + base_filename, |
| "--extinst-grammar=" + rebase_path(debug_info_grammar, root_build_dir), |
| "--extinst-output-base=" + rebase_path(output_path, root_build_dir), |
| ] |
| sources = [ |
| debug_info_grammar, |
| ] |
| outputs = [ |
| output_path_with_h, |
| ] |
| } |
| action("vendor_tables_debug_info") { |
| script = "utils/generate_grammar_tables.py" |
| input_grammar_file = "source/extinst.debuginfo.grammar.json" |
| output_file = "$target_gen_dir/debuginfo.insts.inc" |
| args = [ |
| "--extinst-vendor-grammar=" + |
| rebase_path(input_grammar_file, root_build_dir), |
| "--vendor-insts-output=" + rebase_path(output_file, root_build_dir), |
| ] |
| sources = [ |
| input_grammar_file, |
| ] |
| outputs = [ |
| output_file, |
| ] |
| } |
| action("vendor_tables_amd_gcn_shader") { |
| script = "utils/generate_grammar_tables.py" |
| input_grammar_file = "source/extinst.spv-amd-gcn-shader.grammar.json" |
| output_file = "$target_gen_dir/spv-amd-gcn-shader.insts.inc" |
| args = [ |
| "--extinst-vendor-grammar=" + |
| rebase_path(input_grammar_file, root_build_dir), |
| "--vendor-insts-output=" + rebase_path(output_file, root_build_dir), |
| ] |
| sources = [ |
| input_grammar_file, |
| ] |
| outputs = [ |
| output_file, |
| ] |
| } |
| action("vendor_tables_amd_shader_ballot") { |
| script = "utils/generate_grammar_tables.py" |
| input_grammar_file = "source/extinst.spv-amd-shader-ballot.grammar.json" |
| output_file = "$target_gen_dir/spv-amd-shader-ballot.insts.inc" |
| args = [ |
| "--extinst-vendor-grammar=" + |
| rebase_path(input_grammar_file, root_build_dir), |
| "--vendor-insts-output=" + rebase_path(output_file, root_build_dir), |
| ] |
| sources = [ |
| input_grammar_file, |
| ] |
| outputs = [ |
| output_file, |
| ] |
| } |
| action("vendor_tables_amd_shader_explicit_vertex_parameter") { |
| script = "utils/generate_grammar_tables.py" |
| input_grammar_file = |
| "source/extinst.spv-amd-shader-explicit-vertex-parameter.grammar.json" |
| output_file = |
| "$target_gen_dir/spv-amd-shader-explicit-vertex-parameter.insts.inc" |
| args = [ |
| "--extinst-vendor-grammar=" + |
| rebase_path(input_grammar_file, root_build_dir), |
| "--vendor-insts-output=" + rebase_path(output_file, root_build_dir), |
| ] |
| sources = [ |
| input_grammar_file, |
| ] |
| outputs = [ |
| output_file, |
| ] |
| } |
| action("vendor_tables_amd_shader_trinary_minmax") { |
| script = "utils/generate_grammar_tables.py" |
| input_grammar_file = |
| "source/extinst.spv-amd-shader-trinary-minmax.grammar.json" |
| output_file = "$target_gen_dir/spv-amd-shader-trinary-minmax.insts.inc" |
| args = [ |
| "--extinst-vendor-grammar=" + |
| rebase_path(input_grammar_file, root_build_dir), |
| "--vendor-insts-output=" + rebase_path(output_file, root_build_dir), |
| ] |
| sources = [ |
| input_grammar_file, |
| ] |
| outputs = [ |
| output_file, |
| ] |
| } |
| config("include_config") { |
| include_dirs = [ |
| "external/spirv-headers/include", |
| "include", |
| "source", |
| ".", |
| target_gen_dir, |
| ] |
| } |
| group("spirv-deps") { |
| public_configs = [ ":include_config" ] |
| deps = [ |
| ":generate_include_files", |
| ] |
| } |
| static_library("spirv-tools") { |
| configs += [ ":spirv_warnings" ] |
| public_configs = [ "//third_party/shaderc/fake_sys:config" ] |
| deps = [ |
| ":spirv-deps", |
| ] |
| sources = [ |
| "source/assembly_grammar.cpp", |
| "source/binary.cpp", |
| "source/diagnostic.cpp", |
| "source/disassemble.cpp", |
| "source/enum_string_mapping.cpp", |
| "source/ext_inst.cpp", |
| "source/extensions.cpp", |
| "source/id_descriptor.cpp", |
| "source/libspirv.cpp", |
| "source/message.cpp", |
| "source/name_mapper.cpp", |
| "source/opcode.cpp", |
| "source/operand.cpp", |
| "source/parsed_operand.cpp", |
| "source/print.cpp", |
| "source/software_version.cpp", |
| "source/spirv_endian.cpp", |
| "source/spirv_stats.cpp", |
| "source/spirv_target_env.cpp", |
| "source/spirv_validator_options.cpp", |
| "source/table.cpp", |
| "source/text.cpp", |
| "source/text_handler.cpp", |
| "source/util/bit_stream.cpp", |
| "source/util/parse_number.cpp", |
| "source/util/string_utils.cpp", |
| "source/util/timer.cpp", |
| "source/val/basic_block.cpp", |
| "source/val/construct.cpp", |
| "source/val/function.cpp", |
| "source/val/instruction.cpp", |
| "source/val/validation_state.cpp", |
| "source/validate.cpp", |
| "source/validate_adjacency.cpp", |
| "source/validate_arithmetics.cpp", |
| "source/validate_atomics.cpp", |
| "source/validate_barriers.cpp", |
| "source/validate_bitwise.cpp", |
| "source/validate_builtins.cpp", |
| "source/validate_capability.cpp", |
| "source/validate_cfg.cpp", |
| "source/validate_composites.cpp", |
| "source/validate_conversion.cpp", |
| "source/validate_datarules.cpp", |
| "source/validate_decorations.cpp", |
| "source/validate_derivatives.cpp", |
| "source/validate_ext_inst.cpp", |
| "source/validate_id.cpp", |
| "source/validate_image.cpp", |
| "source/validate_instruction.cpp", |
| "source/validate_layout.cpp", |
| "source/validate_literals.cpp", |
| "source/validate_logicals.cpp", |
| "source/validate_primitives.cpp", |
| "source/validate_type_unique.cpp", |
| ] |
| } |
| static_library("spirv-tools-opt") { |
| configs += [ ":spirv_warnings" ] |
| deps = [ |
| ":spirv-deps", |
| ":spirv-tools", |
| ] |
| sources = [ |
| "source/opt/aggressive_dead_code_elim_pass.cpp", |
| "source/opt/basic_block.cpp", |
| "source/opt/block_merge_pass.cpp", |
| "source/opt/build_module.cpp", |
| "source/opt/ccp_pass.cpp", |
| "source/opt/cfg.cpp", |
| "source/opt/cfg_cleanup_pass.cpp", |
| "source/opt/common_uniform_elim_pass.cpp", |
| "source/opt/compact_ids_pass.cpp", |
| "source/opt/composite.cpp", |
| "source/opt/const_folding_rules.cpp", |
| "source/opt/constants.cpp", |
| "source/opt/copy_prop_arrays.cpp", |
| "source/opt/dead_branch_elim_pass.cpp", |
| "source/opt/dead_insert_elim_pass.cpp", |
| "source/opt/dead_variable_elimination.cpp", |
| "source/opt/decoration_manager.cpp", |
| "source/opt/def_use_manager.cpp", |
| "source/opt/dominator_analysis.cpp", |
| "source/opt/dominator_tree.cpp", |
| "source/opt/eliminate_dead_constant_pass.cpp", |
| "source/opt/eliminate_dead_functions_pass.cpp", |
| "source/opt/feature_manager.cpp", |
| "source/opt/flatten_decoration_pass.cpp", |
| "source/opt/fold.cpp", |
| "source/opt/fold_spec_constant_op_and_composite_pass.cpp", |
| "source/opt/folding_rules.cpp", |
| "source/opt/freeze_spec_constant_value_pass.cpp", |
| "source/opt/function.cpp", |
| "source/opt/if_conversion.cpp", |
| "source/opt/inline_exhaustive_pass.cpp", |
| "source/opt/inline_opaque_pass.cpp", |
| "source/opt/inline_pass.cpp", |
| "source/opt/insert_extract_elim.cpp", |
| "source/opt/instruction.cpp", |
| "source/opt/instruction_list.cpp", |
| "source/opt/ir_context.cpp", |
| "source/opt/ir_loader.cpp", |
| "source/opt/licm_pass.cpp", |
| "source/opt/local_access_chain_convert_pass.cpp", |
| "source/opt/local_redundancy_elimination.cpp", |
| "source/opt/local_single_block_elim_pass.cpp", |
| "source/opt/local_single_store_elim_pass.cpp", |
| "source/opt/local_ssa_elim_pass.cpp", |
| "source/opt/loop_descriptor.cpp", |
| "source/opt/loop_peeling.cpp", |
| "source/opt/loop_unroller.cpp", |
| "source/opt/loop_unswitch_pass.cpp", |
| "source/opt/loop_utils.cpp", |
| "source/opt/mem_pass.cpp", |
| "source/opt/merge_return_pass.cpp", |
| "source/opt/module.cpp", |
| "source/opt/optimizer.cpp", |
| "source/opt/pass.cpp", |
| "source/opt/pass_manager.cpp", |
| "source/opt/private_to_local_pass.cpp", |
| "source/opt/propagator.cpp", |
| "source/opt/redundancy_elimination.cpp", |
| "source/opt/remove_duplicates_pass.cpp", |
| "source/opt/replace_invalid_opc.cpp", |
| "source/opt/scalar_analysis.cpp", |
| "source/opt/scalar_analysis_simplification.cpp", |
| "source/opt/scalar_replacement_pass.cpp", |
| "source/opt/set_spec_constant_default_value_pass.cpp", |
| "source/opt/simplification_pass.cpp", |
| "source/opt/ssa_rewrite_pass.cpp", |
| "source/opt/strength_reduction_pass.cpp", |
| "source/opt/strip_debug_info_pass.cpp", |
| "source/opt/strip_reflect_info_pass.cpp", |
| "source/opt/type_manager.cpp", |
| "source/opt/types.cpp", |
| "source/opt/unify_const_pass.cpp", |
| "source/opt/value_number_table.cpp", |
| "source/opt/workaround1209.cpp", |
| ] |
| } |
| executable("spirv-opt") { |
| deps = [ |
| ":spirv-deps", |
| ":spirv-tools", |
| ":spirv-tools-opt", |
| ] |
| sources = [ |
| "tools/opt/opt.cpp", |
| ] |
| } |
| executable("spirv-dis") { |
| deps = [ |
| ":spirv-deps", |
| ":spirv-tools", |
| ] |
| sources = [ |
| "tools/dis/dis.cpp", |
| ] |
| } |
| executable("spirv-cfg") { |
| deps = [ |
| ":spirv-deps", |
| ":spirv-tools", |
| ] |
| sources = [ |
| "tools/cfg/bin_to_dot.cpp", |
| "tools/cfg/cfg.cpp", |
| ] |
| } |
| executable("spirv-val") { |
| deps = [ |
| ":spirv-deps", |
| ":spirv-tools", |
| ] |
| sources = [ |
| "tools/val/val.cpp", |
| ] |
| } |
| executable("spirv-as") { |
| deps = [ |
| ":spirv-deps", |
| ":spirv-tools", |
| ] |
| sources = [ |
| "tools/as/as.cpp", |
| ] |
| } |
| executable("spirv-tools-cpp-example") { |
| deps = [ |
| ":spirv-tools", |
| ":spirv-tools-opt", |
| ] |
| include_dirs = [ "include" ] |
| sources = [ |
| "examples/cpp-interface/main.cpp", |
| ] |
| } |