From 118f8225671726c065a23461c11b82b1465bbed9 Mon Sep 17 00:00:00 2001 From: Mikhail Mazurskiy Date: Sat, 4 Aug 2018 12:52:46 +0500 Subject: [PATCH] Update deprecated single_file -> allow_single_file attribute Also remove allow_files where it conflicts with allow_single_file (not allowed). Also remove both allow_files and allow_single_file in private attributes where executable is set to True (a file cannot be specified anyway - private attribute). --- extras/bindata.bzl | 4 +--- go/private/rules/builders.bzl | 14 -------------- go/private/rules/cgo.bzl | 3 +-- go/private/rules/info.bzl | 1 - go/private/rules/sdk.bzl | 2 +- go/private/tools/files_equal_test.bzl | 6 ++---- go/private/tools/gazelle.bzl | 6 ++---- proto/compiler.bzl | 13 ++++--------- proto/gogo.bzl | 2 +- tests/bazel_tests.bzl | 11 +++++------ .../examples/cgo/example_command/generate_test.bzl | 3 +-- 11 files changed, 18 insertions(+), 47 deletions(-) diff --git a/extras/bindata.bzl b/extras/bindata.bzl index 4ea2450223..41a1d69504 100644 --- a/extras/bindata.bzl +++ b/extras/bindata.bzl @@ -48,7 +48,7 @@ def _bindata_impl(ctx): inputs = ctx.files.srcs, outputs = [out], mnemonic = "GoBindata", - executable = ctx.file._bindata, + executable = ctx.executable._bindata, arguments = [arguments], ) return [ @@ -71,8 +71,6 @@ bindata = go_rule( "modtime": attr.bool(default = False), "extra_args": attr.string_list(), "_bindata": attr.label( - allow_files = True, - single_file = True, executable = True, cfg = "host", default = Label("@com_github_kevinburke_go_bindata//go-bindata:go-bindata"), diff --git a/go/private/rules/builders.bzl b/go/private/rules/builders.bzl index 2caa0c446b..12f603cb0e 100644 --- a/go/private/rules/builders.bzl +++ b/go/private/rules/builders.bzl @@ -42,50 +42,36 @@ builders = rule( _builders_impl, attrs = { "_asm": attr.label( - allow_files = True, - single_file = True, executable = True, cfg = "host", default = "//go/tools/builders:asm", ), "_compile": attr.label( - allow_files = True, - single_file = True, executable = True, cfg = "host", default = "//go/tools/builders:compile", ), "_pack": attr.label( - allow_files = True, - single_file = True, executable = True, cfg = "host", default = "//go/tools/builders:pack", ), "_link": attr.label( - allow_files = True, - single_file = True, executable = True, cfg = "host", default = "//go/tools/builders:link", ), "_cgo": attr.label( - allow_files = True, - single_file = True, executable = True, cfg = "host", default = "//go/tools/builders:cgo", ), "_test_generator": attr.label( - allow_files = True, - single_file = True, executable = True, cfg = "host", default = "//go/tools/builders:generate_test_main", ), "_cover": attr.label( - allow_files = True, - single_file = True, executable = True, cfg = "host", default = "//go/tools/builders:cover", diff --git a/go/private/rules/cgo.bzl b/go/private/rules/cgo.bzl index da6463d483..70a6ce316c 100644 --- a/go/private/rules/cgo.bzl +++ b/go/private/rules/cgo.bzl @@ -324,8 +324,7 @@ _cgo_import = go_rule( _cgo_import_impl, attrs = { "cgo_o": attr.label( - allow_files = True, - single_file = True, + allow_single_file = True, ), "sample_go_srcs": attr.label_list(allow_files = True), }, diff --git a/go/private/rules/info.bzl b/go/private/rules/info.bzl index f806f82fc2..e6f6c17e04 100644 --- a/go/private/rules/info.bzl +++ b/go/private/rules/info.bzl @@ -42,7 +42,6 @@ _go_info = go_rule( _go_info_impl, attrs = { "_go_info": attr.label( - single_file = True, executable = True, cfg = "host", default = "@io_bazel_rules_go//go/tools/builders:info", diff --git a/go/private/rules/sdk.bzl b/go/private/rules/sdk.bzl index 3995080c9d..16565624bb 100644 --- a/go/private/rules/sdk.bzl +++ b/go/private/rules/sdk.bzl @@ -27,7 +27,7 @@ def _go_sdk_impl(ctx): headers = ctx.files.headers, srcs = ctx.files.srcs, tools = ctx.files.tools, - go = ctx.file.go, + go = ctx.executable.go, )] go_sdk = rule( diff --git a/go/private/tools/files_equal_test.bzl b/go/private/tools/files_equal_test.bzl index d1e4a71fe4..503ae106b9 100644 --- a/go/private/tools/files_equal_test.bzl +++ b/go/private/tools/files_equal_test.bzl @@ -61,13 +61,11 @@ files_equal_test = rule( attrs = { "golden": attr.label( mandatory = True, - allow_files = True, - single_file = True, + allow_single_file = True, ), "actual": attr.label( mandatory = True, - allow_files = True, - single_file = True, + allow_single_file = True, ), "error_message": attr.string( default = "FILES DO NOT HAVE EQUAL CONTENTS", diff --git a/go/private/tools/gazelle.bzl b/go/private/tools/gazelle.bzl index 39700442cc..ace63161cb 100644 --- a/go/private/tools/gazelle.bzl +++ b/go/private/tools/gazelle.bzl @@ -47,12 +47,12 @@ def _gazelle_script_impl(ctx): if ctx.attr.build_tags: args += ["-build_tags", ",".join(ctx.attr.build_tags)] args += ctx.attr.args - script_content = _script_content.format(gazelle = ctx.file._gazelle.short_path, args = " ".join(args)) + script_content = _script_content.format(gazelle = ctx.executable._gazelle.short_path, args = " ".join(args)) script_file = go.declare_file(go, ext = ".bash") ctx.actions.write(output = script_file, is_executable = True, content = script_content) return struct( files = depset([script_file]), - runfiles = ctx.runfiles([ctx.file._gazelle]), + runfiles = ctx.runfiles([ctx.executable._gazelle]), ) _gazelle_script = go_rule( @@ -85,8 +85,6 @@ _gazelle_script = go_rule( "prefix": attr.string(), "_gazelle": attr.label( default = Label("@bazel_gazelle//cmd/gazelle"), - allow_files = True, - single_file = True, executable = True, cfg = "host", ), diff --git a/proto/compiler.bzl b/proto/compiler.bzl index 58d97e702a..15d5e1c0c6 100644 --- a/proto/compiler.bzl +++ b/proto/compiler.bzl @@ -98,9 +98,9 @@ def _go_proto_compiler_impl(ctx): compile = go_proto_compile, options = ctx.attr.options, suffix = ctx.attr.suffix, - go_protoc = ctx.file._go_protoc, - protoc = ctx.file._protoc, - plugin = ctx.file.plugin, + go_protoc = ctx.executable._go_protoc, + protoc = ctx.executable._protoc, + plugin = ctx.executable.plugin, valid_archive = ctx.attr.valid_archive, import_path_option = ctx.attr.import_path_option, ), @@ -117,22 +117,17 @@ go_proto_compiler = go_rule( "valid_archive": attr.bool(default = True), "import_path_option": attr.bool(default = True), "plugin": attr.label( - allow_files = True, - single_file = True, + allow_single_file = True, executable = True, cfg = "host", default = Label("@com_github_golang_protobuf//protoc-gen-go"), ), "_go_protoc": attr.label( - allow_files = True, - single_file = True, executable = True, cfg = "host", default = Label("@io_bazel_rules_go//go/tools/builders:go-protoc"), ), "_protoc": attr.label( - allow_files = True, - single_file = True, executable = True, cfg = "host", default = Label("@com_google_protobuf//:protoc"), diff --git a/proto/gogo.bzl b/proto/gogo.bzl index 41d3258629..237d9d5e46 100644 --- a/proto/gogo.bzl +++ b/proto/gogo.bzl @@ -34,6 +34,6 @@ proto_library( gogo_special_proto = repository_rule( _gogo_special_proto_impl, attrs = { - "proto": attr.label(single_file = True), + "proto": attr.label(allow_single_file = True), }, ) diff --git a/tests/bazel_tests.bzl b/tests/bazel_tests.bzl index 24b6128d27..3ad8b13a5e 100644 --- a/tests/bazel_tests.bzl +++ b/tests/bazel_tests.bzl @@ -233,8 +233,7 @@ _bazel_test_script = go_rule( ), "clean_build": attr.bool(default = False), "bazelrc": attr.label( - allow_files = True, - single_file = True, + allow_single_file = True, default = "@bazel_test//:standalone_bazelrc", ), "_settings": attr.label(default = Label("@bazel_test//:settings")), @@ -289,7 +288,7 @@ def _md5_sum_impl(ctx): inputs = ctx.files.srcs, outputs = [out], mnemonic = "GoMd5sum", - executable = ctx.file._md5sum, + executable = ctx.executable._md5sum, arguments = [arguments], ) return struct(files = depset([out])) @@ -299,9 +298,9 @@ md5_sum = go_rule( attrs = { "srcs": attr.label_list(allow_files = True), "_md5sum": attr.label( - allow_files = True, - single_file = True, - default = Label("@io_bazel_rules_go//go/tools/builders:md5sum"), + executable = True, + default = "@io_bazel_rules_go//go/tools/builders:md5sum", + cfg = "host", ), }, ) diff --git a/tests/legacy/examples/cgo/example_command/generate_test.bzl b/tests/legacy/examples/cgo/example_command/generate_test.bzl index 53ceee7ac1..c3c991dfbc 100644 --- a/tests/legacy/examples/cgo/example_command/generate_test.bzl +++ b/tests/legacy/examples/cgo/example_command/generate_test.bzl @@ -11,8 +11,7 @@ generate_script = rule( _generate_script_impl, attrs = { "binary": attr.label( - allow_files = True, - single_file = True, + allow_single_file = True, ), }, )