1# Copyright 2016 The Bazel Go Rules 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 15load( 16 "//go/private:context.bzl", 17 "go_context", 18) 19load( 20 "//go/private:go_toolchain.bzl", 21 "GO_TOOLCHAIN", 22) 23load( 24 "//go/private:providers.bzl", 25 "GoConfigInfo", 26) 27load( 28 "//go/private/rules:transition.bzl", 29 "go_stdlib_transition", 30) 31 32def _stdlib_impl(ctx): 33 go = go_context(ctx) 34 source, library = go.toolchain.actions.stdlib(go) 35 return [source, library, source.stdlib] 36 37stdlib = rule( 38 implementation = _stdlib_impl, 39 cfg = go_stdlib_transition, 40 attrs = { 41 "cgo_context_data": attr.label(), 42 "_go_config": attr.label( 43 default = "//:go_config", 44 providers = [GoConfigInfo], 45 ), 46 "_allowlist_function_transition": attr.label( 47 default = "@bazel_tools//tools/allowlists/function_transition_allowlist", 48 ), 49 }, 50 doc = """stdlib builds the standard library for the target configuration 51or uses the precompiled standard library from the SDK if it is suitable.""", 52 toolchains = [GO_TOOLCHAIN], 53) 54