Brian Silverman | cc09f18 | 2022-03-09 15:40:20 -0800 | [diff] [blame^] | 1 | load("@rules_rust//rust:defs.bzl", "rust_doc", "rust_library", "rust_test") |
| 2 | |
| 3 | package(default_visibility = ["//ffi/rust_calling_c:__subpackages__"]) |
| 4 | |
| 5 | rust_library( |
| 6 | name = "matrix", |
| 7 | srcs = [ |
| 8 | "src/ffi.rs", |
| 9 | "src/matrix.rs", |
| 10 | ], |
| 11 | deps = [ |
| 12 | "//ffi/rust_calling_c/c:native_matrix", |
| 13 | "@libc", |
| 14 | ], |
| 15 | ) |
| 16 | |
| 17 | rust_test( |
| 18 | name = "matrix_test", |
| 19 | crate = ":matrix", |
| 20 | ) |
| 21 | |
| 22 | rust_doc( |
| 23 | name = "matrix_doc", |
| 24 | crate = ":matrix", |
| 25 | ) |
| 26 | |
| 27 | ## Do the same as above, but with a dynamic c library. |
| 28 | |
| 29 | rust_library( |
| 30 | name = "matrix_dynamically_linked", |
| 31 | srcs = [ |
| 32 | "src/ffi.rs", |
| 33 | "src/matrix.rs", |
| 34 | ], |
| 35 | crate_root = "src/matrix.rs", |
| 36 | target_compatible_with = select({ |
| 37 | # TODO: Make this work on windows |
| 38 | "@platforms//os:windows": ["@platforms//:incompatible"], |
| 39 | "//conditions:default": [], |
| 40 | }), |
| 41 | deps = [ |
| 42 | "//ffi/rust_calling_c/c:native_matrix_so", |
| 43 | "@libc", |
| 44 | ], |
| 45 | ) |
| 46 | |
| 47 | rust_test( |
| 48 | name = "matrix_dylib_test", |
| 49 | crate = ":matrix_dynamically_linked", |
| 50 | target_compatible_with = select({ |
| 51 | # TODO: This test requires --incompatible_macos_set_install_name and Bazel 4.2.0+ |
| 52 | "@platforms//os:macos": ["@platforms//:incompatible"], |
| 53 | # TODO: Make this work on windows |
| 54 | "@platforms//os:windows": ["@platforms//:incompatible"], |
| 55 | "//conditions:default": [], |
| 56 | }), |
| 57 | ) |
| 58 | |
| 59 | rust_doc( |
| 60 | name = "matrix_dylib_doc", |
| 61 | crate = ":matrix_dynamically_linked", |
| 62 | ) |