• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
5import("//build/rust/rs_bindings_from_cc.gni")
6import("//build/rust/rust_executable.gni")
7
8rust_executable("test_rs_bindings_from_cc") {
9  crate_root = "main.rs"
10  sources = [ "main.rs" ]
11  deps = [
12    ":self_contained_target_rs_api",
13    ":target_depending_on_another_rs_api",
14    "//third_party/crubit:ctor",
15  ]
16  build_native_rust_unit_tests = true
17}
18
19rs_bindings_from_cc("self_contained_target_rs_api") {
20  # This is the target that the bindings are for / call into.
21  bindings_target = ":self_contained_target"
22
23  # Lists public headers from `sources` of `self_contained_target`.
24  public_headers = [
25    "self_contained_target_header1.h",
26    "self_contained_target_header2.h",
27  ]
28}
29
30source_set("self_contained_target") {
31  sources = [
32    "self_contained_target_header1.h",
33    "self_contained_target_header2.cc",
34    "self_contained_target_header2.h",
35  ]
36}
37
38rs_bindings_from_cc("target_depending_on_another_rs_api") {
39  # This is the target that the bindings are for / call into.
40  bindings_target = ":target_depending_on_another"
41
42  # Lists public headers from `sources` of `target_depending_on_another`.
43  #
44  # TODO(crbug.com/40215214): Is there something we can do (a convention?) to
45  # avoid this duplication/repetition?
46  public_headers = [ "target_depending_on_another.h" ]
47
48  # Parallels `public_deps` of `target_depending_on_another`
49  #
50  # TODO(crbug.com/40215214): Is there something we can do (a convention?) to
51  # avoid this duplication/repetition?
52  deps = [ ":self_contained_target_rs_api" ]
53}
54
55source_set("target_depending_on_another") {
56  sources = [ "target_depending_on_another.h" ]
57  public_deps = [ ":self_contained_target" ]
58}
59