blob: c36f031317825c47cb6eddbd34a9717f00876502 [file] [log] [blame] [edit]
# Copyright 2021 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")
###############################################################################
# Common - Configs, etc. shared across targets
###############################################################################
config("tint_common_config") {
include_dirs = [
"${target_gen_dir}",
"${tint_root_dir}/",
"${tint_spirv_headers_dir}/include",
"${tint_spirv_tools_dir}/",
"${tint_spirv_tools_dir}/include",
]
}
config("tint_public_config") {
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" ]
}
if (tint_build_wgsl_reader) {
defines += [ "TINT_BUILD_WGSL_READER=1" ]
} else {
defines += [ "TINT_BUILD_WGSL_READER=0" ]
}
if (tint_build_wgsl_writer) {
defines += [ "TINT_BUILD_WGSL_WRITER=1" ]
} else {
defines += [ "TINT_BUILD_WGSL_WRITER=0" ]
}
if (tint_build_msl_writer) {
defines += [ "TINT_BUILD_MSL_WRITER=1" ]
} else {
defines += [ "TINT_BUILD_MSL_WRITER=0" ]
}
if (tint_build_hlsl_writer) {
defines += [ "TINT_BUILD_HLSL_WRITER=1" ]
} else {
defines += [ "TINT_BUILD_HLSL_WRITER=0" ]
}
if (tint_build_glsl_writer) {
defines += [ "TINT_BUILD_GLSL_WRITER=1" ]
} else {
defines += [ "TINT_BUILD_GLSL_WRITER=0" ]
}
include_dirs = [
"${tint_root_dir}/",
"${tint_root_dir}/include/",
"${tint_spirv_headers_dir}/include",
]
}
config("tint_config") {
include_dirs = []
if (tint_build_spv_reader || tint_build_spv_writer) {
include_dirs += [ "${tint_spirv_tools_dir}/include/" ]
}
}
###############################################################################
# Helper library for IO operations
# Only to be used by tests and sample executable
###############################################################################
source_set("tint_utils_io") {
sources = [
"utils/io/command.h",
"utils/io/tmpfile.h",
]
if (is_linux || is_mac) {
sources += [ "utils/io/command_posix.cc" ]
sources += [ "utils/io/tmpfile_posix.cc" ]
} else if (is_win) {
sources += [ "utils/io/command_windows.cc" ]
sources += [ "utils/io/tmpfile_windows.cc" ]
} else {
sources += [ "utils/io/command_other.cc" ]
sources += [ "utils/io/tmpfile_other.cc" ]
}
public_deps = [ ":libtint_core_all_src" ]
}
###############################################################################
# Helper library for validating generated shaders
# As this depends on tint_utils_io, this is only to be used by tests and sample
# executable
###############################################################################
source_set("tint_val") {
sources = [
"val/hlsl.cc",
"val/msl.cc",
"val/val.h",
]
public_deps = [ ":tint_utils_io" ]
}
###############################################################################
# Library - Tint core and optional modules of libtint
###############################################################################
# libtint source sets are divided into a non-optional core in :libtint_core_src
# and optional :libtint_*_src 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.
template("libtint_source_set") {
source_set(target_name) {
forward_variables_from(invoker, "*", [ "configs" ])
if (!defined(invoker.deps)) {
deps = []
}
deps += [
"${tint_spirv_headers_dir}:spv_headers",
"${tint_spirv_tools_dir}:spvtools_core_enums_unified1",
"${tint_spirv_tools_dir}:spvtools_core_tables_unified1",
"${tint_spirv_tools_dir}:spvtools_headers",
"${tint_spirv_tools_dir}:spvtools_language_header_cldebuginfo100",
"${tint_spirv_tools_dir}:spvtools_language_header_debuginfo",
"${tint_spirv_tools_dir}:spvtools_language_header_vkdebuginfo100",
]
if (defined(invoker.configs)) {
configs += invoker.configs
}
configs += [ ":tint_common_config" ]
if (build_with_chromium) {
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
}
if (!defined(invoker.public_configs)) {
public_configs = []
}
public_configs += [ ":tint_public_config" ]
}
}
libtint_source_set("libtint_core_all_src") {
sources = [
"ast/access.cc",
"ast/access.h",
"ast/alias.cc",
"ast/alias.h",
"ast/array.cc",
"ast/array.h",
"ast/assignment_statement.cc",
"ast/assignment_statement.h",
"ast/ast_type.cc", # TODO(bclayton) - rename to type.cc
"ast/atomic.cc",
"ast/atomic.h",
"ast/binary_expression.cc",
"ast/binary_expression.h",
"ast/binding_decoration.cc",
"ast/binding_decoration.h",
"ast/bitcast_expression.cc",
"ast/bitcast_expression.h",
"ast/block_statement.cc",
"ast/block_statement.h",
"ast/bool.cc",
"ast/bool.h",
"ast/bool_literal_expression.cc",
"ast/bool_literal_expression.h",
"ast/break_statement.cc",
"ast/break_statement.h",
"ast/builtin.cc",
"ast/builtin.h",
"ast/builtin_decoration.cc",
"ast/builtin_decoration.h",
"ast/call_expression.cc",
"ast/call_expression.h",
"ast/call_statement.cc",
"ast/call_statement.h",
"ast/case_statement.cc",
"ast/case_statement.h",
"ast/continue_statement.cc",
"ast/continue_statement.h",
"ast/decoration.cc",
"ast/decoration.h",
"ast/depth_multisampled_texture.cc",
"ast/depth_multisampled_texture.h",
"ast/depth_texture.cc",
"ast/depth_texture.h",
"ast/disable_validation_decoration.cc",
"ast/disable_validation_decoration.h",
"ast/discard_statement.cc",
"ast/discard_statement.h",
"ast/else_statement.cc",
"ast/else_statement.h",
"ast/expression.cc",
"ast/expression.h",
"ast/external_texture.cc",
"ast/external_texture.h",
"ast/f32.cc",
"ast/f32.h",
"ast/fallthrough_statement.cc",
"ast/fallthrough_statement.h",
"ast/float_literal_expression.cc",
"ast/float_literal_expression.h",
"ast/for_loop_statement.cc",
"ast/for_loop_statement.h",
"ast/function.cc",
"ast/function.h",
"ast/group_decoration.cc",
"ast/group_decoration.h",
"ast/i32.cc",
"ast/i32.h",
"ast/identifier_expression.cc",
"ast/identifier_expression.h",
"ast/if_statement.cc",
"ast/if_statement.h",
"ast/index_accessor_expression.cc",
"ast/index_accessor_expression.h",
"ast/int_literal_expression.cc",
"ast/int_literal_expression.h",
"ast/internal_decoration.cc",
"ast/internal_decoration.h",
"ast/interpolate_decoration.cc",
"ast/interpolate_decoration.h",
"ast/invariant_decoration.cc",
"ast/invariant_decoration.h",
"ast/literal_expression.cc",
"ast/literal_expression.h",
"ast/location_decoration.cc",
"ast/location_decoration.h",
"ast/loop_statement.cc",
"ast/loop_statement.h",
"ast/matrix.cc",
"ast/matrix.h",
"ast/member_accessor_expression.cc",
"ast/member_accessor_expression.h",
"ast/module.cc",
"ast/module.h",
"ast/multisampled_texture.cc",
"ast/multisampled_texture.h",
"ast/node.cc",
"ast/node.h",
"ast/override_decoration.cc",
"ast/override_decoration.h",
"ast/phony_expression.cc",
"ast/phony_expression.h",
"ast/pipeline_stage.cc",
"ast/pipeline_stage.h",
"ast/pointer.cc",
"ast/pointer.h",
"ast/return_statement.cc",
"ast/return_statement.h",
"ast/sampled_texture.cc",
"ast/sampled_texture.h",
"ast/sampler.cc",
"ast/sampler.h",
"ast/sint_literal_expression.cc",
"ast/sint_literal_expression.h",
"ast/stage_decoration.cc",
"ast/stage_decoration.h",
"ast/statement.cc",
"ast/statement.h",
"ast/storage_class.cc",
"ast/storage_class.h",
"ast/storage_texture.cc",
"ast/storage_texture.h",
"ast/stride_decoration.cc",
"ast/stride_decoration.h",
"ast/struct.cc",
"ast/struct.h",
"ast/struct_block_decoration.cc",
"ast/struct_block_decoration.h",
"ast/struct_member.cc",
"ast/struct_member.h",
"ast/struct_member_align_decoration.cc",
"ast/struct_member_align_decoration.h",
"ast/struct_member_offset_decoration.cc",
"ast/struct_member_offset_decoration.h",
"ast/struct_member_size_decoration.cc",
"ast/struct_member_size_decoration.h",
"ast/switch_statement.cc",
"ast/switch_statement.h",
"ast/texture.cc",
"ast/texture.h",
"ast/traverse_expressions.h",
"ast/type.h",
"ast/type_decl.cc",
"ast/type_decl.h",
"ast/type_name.cc",
"ast/type_name.h",
"ast/u32.cc",
"ast/u32.h",
"ast/uint_literal_expression.cc",
"ast/uint_literal_expression.h",
"ast/unary_op.cc",
"ast/unary_op.h",
"ast/unary_op_expression.cc",
"ast/unary_op_expression.h",
"ast/variable.cc",
"ast/variable.h",
"ast/variable_decl_statement.cc",
"ast/variable_decl_statement.h",
"ast/vector.cc",
"ast/vector.h",
"ast/void.cc",
"ast/void.h",
"ast/workgroup_decoration.cc",
"ast/workgroup_decoration.h",
"block_allocator.h",
"castable.cc",
"castable.h",
"clone_context.cc",
"clone_context.h",
"debug.cc",
"debug.h",
"demangler.cc",
"demangler.h",
"diagnostic/diagnostic.cc",
"diagnostic/diagnostic.h",
"diagnostic/formatter.cc",
"diagnostic/formatter.h",
"diagnostic/printer.cc",
"diagnostic/printer.h",
"inspector/entry_point.cc",
"inspector/entry_point.h",
"inspector/inspector.cc",
"inspector/inspector.h",
"inspector/resource_binding.cc",
"inspector/resource_binding.h",
"inspector/scalar.cc",
"inspector/scalar.h",
"intrinsic_table.cc",
"intrinsic_table.h",
"intrinsic_table.inl",
"program.cc",
"program.h",
"program_builder.cc",
"program_builder.h",
"program_id.cc",
"program_id.h",
"reader/reader.cc",
"reader/reader.h",
"resolver/dependency_graph.cc",
"resolver/dependency_graph.h",
"resolver/resolver.cc",
"resolver/resolver.h",
"resolver/resolver_constants.cc",
"resolver/resolver_validation.cc",
"scope_stack.h",
"sem/array.h",
"sem/atomic_type.h",
"sem/behavior.h",
"sem/binding_point.h",
"sem/bool_type.h",
"sem/call.h",
"sem/call_target.h",
"sem/constant.h",
"sem/depth_multisampled_texture_type.h",
"sem/depth_texture_type.h",
"sem/expression.h",
"sem/external_texture_type.h",
"sem/f32_type.h",
"sem/for_loop_statement.h",
"sem/i32_type.h",
"sem/if_statement.h",
"sem/info.h",
"sem/intrinsic.h",
"sem/intrinsic_type.h",
"sem/loop_statement.h",
"sem/matrix_type.h",
"sem/multisampled_texture_type.h",
"sem/node.h",
"sem/parameter_usage.h",
"sem/pipeline_stage_set.h",
"sem/pointer_type.h",
"sem/reference_type.h",
"sem/sampled_texture_type.h",
"sem/sampler_texture_pair.h",
"sem/sampler_type.h",
"sem/storage_texture_type.h",
"sem/switch_statement.h",
"sem/texture_type.h",
"sem/type.h",
"sem/type_constructor.h",
"sem/type_conversion.h",
"sem/type_manager.h",
"sem/type_mappings.h",
"sem/u32_type.h",
"sem/vector_type.h",
"sem/void_type.h",
"source.cc",
"source.h",
"symbol.cc",
"symbol.h",
"symbol_table.cc",
"symbol_table.h",
"traits.h",
"transform/add_empty_entry_point.cc",
"transform/add_empty_entry_point.h",
"transform/add_spirv_block_decoration.cc",
"transform/add_spirv_block_decoration.h",
"transform/array_length_from_uniform.cc",
"transform/array_length_from_uniform.h",
"transform/binding_remapper.cc",
"transform/binding_remapper.h",
"transform/calculate_array_length.cc",
"transform/calculate_array_length.h",
"transform/canonicalize_entry_point_io.cc",
"transform/canonicalize_entry_point_io.h",
"transform/decompose_memory_access.cc",
"transform/decompose_memory_access.h",
"transform/decompose_strided_matrix.cc",
"transform/decompose_strided_matrix.h",
"transform/external_texture_transform.cc",
"transform/external_texture_transform.h",
"transform/first_index_offset.cc",
"transform/first_index_offset.h",
"transform/fold_constants.cc",
"transform/fold_constants.h",
"transform/fold_trivial_single_use_lets.cc",
"transform/fold_trivial_single_use_lets.h",
"transform/for_loop_to_loop.cc",
"transform/for_loop_to_loop.h",
"transform/localize_struct_array_assignment.cc",
"transform/localize_struct_array_assignment.h",
"transform/loop_to_for_loop.cc",
"transform/loop_to_for_loop.h",
"transform/manager.cc",
"transform/manager.h",
"transform/module_scope_var_to_entry_point_param.cc",
"transform/module_scope_var_to_entry_point_param.h",
"transform/multiplanar_external_texture.cc",
"transform/multiplanar_external_texture.h",
"transform/num_workgroups_from_uniform.cc",
"transform/num_workgroups_from_uniform.h",
"transform/pad_array_elements.cc",
"transform/pad_array_elements.h",
"transform/promote_initializers_to_const_var.cc",
"transform/promote_initializers_to_const_var.h",
"transform/remove_phonies.cc",
"transform/remove_phonies.h",
"transform/remove_unreachable_statements.cc",
"transform/remove_unreachable_statements.h",
"transform/renamer.cc",
"transform/renamer.h",
"transform/robustness.cc",
"transform/robustness.h",
"transform/simplify_pointers.cc",
"transform/simplify_pointers.h",
"transform/single_entry_point.cc",
"transform/single_entry_point.h",
"transform/transform.cc",
"transform/transform.h",
"transform/unshadow.cc",
"transform/unshadow.h",
"transform/var_for_dynamic_index.cc",
"transform/var_for_dynamic_index.h",
"transform/vectorize_scalar_matrix_constructors.cc",
"transform/vectorize_scalar_matrix_constructors.h",
"transform/vertex_pulling.cc",
"transform/vertex_pulling.h",
"transform/wrap_arrays_in_structs.cc",
"transform/wrap_arrays_in_structs.h",
"transform/zero_init_workgroup_memory.cc",
"transform/zero_init_workgroup_memory.h",
"utils/enum_set.h",
"utils/hash.h",
"utils/map.h",
"utils/math.h",
"utils/scoped_assignment.h",
"utils/string.h",
"utils/unique_vector.h",
"writer/append_vector.cc",
"writer/append_vector.h",
"writer/array_length_from_uniform_options.cc",
"writer/array_length_from_uniform_options.h",
"writer/float_to_string.cc",
"writer/float_to_string.h",
"writer/text.cc",
"writer/text.h",
"writer/text_generator.cc",
"writer/text_generator.h",
"writer/writer.cc",
"writer/writer.h",
]
if (is_linux) {
sources += [ "diagnostic/printer_linux.cc" ]
} else if (is_win) {
sources += [ "diagnostic/printer_windows.cc" ]
} else {
sources += [ "diagnostic/printer_other.cc" ]
}
}
libtint_source_set("libtint_sem_src") {
sources = [
"sem/array.cc",
"sem/array.h",
"sem/atomic_type.cc",
"sem/atomic_type.h",
"sem/behavior.cc",
"sem/behavior.h",
"sem/binding_point.h",
"sem/block_statement.cc",
"sem/bool_type.cc",
"sem/bool_type.h",
"sem/call.cc",
"sem/call.h",
"sem/call_target.cc",
"sem/call_target.h",
"sem/constant.cc",
"sem/constant.h",
"sem/depth_multisampled_texture_type.cc",
"sem/depth_multisampled_texture_type.h",
"sem/depth_texture_type.cc",
"sem/depth_texture_type.h",
"sem/expression.cc",
"sem/expression.h",
"sem/external_texture_type.cc",
"sem/external_texture_type.h",
"sem/f32_type.cc",
"sem/f32_type.h",
"sem/for_loop_statement.cc",
"sem/for_loop_statement.h",
"sem/function.cc",
"sem/i32_type.cc",
"sem/i32_type.h",
"sem/if_statement.cc",
"sem/if_statement.h",
"sem/info.cc",
"sem/info.h",
"sem/intrinsic.cc",
"sem/intrinsic.h",
"sem/intrinsic_type.cc",
"sem/intrinsic_type.h",
"sem/loop_statement.cc",
"sem/loop_statement.h",
"sem/matrix_type.cc",
"sem/matrix_type.h",
"sem/member_accessor_expression.cc",
"sem/multisampled_texture_type.cc",
"sem/multisampled_texture_type.h",
"sem/node.cc",
"sem/node.h",
"sem/parameter_usage.cc",
"sem/parameter_usage.h",
"sem/pipeline_stage_set.h",
"sem/pointer_type.cc",
"sem/pointer_type.h",
"sem/reference_type.cc",
"sem/reference_type.h",
"sem/sampled_texture_type.cc",
"sem/sampled_texture_type.h",
"sem/sampler_type.cc",
"sem/sampler_type.h",
"sem/statement.cc",
"sem/storage_texture_type.cc",
"sem/storage_texture_type.h",
"sem/struct.cc",
"sem/switch_statement.cc",
"sem/switch_statement.h",
"sem/texture_type.cc",
"sem/texture_type.h",
"sem/type.cc",
"sem/type.h",
"sem/type_constructor.cc",
"sem/type_constructor.h",
"sem/type_conversion.cc",
"sem/type_conversion.h",
"sem/type_manager.cc",
"sem/type_manager.h",
"sem/type_mappings.h",
"sem/u32_type.cc",
"sem/u32_type.h",
"sem/variable.cc",
"sem/vector_type.cc",
"sem/vector_type.h",
"sem/void_type.cc",
"sem/void_type.h",
]
public_deps = [ ":libtint_core_all_src" ]
}
libtint_source_set("libtint_core_src") {
public_deps = [
":libtint_core_all_src",
":libtint_sem_src",
]
}
libtint_source_set("libtint_spv_reader_src") {
sources = [
"reader/spirv/construct.cc",
"reader/spirv/construct.h",
"reader/spirv/entry_point_info.cc",
"reader/spirv/entry_point_info.h",
"reader/spirv/enum_converter.cc",
"reader/spirv/enum_converter.h",
"reader/spirv/fail_stream.h",
"reader/spirv/function.cc",
"reader/spirv/function.h",
"reader/spirv/namer.cc",
"reader/spirv/namer.h",
"reader/spirv/parser.cc",
"reader/spirv/parser.h",
"reader/spirv/parser_impl.cc",
"reader/spirv/parser_impl.h",
"reader/spirv/parser_type.cc",
"reader/spirv/parser_type.h",
"reader/spirv/usage.cc",
"reader/spirv/usage.h",
]
public_deps = [
":libtint_core_src",
"${tint_spirv_tools_dir}/:spvtools_opt",
]
public_configs = [ "${tint_spirv_tools_dir}/:spvtools_internal_config" ]
}
libtint_source_set("libtint_spv_writer_src") {
sources = [
"writer/spirv/binary_writer.cc",
"writer/spirv/binary_writer.h",
"writer/spirv/builder.cc",
"writer/spirv/builder.h",
"writer/spirv/function.cc",
"writer/spirv/function.h",
"writer/spirv/generator.cc",
"writer/spirv/generator.h",
"writer/spirv/instruction.cc",
"writer/spirv/instruction.h",
"writer/spirv/operand.cc",
"writer/spirv/operand.h",
"writer/spirv/scalar_constant.h",
]
public_deps = [ ":libtint_core_src" ]
}
libtint_source_set("libtint_wgsl_reader_src") {
sources = [
"reader/wgsl/lexer.cc",
"reader/wgsl/lexer.h",
"reader/wgsl/parser.cc",
"reader/wgsl/parser.h",
"reader/wgsl/parser_impl.cc",
"reader/wgsl/parser_impl.h",
"reader/wgsl/parser_impl_detail.h",
"reader/wgsl/token.cc",
"reader/wgsl/token.h",
]
public_deps = [ ":libtint_core_src" ]
}
libtint_source_set("libtint_wgsl_writer_src") {
sources = [
"writer/wgsl/generator.cc",
"writer/wgsl/generator.h",
"writer/wgsl/generator_impl.cc",
"writer/wgsl/generator_impl.h",
]
public_deps = [ ":libtint_core_src" ]
}
libtint_source_set("libtint_msl_writer_src") {
sources = [
"writer/msl/generator.cc",
"writer/msl/generator.h",
"writer/msl/generator_impl.cc",
"writer/msl/generator_impl.h",
]
public_deps = [ ":libtint_core_src" ]
}
libtint_source_set("libtint_hlsl_writer_src") {
sources = [
"writer/hlsl/generator.cc",
"writer/hlsl/generator.h",
"writer/hlsl/generator_impl.cc",
"writer/hlsl/generator_impl.h",
]
public_deps = [ ":libtint_core_src" ]
}
libtint_source_set("libtint_glsl_writer_src") {
sources = [
"transform/glsl.cc",
"transform/glsl.h",
"writer/glsl/generator.cc",
"writer/glsl/generator.h",
"writer/glsl/generator_impl.cc",
"writer/glsl/generator_impl.h",
]
public_deps = [ ":libtint_core_src" ]
}
source_set("libtint") {
public_deps = [ ":libtint_core_src" ]
if (tint_build_spv_reader) {
public_deps += [ ":libtint_spv_reader_src" ]
}
if (tint_build_spv_writer) {
public_deps += [ ":libtint_spv_writer_src" ]
}
if (tint_build_wgsl_reader) {
public_deps += [ ":libtint_wgsl_reader_src" ]
}
if (tint_build_wgsl_writer) {
public_deps += [ ":libtint_wgsl_writer_src" ]
}
if (tint_build_msl_writer) {
public_deps += [ ":libtint_msl_writer_src" ]
}
if (tint_build_hlsl_writer) {
public_deps += [ ":libtint_hlsl_writer_src" ]
}
if (tint_build_glsl_writer) {
public_deps += [ ":libtint_glsl_writer_src" ]
}
configs += [ ":tint_common_config" ]
public_configs = [ ":tint_public_config" ]
if (build_with_chromium) {
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
}
}