File: BUILD.gn

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (139 lines) | stat: -rw-r--r-- 5,616 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# Copyright 2021 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/config/rust.gni")
import("//build/rust/rust_unit_tests_group.gni")

# Build some minimal binaries to exercise the Rust toolchain
# only if that toolchain is enabled in gn args.
group("tests") {
  testonly = true

  deps = [ ":deps" ]
  if (can_build_rust_unit_tests) {
    deps += [ ":build_rust_tests" ]
  }
}

group("deps") {
  testonly = true
  deps = []

  # All the rest require Rust.
  if (toolchain_has_rust) {
    deps += [
      "//build/rust/tests/bindgen_cpp_test_with_cpp_linkage",
      "//build/rust/tests/bindgen_static_fns_test",
      "//build/rust/tests/bindgen_test",
      "//build/rust/tests/test_aliased_deps",
      "//build/rust/tests/test_aliased_deps:test_aliased_deps_exe",
      "//build/rust/tests/test_bin_crate",
      "//build/rust/tests/test_rlib_crate:target1",
      "//build/rust/tests/test_rlib_crate:target2",
      "//build/rust/tests/test_rlib_crate:test_rlib_crate_associated_bin",
      "//build/rust/tests/test_rlib_crate_testonly:testonly_target",
      "//build/rust/tests/test_rust_exe_2",
      "//build/rust/tests/test_rust_metadata:test_rust_metadata_cc_exe",
      "//build/rust/tests/test_rust_metadata:test_rust_metadata_exe",
      "//build/rust/tests/test_rust_multiple_dep_versions_exe",
      "//build/rust/tests/test_simple_rust_exe",

      # TODO(crbug.com/40226863): Enable the additional target below
      # once `rs_bindings_from_cc` is distributed via `gclient sync`.  In the
      # meantime see the instructions in
      # `//build/rust/run_rs_bindings_from_cc.py`.
      #"test_rs_bindings_from_cc:test_rs_bindings_from_cc",
    ]

    if (target_cpu == "x86") {
      # Some `target_os`s do not support 32-bit platforms anymore.  The
      # selection below is _loosely_ based on `is_valid_x86_target` from
      # the top-level `//BUILD.gn`.
      if (is_win || is_android) {
        deps += [ "//build/rust/tests/test_build_rs_target_arch_x86" ]
      }
    }

    if (!(is_apple && is_official_build)) {
      # TODO: crbug.com/372055517 - Apple lld has an ordering dependency bug
      # when LTO is enabled, and this particular build target runs into that.
      deps += [ "//build/rust/tests/bindgen_cpp_test" ]
    }

    if (enable_chromium_prelude) {
      deps += [ "//build/rust/chromium_prelude:import_test" ]
    }
    if (enable_rust_cxx) {
      deps += [
        "//build/rust/tests/test_cpp_including_rust",
        "//build/rust/tests/test_rust_calling_cpp",
        "//build/rust/tests/test_rust_exe",
        "//build/rust/tests/test_rust_static_library",
      ]
    }
    if (build_with_chromium) {
      # This tests integration with a 3p library that downstream projects
      # don't need to have.
      deps += [ "//build/rust/tests/test_serde_json_lenient" ]
    }

    if (can_build_rust_unit_tests) {
      deps += [
        "//build/rust/tests/bindgen_static_fns_test:bindgen_static_fns_test_lib_unittests",
        "//build/rust/tests/bindgen_test:bindgen_test_lib_unittests",
        "//build/rust/tests/test_aliased_deps:test_aliased_deps_unittests",
        "//build/rust/tests/test_rlib_crate:target1_test_rlib_crate_v0_2_unittests",
        "//build/rust/tests/test_rlib_crate:target2_test_rlib_crate_v0_2_unittests",
        "//build/rust/tests/test_rust_metadata:test_rust_metadata_unittests",
        "//build/rust/tests/test_rust_multiple_dep_versions_exe/v1:test_lib_v1_unittests",
        "//build/rust/tests/test_rust_multiple_dep_versions_exe/v2:test_lib_v2_unittests",
        "//build/rust/tests/test_rust_static_library_non_standard_arrangement:foo_tests",

        # TODO(crbug.com/40226863): Enable the additional target below
        # once `rs_bindings_from_cc` is distributed via `gclient sync`.  In the
        # meantime see the instructions in
        # `//build/rust/run_rs_bindings_from_cc.py`.
        #"test_rs_bindings_from_cc:test_rs_bindings_from_cc_unittests",
      ]

      if (enable_rust_cxx) {
        deps += [
          "//build/rust/tests/test_cpp_including_rust:test_cpp_including_rust_unittests",
          "//build/rust/tests/test_rust_exe:test_rust_exe_unittests",
          "//build/rust/tests/test_rust_static_library:test_rust_static_library_unittests",
          "//build/rust/tests/test_rust_unittests",
        ]
      }
    }

    # Dylibs should only be built in component builds. We turn on flags which
    # are incompatible with shared library compilation in non-component builds
    # (such as code coverage https://crbug.com/1457533).
    if (is_component_build && enable_rust_cxx) {
      deps += [ "//build/rust/tests/test_rust_shared_library" ]
      if (can_build_rust_unit_tests) {
        deps += [ "//build/rust/tests/test_cpp_including_rust:test_cpp_including_rust_dylib_unittests" ]

        # TODO(crbug.com/40266882): The shared library unittest EXE ends up
        # requiring the DLL to run, even though it does not use the DLL.
        if (!is_win && !is_mac) {
          deps += [ "//build/rust/tests/test_rust_shared_library:test_rust_shared_library_unittests" ]
        }
      }
    }

    if (is_win) {
      deps += [ "//build/rust/tests/windows_sys_test" ]
      deps += [ "//build/rust/tests/test_control_flow_guard" ]
    }
  }
}

if (can_build_rust_unit_tests) {
  # Generates a script that will run all the native Rust unit tests, in order
  # to have them all part of a single test step on infra bots.
  rust_unit_tests_group("build_rust_tests") {
    deps = [ ":deps" ]
  }
}