BUILD.gn 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. # Copyright 2021 The Chromium Authors. All rights reserved.
  2. # Use of this source code is governed by a BSD-style license that can be
  3. # found in the LICENSE file.
  4. import("//build/config/rust.gni")
  5. import("//build/rust/rust_unit_tests_group.gni")
  6. group("tests") {
  7. # Build some minimal binaries to exercise the Rust toolchain
  8. # only if that toolchain is enabled in gn args.
  9. testonly = true
  10. deps = [ ":deps" ]
  11. if (can_build_rust_unit_tests) {
  12. deps += [ ":build_rust_tests" ]
  13. }
  14. }
  15. group("deps") {
  16. testonly = true
  17. # These should build with or without Rust, in different modes
  18. deps = [
  19. "test_mixed_component:test_mixed_component_demo",
  20. "test_mixed_executable",
  21. "test_mixed_testonly_executable",
  22. "test_variable_static_library:test_variable_static_library_demo",
  23. ]
  24. # All the rest require Rust.
  25. if (toolchain_has_rust) {
  26. deps += [
  27. "test_cpp_including_rust",
  28. "test_mixed_static_library",
  29. "test_rlib_crate:target1",
  30. "test_rlib_crate:target2",
  31. "test_rust_static_library",
  32. "test_serde_json_lenient",
  33. ]
  34. if (rustc_can_link) {
  35. deps += [
  36. "bindgen_test",
  37. "test_mixed_shared_library",
  38. "test_rust_shared_library",
  39. ]
  40. }
  41. if (can_build_rust_unit_tests) {
  42. deps += [
  43. "bindgen_test:bindgen_test_lib_unittests",
  44. "test_cpp_including_rust:test_cpp_including_rust_unittests",
  45. "test_mixed_component:test_mixed_component_rs_unittests",
  46. "test_mixed_static_library:test_mixed_static_library_rs_unittests",
  47. "test_rlib_crate:test_rlib_crate_target1_unittests",
  48. "test_rlib_crate:test_rlib_crate_target2_unittests",
  49. "test_rust_exe:test_rust_exe_unittests",
  50. "test_rust_static_library:test_rust_static_library_unittests",
  51. "test_rust_static_library_non_standard_arrangement:foo_tests",
  52. "test_rust_unittests",
  53. "test_variable_static_library:test_variable_static_library_rs_unittests",
  54. # TODO(https://crbug.com/1329611): Enable the additional target below
  55. # once `rs_bindings_from_cc` is distributed via `gclient sync`. In the
  56. # meantime see the instructions in
  57. # `//build/rust/run_rs_bindings_from_cc.py`.
  58. #"test_rs_bindings_from_cc:test_rs_bindings_from_cc_unittests",
  59. ]
  60. # TODO(crbug.com/1297592): The bot isolate does not end up including any
  61. # .so files so the tests fail:
  62. #
  63. # error while loading shared libraries: libtest_mixed_shared_library.so:
  64. # cannot open shared object file: No such file or directory
  65. if (false) {
  66. deps += [
  67. "test_mixed_shared_library:test_mixed_shared_library_rs_unittests",
  68. "test_rust_shared_library:test_rust_shared_library_unittests",
  69. ]
  70. }
  71. }
  72. if (rustc_can_link) {
  73. deps += [
  74. "test_bin_crate",
  75. "test_rlib_crate:test_rlib_crate_associated_bin",
  76. "test_rust_exe",
  77. "test_rust_multiple_dep_versions_exe",
  78. "test_simple_rust_exe",
  79. "//third_party/rust/bindgen/v0_59:bindgen",
  80. # TODO(https://crbug.com/1329611): Enable the additional target below
  81. # once `rs_bindings_from_cc` is distributed via `gclient sync`. In the
  82. # meantime see the instructions in
  83. # `//build/rust/run_rs_bindings_from_cc.py`.
  84. #"test_rs_bindings_from_cc:test_rs_bindings_from_cc",
  85. ]
  86. }
  87. }
  88. }
  89. if (can_build_rust_unit_tests) {
  90. # A group covering all native Rust unit tests under //build/rust directory.
  91. rust_unit_tests_group("build_rust_tests") {
  92. deps = [ ":deps" ]
  93. }
  94. }