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