1# Copyright 2014 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( 16 "//go/private:context.bzl", 17 "go_context", 18) 19load( 20 "//go/private:go_toolchain.bzl", 21 "GO_TOOLCHAIN", 22) 23 24def _go_info_impl(ctx): 25 go = go_context(ctx) 26 report = go.declare_file(go, ext = ".txt") 27 args = go.builder_args(go) 28 args.add("-out", report) 29 go.actions.run( 30 inputs = go.sdk_files, 31 outputs = [report], 32 mnemonic = "GoInfo", 33 executable = ctx.executable._go_info, 34 arguments = [args], 35 ) 36 return [DefaultInfo( 37 files = depset([report]), 38 runfiles = ctx.runfiles([report]), 39 )] 40 41_go_info = rule( 42 implementation = _go_info_impl, 43 attrs = { 44 "_go_info": attr.label( 45 executable = True, 46 cfg = "exec", 47 default = "//go/tools/builders:info", 48 ), 49 "_go_context_data": attr.label( 50 default = "//:go_context_data", 51 ), 52 }, 53 toolchains = [GO_TOOLCHAIN], 54) 55 56def go_info(): 57 _go_info( 58 name = "go_info", 59 visibility = ["//visibility:public"], 60 ) 61