BUILD.gn (2399B)
1 # Copyright 2022 The Chromium Authors 2 # Use of this source code is governed by a BSD-style license that can be 3 # found in the LICENSE file. 4 5 import("//chromium/build/config/rust.gni") 6 import("//chromium/build/rust/rust_macro.gni") 7 import("//chromium/build/rust/rust_static_library.gni") 8 9 # Common constants. 10 _support_dir = "{rust_sysroot}/lib/crubit" 11 12 # Dependencies of ..._rs_api.rs files generated by Crubit's 13 # `bin/rs_bindings_from_cc` tool. See also `deps_for_generated_rs_file` in 14 # Crubit's `src/rs_bindings_from_cc/BUILD`. 15 group("deps_of_rs_api") { 16 public_deps = [ 17 ":ctor", 18 ":forward_declare", 19 ":oops", 20 "//third_party/rust/memoffset/v0_6:lib", 21 "//third_party/rust/static_assertions/v1:lib", 22 ] 23 } 24 25 # Dependencies of ..._rs_api_impl.cc files generated by Crubit's 26 # `bin/rs_bindings_from_cc` tool. See also `deps_for_generated_cc_file` in 27 # Crubit's `src/rs_bindings_from_cc/BUILD`. 28 source_set("deps_of_rs_api_impl") { 29 sources = [ 30 "${_support_dir}/cxx20_backports.h", 31 "${_support_dir}/offsetof.h", 32 ] 33 } 34 35 # TODO: crbug.com/40226863 - Crubit should publish a Cargo.toml for these 36 # crates, then we can generate rules for them dynamically with gnrt. 37 rust_static_library("ctor") { 38 crate_root = "${_support_dir}/ctor.rs" 39 sources = [ "${_support_dir}/ctor.rs" ] 40 build_native_rust_unit_tests = true 41 deps = [ ":ctor_proc_macros" ] 42 } 43 44 rust_macro("ctor_proc_macros") { 45 visibility = [ ":*" ] 46 crate_root = "${_support_dir}/ctor_proc_macros.rs" 47 sources = [ "${_support_dir}/ctor_proc_macros.rs" ] 48 deps = [ 49 "//third_party/rust/proc_macro2/v1:lib", 50 "//third_party/rust/quote/v1:lib", 51 "//third_party/rust/syn/v1:lib", 52 ] 53 } 54 55 rust_static_library("forward_declare") { 56 crate_root = "${_support_dir}/forward_declare.rs" 57 sources = [ "${_support_dir}/forward_declare.rs" ] 58 build_native_rust_unit_tests = true 59 deps = [ ":forward_declare_proc_macros" ] 60 } 61 62 rust_macro("forward_declare_proc_macros") { 63 visibility = [ ":*" ] 64 crate_root = "${_support_dir}/forward_declare_proc_macros.rs" 65 sources = [ "${_support_dir}/forward_declare_proc_macros.rs" ] 66 deps = [ 67 "//third_party/rust/proc_macro2/v1:lib", 68 "//third_party/rust/quote/v1:lib", 69 "//third_party/rust/syn/v1:lib", 70 ] 71 } 72 73 rust_static_library("oops") { 74 crate_root = "${_support_dir}/oops.rs" 75 sources = [ "${_support_dir}/oops.rs" ] 76 build_native_rust_unit_tests = true 77 }