1load("@rules_cc//cc:defs.bzl", "cc_library") 2load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library", "rust_proc_macro") 3 4rust_library( 5 name = "cxx", 6 srcs = glob(["src/**/*.rs"]), 7 crate_features = [ 8 "alloc", 9 "std", 10 ], 11 edition = "2021", 12 proc_macro_deps = [ 13 ":cxxbridge-macro", 14 ], 15 visibility = ["//visibility:public"], 16 deps = [":core-lib"], 17) 18 19alias( 20 name = "codegen", 21 actual = ":cxxbridge", 22 visibility = ["//visibility:public"], 23) 24 25rust_binary( 26 name = "cxxbridge", 27 srcs = glob(["gen/cmd/src/**/*.rs"]), 28 data = ["gen/cmd/src/gen/include/cxx.h"], 29 edition = "2021", 30 deps = [ 31 "//third-party:clap", 32 "//third-party:codespan-reporting", 33 "//third-party:proc-macro2", 34 "//third-party:quote", 35 "//third-party:syn", 36 ], 37) 38 39cc_library( 40 name = "core", 41 hdrs = ["include/cxx.h"], 42 include_prefix = "rust", 43 strip_include_prefix = "include", 44 visibility = ["//visibility:public"], 45) 46 47cc_library( 48 name = "core-lib", 49 srcs = ["src/cxx.cc"], 50 hdrs = ["include/cxx.h"], 51) 52 53rust_proc_macro( 54 name = "cxxbridge-macro", 55 srcs = glob(["macro/src/**/*.rs"]), 56 edition = "2021", 57 deps = [ 58 "//third-party:proc-macro2", 59 "//third-party:quote", 60 "//third-party:syn", 61 ], 62) 63 64rust_library( 65 name = "cxx-build", 66 srcs = glob(["gen/build/src/**/*.rs"]), 67 data = ["gen/build/src/gen/include/cxx.h"], 68 edition = "2021", 69 deps = [ 70 "//third-party:cc", 71 "//third-party:codespan-reporting", 72 "//third-party:once_cell", 73 "//third-party:proc-macro2", 74 "//third-party:quote", 75 "//third-party:scratch", 76 "//third-party:syn", 77 ], 78) 79 80rust_library( 81 name = "cxx-gen", 82 srcs = glob(["gen/lib/src/**/*.rs"]), 83 data = ["gen/lib/src/gen/include/cxx.h"], 84 edition = "2021", 85 visibility = ["//visibility:public"], 86 deps = [ 87 "//third-party:cc", 88 "//third-party:codespan-reporting", 89 "//third-party:proc-macro2", 90 "//third-party:quote", 91 "//third-party:syn", 92 ], 93) 94