1*d4726bddSHONG Yifanload("@bazel_skylib//:bzl_library.bzl", "bzl_library") 2*d4726bddSHONG Yifanload("@bazel_skylib//rules:common_settings.bzl", "bool_flag", "string_flag") 3*d4726bddSHONG Yifanload("//rust/private:unpretty.bzl", "rust_unpretty_flag") 4*d4726bddSHONG Yifanload(":incompatible.bzl", "incompatible_flag") 5*d4726bddSHONG Yifan 6*d4726bddSHONG Yifanpackage(default_visibility = ["//visibility:public"]) 7*d4726bddSHONG Yifan 8*d4726bddSHONG Yifanbzl_library( 9*d4726bddSHONG Yifan name = "bzl_lib", 10*d4726bddSHONG Yifan srcs = glob(["**/*.bzl"]), 11*d4726bddSHONG Yifan) 12*d4726bddSHONG Yifan 13*d4726bddSHONG Yifanrust_unpretty_flag( 14*d4726bddSHONG Yifan name = "unpretty", 15*d4726bddSHONG Yifan build_setting_default = [ 16*d4726bddSHONG Yifan "ast-tree,expanded", 17*d4726bddSHONG Yifan "ast-tree", 18*d4726bddSHONG Yifan "expanded,hygiene", 19*d4726bddSHONG Yifan "expanded,identified", 20*d4726bddSHONG Yifan "expanded", 21*d4726bddSHONG Yifan "hir-tree", 22*d4726bddSHONG Yifan "hir,identified", 23*d4726bddSHONG Yifan "hir,typed", 24*d4726bddSHONG Yifan "hir", 25*d4726bddSHONG Yifan "identified", 26*d4726bddSHONG Yifan "mir-cfg", 27*d4726bddSHONG Yifan "mir", 28*d4726bddSHONG Yifan "normal", 29*d4726bddSHONG Yifan ], 30*d4726bddSHONG Yifan) 31*d4726bddSHONG Yifan 32*d4726bddSHONG Yifan# A flag controlling whether to rename first-party crates such that their names 33*d4726bddSHONG Yifan# encode the Bazel package and target name, instead of just the target name. 34*d4726bddSHONG Yifan# 35*d4726bddSHONG Yifan# First-party vs. third-party crates are identified using the value of 36*d4726bddSHONG Yifan# //settings:third_party_dir. 37*d4726bddSHONG Yifanbool_flag( 38*d4726bddSHONG Yifan name = "rename_first_party_crates", 39*d4726bddSHONG Yifan build_setting_default = False, 40*d4726bddSHONG Yifan) 41*d4726bddSHONG Yifan 42*d4726bddSHONG Yifan# A flag specifying the location of vendored third-party rust crates within this 43*d4726bddSHONG Yifan# repository that must not be renamed when `rename_first_party_crates` is enabled. 44*d4726bddSHONG Yifan# 45*d4726bddSHONG Yifan# Must be specified as a Bazel package, e.g. "//some/location/in/repo". 46*d4726bddSHONG Yifanstring_flag( 47*d4726bddSHONG Yifan name = "third_party_dir", 48*d4726bddSHONG Yifan build_setting_default = "//third_party/rust", 49*d4726bddSHONG Yifan) 50*d4726bddSHONG Yifan 51*d4726bddSHONG Yifan# A flag to control whether rust_library and rust_binary targets should 52*d4726bddSHONG Yifan# implicitly depend on the *real* import macro, or on a no-op target. 53*d4726bddSHONG Yifanbool_flag( 54*d4726bddSHONG Yifan name = "use_real_import_macro", 55*d4726bddSHONG Yifan build_setting_default = False, 56*d4726bddSHONG Yifan) 57*d4726bddSHONG Yifan 58*d4726bddSHONG Yifan# When set, this flag causes rustc to emit .rmeta files and use them for rlib -> rlib dependencies. 59*d4726bddSHONG Yifan# While this involves one extra (short) rustc invocation to build the rmeta file, 60*d4726bddSHONG Yifan# it allows library dependencies to be unlocked much sooner, increasing parallelism during compilation. 61*d4726bddSHONG Yifanbool_flag( 62*d4726bddSHONG Yifan name = "pipelined_compilation", 63*d4726bddSHONG Yifan build_setting_default = False, 64*d4726bddSHONG Yifan) 65*d4726bddSHONG Yifan 66*d4726bddSHONG Yifan# A flag to control whether to link rust_binary and rust_test targets using 67*d4726bddSHONG Yifan# cc_common.link instead of rustc. 68*d4726bddSHONG Yifanbool_flag( 69*d4726bddSHONG Yifan name = "experimental_use_cc_common_link", 70*d4726bddSHONG Yifan build_setting_default = False, 71*d4726bddSHONG Yifan) 72*d4726bddSHONG Yifan 73*d4726bddSHONG Yifan# A flag to indicate that a global allocator is in use when using --@rules_rust//rust/settings:experimental_use_cc_common_link 74*d4726bddSHONG Yifan# Users need to specify this flag because rustc generates different set of symbols at link time when a global allocator is in use. 75*d4726bddSHONG Yifan# When the linking is not done by rustc, the `rust_toolchain` itself provides the appropriate set of symbols. 76*d4726bddSHONG Yifanbool_flag( 77*d4726bddSHONG Yifan name = "experimental_use_global_allocator", 78*d4726bddSHONG Yifan build_setting_default = False, 79*d4726bddSHONG Yifan) 80*d4726bddSHONG Yifan 81*d4726bddSHONG Yifan# A flag to have coverage tooling added as `coverage_common.instrumented_files_info.metadata_files` instead of 82*d4726bddSHONG Yifan# reporting tools like `llvm-cov` and `llvm-profdata` as runfiles to each test. 83*d4726bddSHONG Yifanbool_flag( 84*d4726bddSHONG Yifan name = "experimental_use_coverage_metadata_files", 85*d4726bddSHONG Yifan build_setting_default = False, 86*d4726bddSHONG Yifan) 87*d4726bddSHONG Yifan 88*d4726bddSHONG Yifan# A flag to set rustc --sysroot flag to the sysroot generated by rust_toolchain 89*d4726bddSHONG Yifanincompatible_flag( 90*d4726bddSHONG Yifan name = "experimental_toolchain_generated_sysroot", 91*d4726bddSHONG Yifan build_setting_default = True, 92*d4726bddSHONG Yifan issue = "https://github.com/bazelbuild/rules_rust/issues/2039", 93*d4726bddSHONG Yifan) 94*d4726bddSHONG Yifan 95*d4726bddSHONG Yifan# A flag to control whether to link libstd dynamically. 96*d4726bddSHONG Yifanbool_flag( 97*d4726bddSHONG Yifan name = "experimental_link_std_dylib", 98*d4726bddSHONG Yifan build_setting_default = False, 99*d4726bddSHONG Yifan) 100*d4726bddSHONG Yifan 101*d4726bddSHONG Yifan# A flag to remove the SYSROOT environment variable from `Rustc` actions. 102*d4726bddSHONG Yifanincompatible_flag( 103*d4726bddSHONG Yifan name = "incompatible_no_rustc_sysroot_env", 104*d4726bddSHONG Yifan build_setting_default = True, 105*d4726bddSHONG Yifan issue = "https://github.com/bazelbuild/rules_rust/issues/2429", 106*d4726bddSHONG Yifan) 107*d4726bddSHONG Yifan 108*d4726bddSHONG Yifan# A flag to control whether the shell path from a shell toolchain (`@bazel_tools//tools/sh:toolchain_type`) 109*d4726bddSHONG Yifan# is embedded into the bootstrap process wrapper for the `.sh` file. 110*d4726bddSHONG Yifanbool_flag( 111*d4726bddSHONG Yifan name = "experimental_use_sh_toolchain_for_bootstrap_process_wrapper", 112*d4726bddSHONG Yifan build_setting_default = False, 113*d4726bddSHONG Yifan) 114