1"""Function for preserving `select` entries for Cargo cfg expressions which did 2not match any enabled target triple / Bazel platform. 3 4For example we might generate: 5 6 rust_library( 7 ... 8 deps = [ 9 "//common:unconditional_dep", 10 ] + selects.with_unmapped({ 11 "@rules_rust//rust/platform:x86_64-pc-windows-msvc": [ 12 "//third-party/rust:windows-sys", # cfg(windows) 13 ], 14 "@rules_rust//rust/platform:x86_64-unknown-linux-gnu": [ 15 "//third-party/rust:libc", # cfg(any(unix, target_os = "wasi")) 16 ], 17 "//conditions:default": [], 18 selects.NO_MATCHING_PLATFORM_TRIPLES: [ 19 "//third-party/rust:hermit-abi", # cfg(target_os = "hermit") 20 ], 21 }) 22 ) 23""" 24 25_SENTINEL = struct() 26 27def _with_unmapped(configurations): 28 configurations.pop(_SENTINEL) 29 return select(configurations) 30 31selects = struct( 32 with_unmapped = _with_unmapped, 33 NO_MATCHING_PLATFORM_TRIPLES = _SENTINEL, 34) 35