• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2018 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
15load("//go/private:providers.bzl", "GoStdLib")
16
17def _force_rebuild_transition_impl(settings, attr):
18    return {"//go/config:race": True}
19
20force_rebuild_transition = transition(
21    implementation = _force_rebuild_transition_impl,
22    inputs = ["//go/config:race"],
23    outputs = ["//go/config:race"],
24)
25
26def _stdlib_files_impl(ctx):
27    # When an outgoing transition (aka split transition) is used,
28    # ctx.attr._stdlib is a list of Target.
29    stdlib = ctx.attr._stdlib[0][GoStdLib]
30    libs = stdlib.libs
31    runfiles = ctx.runfiles(files = libs)
32    return [DefaultInfo(
33        files = depset(libs + [stdlib._list_json]),
34        runfiles = runfiles,
35    )]
36
37stdlib_files = rule(
38    implementation = _stdlib_files_impl,
39    attrs = {
40        "_stdlib": attr.label(
41            default = "@io_bazel_rules_go//:stdlib",
42            providers = [GoStdLib],
43            cfg = force_rebuild_transition,
44        ),
45        "_allowlist_function_transition": attr.label(
46            default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
47        ),
48    },
49)
50