blob: 041d1da49b2470263a7a8d7c06017ca62367f478 [file] [log] [blame]
Brian Silvermancc09f182022-03-09 15:40:20 -08001load("@rules_rust//rust:defs.bzl", "rust_doc", "rust_library", "rust_test")
2
3package(default_visibility = ["//ffi/rust_calling_c:__subpackages__"])
4
5rust_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
17rust_test(
18 name = "matrix_test",
19 crate = ":matrix",
20)
21
22rust_doc(
23 name = "matrix_doc",
24 crate = ":matrix",
25)
26
27## Do the same as above, but with a dynamic c library.
28
29rust_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
47rust_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
59rust_doc(
60 name = "matrix_dylib_doc",
61 crate = ":matrix_dynamically_linked",
62)