fork/rules_rust
git clone https://git.julia.blue/fork/rules_rust
1b451c30
0.8.1
1"""Definitions for support config settings and platform definitions""" 2 3load ( "@bazel_skylib//lib:selects.bzl" , "selects" ) 4load ( 5":triple_mappings.bzl" , 6"SUPPORTED_PLATFORM_TRIPLES" , 7"cpu_arch_to_constraints" , 8"system_to_constraints" , 9"triple_to_constraint_set" , 10) 11 12_SUPPORTED_CPU_ARCH = [ 13"aarch64" , 14"arm" , 15"armv7" , 16"i686" , 17"powerpc" , 18"s390x" , 19"x86_64" , 20"riscv32" , 21] 22 23_SUPPORTED_SYSTEMS = [ 24"android" , 25"darwin" , 26"freebsd" , 27"ios" , 28"linux" , 29"windows" , 30] 31 32# buildifier: disable=unnamed-macro 33def declare_config_settings (): 34"""Helper function for declaring `config_setting`s""" 35for cpu_arch in _SUPPORTED_CPU_ARCH : 36native . config_setting ( 37name = cpu_arch , 38constraint_values = cpu_arch_to_constraints ( cpu_arch ), 39) 40 41for system in _SUPPORTED_SYSTEMS : 42native . config_setting ( 43name = system , 44constraint_values = system_to_constraints ( system ), 45) 46 47# Add alias for OSX to "darwin" to match what users will be expecting. 48native . alias ( 49name = "osx" , 50actual = ":darwin" , 51) 52 53# Add alias for OSX to "macos" to be consistent with the long-term 54# direction of `@platforms` in using the OS's modern name. 55native . alias ( 56name = "macos" , 57actual = ":darwin" , 58) 59 60all_supported_triples = SUPPORTED_PLATFORM_TRIPLES 61for triple in all_supported_triples : 62native . config_setting ( 63name = triple , 64constraint_values = triple_to_constraint_set ( triple ), 65) 66 67native . platform ( 68name = "wasm" , 69constraint_values = [ 70str ( Label ( "//rust/platform/cpu:wasm32" )), 71str ( Label ( "//rust/platform/os:unknown" )), 72], 73) 74 75native . platform ( 76name = "wasi" , 77constraint_values = [ 78str ( Label ( "//rust/platform/cpu:wasm32" )), 79str ( Label ( "//rust/platform/os:wasi" )), 80], 81) 82 83selects . config_setting_group ( 84name = "unix" , 85match_any = [ 86":android" , 87":darwin" , 88":freebsd" , 89":linux" , 90], 91)