github.com/bazelbuild/rules_go@v0.47.2-0.20240515105122-e7ddb9ea474e/go/platform/list.bzl (about) 1 # Copyright 2017 The Bazel Authors. All rights reserved. 2 # 3 # Licensed under the Apache License, Version 2.0 (the "License"); 4 # you may not use this file except in compliance with the License. 5 # You may obtain a copy of the License at 6 # 7 # http://www.apache.org/licenses/LICENSE-2.0 8 # 9 # Unless required by applicable law or agreed to in writing, software 10 # distributed under the License is distributed on an "AS IS" BASIS, 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 # See the License for the specific language governing permissions and 13 # limitations under the License. 14 15 load( 16 "//go/private:platforms.bzl", 17 _GOARCH = "GOARCH_CONSTRAINTS", 18 _GOOS = "GOOS_CONSTRAINTS", 19 _GOOS_GOARCH = "GOOS_GOARCH", 20 _MSAN_GOOS_GOARCH = "MSAN_GOOS_GOARCH", 21 _RACE_GOOS_GOARCH = "RACE_GOOS_GOARCH", 22 ) 23 24 GOOS_GOARCH = _GOOS_GOARCH 25 GOOS = _GOOS 26 GOARCH = _GOARCH 27 RACE_GOOS_GOARCH = _RACE_GOOS_GOARCH 28 MSAN_GOOS_GOARCH = _MSAN_GOOS_GOARCH 29 30 def declare_config_settings(): 31 """Generates config_setting targets. 32 33 declare_config_settings declares a config_setting target for each goos, 34 goarch, and valid goos_goarch pair. These targets may be used in select 35 expressions. Each target refers to a corresponding constraint_value in 36 //go/toolchain. 37 """ 38 for goos in GOOS: 39 native.config_setting( 40 name = goos, 41 constraint_values = [Label("//go/toolchain:" + goos)], 42 visibility = ["//visibility:public"], 43 ) 44 for goarch in GOARCH: 45 native.config_setting( 46 name = goarch, 47 constraint_values = [Label("//go/toolchain:" + goarch)], 48 visibility = ["//visibility:public"], 49 ) 50 for goos, goarch in GOOS_GOARCH: 51 native.config_setting( 52 name = goos + "_" + goarch, 53 constraint_values = [ 54 Label("//go/toolchain:" + goos), 55 Label("//go/toolchain:" + goarch), 56 ], 57 visibility = ["//visibility:public"], 58 ) 59 60 # Setting that determines whether cgo is enabled. 61 # This is experimental and may be changed or removed when we migrate 62 # to build settings. 63 native.config_setting( 64 name = "internal_cgo_off", 65 constraint_values = [Label("//go/toolchain:cgo_off")], 66 visibility = [Label("//:__pkg__")], 67 )