1*d4726bddSHONG Yifanload("@no_std_crate_index//:defs.bzl", "aliases", "all_crate_deps") 2*d4726bddSHONG Yifanload("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") 3*d4726bddSHONG Yifanload( 4*d4726bddSHONG Yifan "@rules_rust//rust:defs.bzl", 5*d4726bddSHONG Yifan "rust_binary", 6*d4726bddSHONG Yifan "rust_library", 7*d4726bddSHONG Yifan "rust_shared_library", 8*d4726bddSHONG Yifan) 9*d4726bddSHONG Yifan 10*d4726bddSHONG Yifanrust_shared_library( 11*d4726bddSHONG Yifan name = "lib", 12*d4726bddSHONG Yifan srcs = [ 13*d4726bddSHONG Yifan "lib.rs", 14*d4726bddSHONG Yifan "no_std.rs", 15*d4726bddSHONG Yifan ], 16*d4726bddSHONG Yifan crate_features = select({ 17*d4726bddSHONG Yifan "@rules_rust//:is_no_std": [], 18*d4726bddSHONG Yifan "//conditions:default": ["std"], 19*d4726bddSHONG Yifan }), 20*d4726bddSHONG Yifan edition = "2021", 21*d4726bddSHONG Yifan deps = ["custom_alloc"], 22*d4726bddSHONG Yifan) 23*d4726bddSHONG Yifan 24*d4726bddSHONG Yifanrust_library( 25*d4726bddSHONG Yifan name = "custom_alloc", 26*d4726bddSHONG Yifan srcs = ["alloc.rs"], 27*d4726bddSHONG Yifan aliases = aliases(), 28*d4726bddSHONG Yifan deps = all_crate_deps(normal = True), 29*d4726bddSHONG Yifan) 30*d4726bddSHONG Yifan 31*d4726bddSHONG Yifancc_library( 32*d4726bddSHONG Yifan name = "nostartfiles", 33*d4726bddSHONG Yifan linkopts = ["-nostartfiles"], 34*d4726bddSHONG Yifan) 35*d4726bddSHONG Yifan 36*d4726bddSHONG Yifanrust_binary( 37*d4726bddSHONG Yifan name = "main", 38*d4726bddSHONG Yifan srcs = ["main.rs"], 39*d4726bddSHONG Yifan aliases = aliases(), 40*d4726bddSHONG Yifan deps = all_crate_deps(normal = True) + [":nostartfiles"], 41*d4726bddSHONG Yifan) 42*d4726bddSHONG Yifan 43*d4726bddSHONG Yifancc_test( 44*d4726bddSHONG Yifan name = "no_std_cc_test", 45*d4726bddSHONG Yifan srcs = ["main.c"], 46*d4726bddSHONG Yifan deps = [":lib"], 47*d4726bddSHONG Yifan) 48