fork/rules_rust
git clone https://git.julia.blue/fork/rules_rust
9d344794
main
1load ( "@rules_cc//cc:defs.bzl" , "cc_import" , "cc_library" , "cc_test" ) 2load ( "@rules_rust//rust:defs.bzl" , "rust_binary" , "rust_static_library" ) 3 4rust_static_library ( 5name = "rust_lib" , 6srcs = [ "lib.rs" ], 7edition = "2021" , 8) 9 10cc_library ( 11name = "c_lib" , 12srcs = [ "lib.c" ], 13hdrs = [ "lib.h" ], 14deps = [ ":rust_lib" ], 15) 16 17# Tests that cc_shared_library correctly traverses into 18# `rust_static_library` when linking. 19cc_shared_library ( 20name = "shared" , 21deps = [ ":c_lib" ], 22) 23 24cc_test ( 25name = "test" , 26srcs = [ "main.c" ], 27dynamic_deps = [ ":shared" ], 28linkstatic = True , 29deps = [ ":c_lib" ], 30) 31 32NOT_WINDOWS = select ({ 33"@platforms//os:linux" : [], 34"@platforms//os:macos" : [], 35"//conditions:default" : [ "@platforms//:incompatible" ], 36}) 37 38cc_import ( 39name = "shared_import" , 40shared_library = ":shared" , 41target_compatible_with = NOT_WINDOWS , 42) 43 44rust_binary ( 45name = "linked_against_shared" , 46srcs = [ "linked_against_shared.rs" ], 47edition = "2018" , 48target_compatible_with = NOT_WINDOWS , 49deps = [ ":shared_import" ], 50) 51 52sh_test ( 53name = "runfiles_contains_shared" , 54srcs = [ "runfiles_contains_shared.sh" ], 55data = [ ":linked_against_shared" ], 56target_compatible_with = NOT_WINDOWS , 57)