fork/rules_rust
git clone https://git.julia.blue/fork/rules_rust
bd64711f
rust-analyzer
1load ( "@rules_cc//cc:defs.bzl" , "cc_binary" ) 2load ( "//rust:defs.bzl" , "rust_library" , "rust_proc_macro" , "rust_test" ) 3 4# buildifier: disable=bzl-visibility 5load ( "//rust/private:transitions.bzl" , "alias_with_import_macro_bootstrapping_mode" ) 6 7alias_with_import_macro_bootstrapping_mode ( 8name = "import_macro" , 9actual = ":import_macro_impl" , 10) 11 12rust_proc_macro ( 13name = "import_macro_impl" , 14srcs = [ 15"import.rs" , 16], 17crate_name = "import" , 18edition = "2018" , 19deps = [ 20":import_internal" , 21"//util/import/3rdparty/crates:syn" , 22], 23) 24 25rust_library ( 26name = "import_internal" , 27srcs = [ 28"import_internal.rs" , 29], 30edition = "2018" , 31deps = [ 32"//util/import/3rdparty/crates:aho-corasick" , 33"//util/import/3rdparty/crates:lazy_static" , 34"//util/import/3rdparty/crates:proc-macro2" , 35"//util/import/3rdparty/crates:quote" , 36"//util/import/3rdparty/crates:syn" , 37"//util/label" , 38], 39) 40 41rust_test ( 42name = "import_internal_test" , 43crate = ":import_internal" , 44edition = "2018" , 45# TODO: https://github.com/bazelbuild/rules_rust/issues/1672 46tags = [ "manual" ], 47deps = [ 48"//util/import/3rdparty/crates:quickcheck" , 49], 50) 51 52alias ( 53name = "import" , 54actual = select ({ 55":use_fake_import_macro" : ":fake_import_macro_impl" , 56"//conditions:default" : ":import_macro_label" , 57}), 58visibility = [ "//visibility:public" ], 59) 60 61# This is there to cut the loading-time dependency on the import macro dependencies 62# (so users who don't use the macro don't need to add those deps to their WORKSPACE 63# file). Bazel in the loading phase doesn't "see" through `label_flag`. 64label_flag ( 65name = "import_macro_label" , 66build_setting_default = "import_macro" , 67) 68 69config_setting ( 70name = "use_fake_import_macro" , 71flag_values = { 72"@rules_rust//rust/settings:use_real_import_macro" : "False" , 73}, 74) 75 76cc_binary ( 77name = "fake_import_macro_impl" , 78srcs = [ "fake_import_macro_impl.cc" ], 79)