| # Copyright 2024 The ANGLE Project Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| import("../../../../gni/angle.gni") |
| if (angle_has_build) { |
| import("//build/rust/rust_static_library.gni") |
| } |
| |
| angle_translator_ir_sources = [ |
| "src/ast.rs", |
| "src/builder.rs", |
| "src/compile.rs", |
| "src/debug.rs", |
| "src/gl.rs", |
| "src/instruction.rs", |
| "src/ir.rs", |
| "src/lib.rs", |
| "src/output.rs", |
| "src/output/legacy.rs", |
| "src/output/null.rs", |
| "src/reflection.rs", |
| "src/transform.rs", |
| "src/transform/astify.rs", |
| "src/transform/broadcast_fragcolor.rs", |
| "src/transform/clamp_frag_depth.rs", |
| "src/transform/clamp_point_size.rs", |
| "src/transform/dead_code_eliminate.rs", |
| "src/transform/dealias.rs", |
| "src/transform/emulate_instanced_multiview.rs", |
| "src/transform/emulate_multi_draw.rs", |
| "src/transform/expand_fragment_outputs_to_vec4.rs", |
| "src/transform/initialize_uninitialized_variables.rs", |
| "src/transform/localized_workarounds.rs", |
| "src/transform/monomorphize_unsupported_functions.rs", |
| "src/transform/propagate_precision.rs", |
| "src/transform/remove_unused_framebuffer_fetch.rs", |
| "src/transform/rewrite_array_of_array_of_opaque_uniforms.rs", |
| "src/transform/rewrite_pixel_local_storage.rs", |
| "src/transform/rewrite_struct_samplers.rs", |
| "src/transform/scalarize_vec_and_mat_constructor_args.rs", |
| "src/transform/sort_uniforms.rs", |
| "src/traverser.rs", |
| "src/util.rs", |
| ] |
| |
| if (angle_debug_layers_enabled) { |
| angle_translator_ir_sources += [ "src/validator.rs" ] |
| } |
| |
| if (angle_enable_essl) { |
| angle_translator_ir_sources += [ "src/output/essl.rs" ] |
| } |
| if (angle_enable_glsl) { |
| angle_translator_ir_sources += [ "src/output/glsl.rs" ] |
| } |
| if (angle_enable_hlsl) { |
| angle_translator_ir_sources += [ "src/output/hlsl.rs" ] |
| } |
| if (angle_enable_msl) { |
| angle_translator_ir_sources += [ |
| "src/output/msl.rs", |
| "src/transform/msl/ensure_loop_forward_progress.rs", |
| ] |
| } |
| if (angle_enable_vulkan) { |
| angle_translator_ir_sources += [ |
| "src/output/spirv.rs", |
| "src/transform/spirv/pass1.rs", |
| "src/transform/spirv/vertex_instance_id.rs", |
| ] |
| } |
| if (angle_enable_wgpu) { |
| angle_translator_ir_sources += [ "src/output/wgsl.rs" ] |
| } |
| |
| if (angle_ir) { |
| config("gen_src_include") { |
| include_dirs = [ |
| "$root_gen_dir/src", |
| "$root_gen_dir/third_party/angle/src", |
| ] |
| } |
| |
| rust_static_library("translator_ir") { |
| # Need unsafe because of FFI |
| allow_unsafe = true |
| |
| sources = angle_translator_ir_sources |
| |
| # Set flags based on which of the outputs in `ShShaderOutput` is supported. |
| # If any generator is not built, transformations specific to it and its |
| # code generator are excluded from build. |
| rustflags = [] |
| if (angle_enable_essl) { |
| rustflags += [ |
| "--cfg", |
| "angle_enable_essl", |
| ] |
| } |
| if (angle_enable_glsl) { |
| rustflags += [ |
| "--cfg", |
| "angle_enable_glsl", |
| ] |
| } |
| if (angle_enable_hlsl) { |
| rustflags += [ |
| "--cfg", |
| "angle_enable_hlsl", |
| ] |
| } |
| if (angle_enable_msl) { |
| rustflags += [ |
| "--cfg", |
| "angle_enable_msl", |
| ] |
| } |
| if (angle_enable_vulkan) { |
| rustflags += [ |
| "--cfg", |
| "angle_enable_spirv", |
| ] |
| } |
| if (angle_enable_wgpu) { |
| rustflags += [ |
| "--cfg", |
| "angle_enable_wgsl", |
| ] |
| } |
| |
| cxx_bindings = [ |
| "src/builder.rs", |
| "src/compile.rs", |
| "src/output/legacy.rs", |
| ] |
| |
| # dcheck_always_on automatically sets -Cdebug-assertions, but ANGLE builds |
| # could technically set that to false but enable asserts via |
| # angle_assert_always_on. |
| if (angle_assert_always_on) { |
| rustflags += [ "-Cdebug-assertions" ] |
| } |
| |
| configs += [ |
| "$angle_root:internal_config", |
| ":gen_src_include", |
| ] |
| } |
| } |