fork/rules_rust
git clone https://git.julia.blue/fork/rules_rust
c3581a57
patching
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"riscv64" , 22] 23 24_SUPPORTED_SYSTEMS = [ 25"android" , 26"darwin" , 27"freebsd" , 28"ios" , 29"linux" , 30"windows" , 31"nto" , 32] 33 34# buildifier: disable=unnamed-macro 35def declare_config_settings (): 36"""Helper function for declaring `config_setting`s""" 37for cpu_arch in _SUPPORTED_CPU_ARCH : 38native . config_setting ( 39name = cpu_arch , 40constraint_values = cpu_arch_to_constraints ( cpu_arch ), 41) 42 43for system in _SUPPORTED_SYSTEMS : 44native . config_setting ( 45name = system , 46constraint_values = system_to_constraints ( system ), 47) 48 49# Add alias for OSX to "darwin" to match what users will be expecting. 50native . alias ( 51name = "osx" , 52actual = ":darwin" , 53) 54 55# Add alias for OSX to "macos" to be consistent with the long-term 56# direction of `@platforms` in using the OS's modern name. 57native . alias ( 58name = "macos" , 59actual = ":darwin" , 60) 61 62all_supported_triples = SUPPORTED_PLATFORM_TRIPLES 63for triple in all_supported_triples : 64native . config_setting ( 65name = triple , 66constraint_values = triple_to_constraint_set ( triple ), 67) 68 69native . platform ( 70name = "wasm" , 71constraint_values = [ 72"@platforms//cpu:wasm32" , 73str ( Label ( "//rust/platform/os:unknown" )), 74], 75) 76 77native . platform ( 78name = "wasi" , 79constraint_values = [ 80"@platforms//cpu:wasm32" , 81"@platforms//os:wasi" , 82], 83) 84 85selects . config_setting_group ( 86name = "unix" , 87match_any = [ 88":android" , 89":darwin" , 90":freebsd" , 91":linux" , 92":nto" , 93], 94)