| # Copyright 2020 The Tint Authors |
| # |
| # Licensed under the Apache License, Version 2.0 (the "License"); |
| # you may not use this file except in compliance with the License. |
| # You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| # See the License for the specific language governing permissions and |
| # limitations under the License. |
| |
| import("//build_overrides/build.gni") |
| import("tint_overrides_with_defaults.gni") |
| |
| config("tint_common_config") { |
| cflags = [] |
| ldflags = [] |
| include_dirs = [] |
| defines = [] |
| |
| if (tint_build_spv_reader) { |
| defines += [ "TINT_BUILD_SPV_READER=1" ] |
| } else { |
| defines += [ "TINT_BUILD_SPV_READER=0" ] |
| } |
| |
| if (tint_build_spv_writer) { |
| defines += [ "TINT_BUILD_SPV_WRITER=1" ] |
| } else { |
| defines += [ "TINT_BUILD_SPV_WRITER=0" ] |
| } |
| } |
| |
| # libtint source sets are divided into a non-optional core in :libtint_core and |
| # optional :libtint_* subsets, because ninja does not like having multiple source |
| # files with the same name, like function.cc, in the same source set target. |
| # |
| # Targets that want to use tint as a library should depend on ":libtint" and use |
| # the build flags to control what is included, instead of trying to specify the |
| # subsets that they want. |
| |
| source_set("libtint_core") { |
| sources = [ |
| "src/ast/array_accessor_expression.cc", |
| "src/ast/array_accessor_expression.h", |
| "src/ast/as_expression.cc", |
| "src/ast/as_expression.h", |
| "src/ast/assignment_statement.cc", |
| "src/ast/assignment_statement.h", |
| "src/ast/binary_expression.cc", |
| "src/ast/binary_expression.h", |
| "src/ast/binding_decoration.cc", |
| "src/ast/binding_decoration.h", |
| "src/ast/bool_literal.cc", |
| "src/ast/bool_literal.h", |
| "src/ast/break_statement.cc", |
| "src/ast/break_statement.h", |
| "src/ast/builtin.cc", |
| "src/ast/builtin.h", |
| "src/ast/builtin_decoration.cc", |
| "src/ast/builtin_decoration.h", |
| "src/ast/call_expression.cc", |
| "src/ast/call_expression.h", |
| "src/ast/case_statement.cc", |
| "src/ast/case_statement.h", |
| "src/ast/cast_expression.cc", |
| "src/ast/cast_expression.h", |
| "src/ast/constructor_expression.cc", |
| "src/ast/constructor_expression.h", |
| "src/ast/continue_statement.cc", |
| "src/ast/continue_statement.h", |
| "src/ast/decorated_variable.cc", |
| "src/ast/decorated_variable.h", |
| "src/ast/derivative_modifier.cc", |
| "src/ast/derivative_modifier.h", |
| "src/ast/else_statement.cc", |
| "src/ast/else_statement.h", |
| "src/ast/entry_point.cc", |
| "src/ast/entry_point.h", |
| "src/ast/expression.cc", |
| "src/ast/expression.h", |
| "src/ast/fallthrough_statement.cc", |
| "src/ast/fallthrough_statement.h", |
| "src/ast/float_literal.cc", |
| "src/ast/float_literal.h", |
| "src/ast/function.cc", |
| "src/ast/function.h", |
| "src/ast/identifier_expression.cc", |
| "src/ast/identifier_expression.h", |
| "src/ast/if_statement.cc", |
| "src/ast/if_statement.h", |
| "src/ast/import.cc", |
| "src/ast/import.h", |
| "src/ast/int_literal.cc", |
| "src/ast/int_literal.h", |
| "src/ast/kill_statement.cc", |
| "src/ast/kill_statement.h", |
| "src/ast/literal.cc", |
| "src/ast/literal.h", |
| "src/ast/location_decoration.cc", |
| "src/ast/location_decoration.h", |
| "src/ast/loop_statement.cc", |
| "src/ast/loop_statement.h", |
| "src/ast/member_accessor_expression.cc", |
| "src/ast/member_accessor_expression.h", |
| "src/ast/module.cc", |
| "src/ast/module.h", |
| "src/ast/node.cc", |
| "src/ast/node.h", |
| "src/ast/nop_statement.cc", |
| "src/ast/nop_statement.h", |
| "src/ast/pipeline_stage.cc", |
| "src/ast/pipeline_stage.h", |
| "src/ast/return_statement.cc", |
| "src/ast/return_statement.h", |
| "src/ast/scalar_constructor_expression.cc", |
| "src/ast/scalar_constructor_expression.h", |
| "src/ast/set_decoration.cc", |
| "src/ast/set_decoration.h", |
| "src/ast/statement.cc", |
| "src/ast/statement.h", |
| "src/ast/statement_condition.cc", |
| "src/ast/statement_condition.h", |
| "src/ast/storage_class.cc", |
| "src/ast/storage_class.h", |
| "src/ast/struct.cc", |
| "src/ast/struct.h", |
| "src/ast/struct_decoration.cc", |
| "src/ast/struct_decoration.h", |
| "src/ast/struct_member.cc", |
| "src/ast/struct_member.h", |
| "src/ast/struct_member_decoration.cc", |
| "src/ast/struct_member_decoration.h", |
| "src/ast/struct_member_offset_decoration.cc", |
| "src/ast/struct_member_offset_decoration.h", |
| "src/ast/switch_statement.cc", |
| "src/ast/switch_statement.h", |
| "src/ast/type/alias_type.cc", |
| "src/ast/type/alias_type.h", |
| "src/ast/type/array_type.cc", |
| "src/ast/type/array_type.h", |
| "src/ast/type/bool_type.cc", |
| "src/ast/type/bool_type.h", |
| "src/ast/type/f32_type.cc", |
| "src/ast/type/f32_type.h", |
| "src/ast/type/i32_type.cc", |
| "src/ast/type/i32_type.h", |
| "src/ast/type/matrix_type.cc", |
| "src/ast/type/matrix_type.h", |
| "src/ast/type/pointer_type.cc", |
| "src/ast/type/pointer_type.h", |
| "src/ast/type/struct_type.cc", |
| "src/ast/type/struct_type.h", |
| "src/ast/type/type.cc", |
| "src/ast/type/type.h", |
| "src/ast/type/u32_type.cc", |
| "src/ast/type/u32_type.h", |
| "src/ast/type/vector_type.cc", |
| "src/ast/type/vector_type.h", |
| "src/ast/type/void_type.cc", |
| "src/ast/type/void_type.h", |
| "src/ast/type_constructor_expression.cc", |
| "src/ast/type_constructor_expression.h", |
| "src/ast/uint_literal.cc", |
| "src/ast/uint_literal.h", |
| "src/ast/unary_derivative.cc", |
| "src/ast/unary_derivative.h", |
| "src/ast/unary_derivative_expression.cc", |
| "src/ast/unary_derivative_expression.h", |
| "src/ast/unary_method.cc", |
| "src/ast/unary_method.h", |
| "src/ast/unary_method_expression.cc", |
| "src/ast/unary_method_expression.h", |
| "src/ast/unary_op.cc", |
| "src/ast/unary_op.h", |
| "src/ast/unary_op_expression.cc", |
| "src/ast/unary_op_expression.h", |
| "src/ast/unless_statement.cc", |
| "src/ast/unless_statement.h", |
| "src/ast/variable.cc", |
| "src/ast/variable.h", |
| "src/ast/variable_decl_statement.cc", |
| "src/ast/variable_decl_statement.h", |
| "src/ast/variable_decoration.cc", |
| "src/ast/variable_decoration.h", |
| "src/context.cc", |
| "src/context.h", |
| "src/reader/reader.cc", |
| "src/reader/reader.h", |
| "src/scope_stack.h", |
| "src/source.h", |
| "src/type_determiner.cc", |
| "src/type_determiner.h", |
| "src/type_manager.cc", |
| "src/type_manager.h", |
| "src/validator.cc", |
| "src/validator.h", |
| "src/validator_impl.cc", |
| "src/validator_impl.h", |
| "src/writer/writer.cc", |
| "src/writer/writer.h", |
| ] |
| |
| configs += [ ":tint_common_config" ] |
| |
| if (build_with_chromium) { |
| configs -= [ "//build/config/compiler:chromium_code" ] |
| configs += [ "//build/config/compiler:no_chromium_code" ] |
| } |
| } |
| |
| config("tint_spv_reader_config") { |
| include_dirs = [ |
| "${tint_spirv_tools_dir}/", |
| "${tint_spirv_tools_dir}/include", |
| "${target_gen_dir}/${tint_spirv_tools_gen}", |
| ] |
| } |
| |
| source_set("libtint_spv_reader") { |
| sources = [ |
| "src/reader/spirv/enum_converter.cc", |
| "src/reader/spirv/enum_converter.h", |
| "src/reader/spirv/fail_stream.h", |
| "src/reader/spirv/function.cc", |
| "src/reader/spirv/function.h", |
| "src/reader/spirv/namer.cc", |
| "src/reader/spirv/namer.h", |
| "src/reader/spirv/parser.cc", |
| "src/reader/spirv/parser.h", |
| "src/reader/spirv/parser_impl.cc", |
| "src/reader/spirv/parser_impl.h", |
| ] |
| |
| deps = [ |
| "${tint_spirv_headers_dir}/:spv_headers", |
| "${tint_spirv_tools_dir}/:spvtools_opt", |
| "${tint_spirv_tools_dir}/:spvtools_val", |
| ] |
| |
| configs += [ ":tint_common_config" ] |
| configs += [ ":tint_spv_reader_config" ] |
| |
| if (build_with_chromium) { |
| configs -= [ "//build/config/compiler:chromium_code" ] |
| configs += [ "//build/config/compiler:no_chromium_code" ] |
| } |
| } |
| |
| source_set("libtint_spv_writer") { |
| sources = [ |
| "src/writer/spirv/binary_writer.cc", |
| "src/writer/spirv/binary_writer.h", |
| "src/writer/spirv/builder.cc", |
| "src/writer/spirv/builder.h", |
| "src/writer/spirv/function.cc", |
| "src/writer/spirv/function.h", |
| "src/writer/spirv/generator.cc", |
| "src/writer/spirv/generator.h", |
| "src/writer/spirv/instruction.cc", |
| "src/writer/spirv/instruction.h", |
| "src/writer/spirv/operand.cc", |
| "src/writer/spirv/operand.h", |
| ] |
| |
| deps = [ "${tint_spirv_headers_dir}/:spv_headers" ] |
| |
| configs += [ ":tint_common_config" ] |
| |
| if (build_with_chromium) { |
| configs -= [ "//build/config/compiler:chromium_code" ] |
| configs += [ "//build/config/compiler:no_chromium_code" ] |
| } |
| } |
| |
| source_set("libtint") { |
| deps = [ ":libtint_core" ] |
| if (tint_build_spv_reader) { |
| deps += [ ":libtint_spv_reader" ] |
| } |
| |
| if (tint_build_spv_writer) { |
| deps += [ ":libtint_spv_writer" ] |
| } |
| |
| configs += [ ":tint_common_config" ] |
| |
| if (build_with_chromium) { |
| configs -= [ "//build/config/compiler:chromium_code" ] |
| configs += [ "//build/config/compiler:no_chromium_code" ] |
| } |
| } |
| |
| executable("tint") { |
| sources = [ "samples/main.cc" ] |
| deps = [ ":libtint" ] |
| |
| configs += [ ":tint_common_config" ] |
| |
| if (build_with_chromium) { |
| configs -= [ "//build/config/compiler:chromium_code" ] |
| configs += [ "//build/config/compiler:no_chromium_code" ] |
| } |
| } |
| |
| group("tint_all") { |
| deps = [ ":tint" ] |
| } |