Skip to content

Commit

Permalink
Deprecate legacy action APIs
Browse files Browse the repository at this point in the history
The asm, compile, cover, and pack actions on go_context are no longer
used by rules_go itself and not covered by any tests. Unless there is
a very strong use case for them in our user base and someone steps up
to contribute test coverage, these are marked for removal in version
0.36.0.

This commit `print`s a warning if any of the deprecated actions is
invoked.

Note: `cover` has already been removed in 0.32.0.
  • Loading branch information
fmeum committed Jun 3, 2022
1 parent 4d620fa commit 5332e8d
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 0 deletions.
9 changes: 9 additions & 0 deletions go/private/actions/asm.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,22 @@ load(
"//go/private:mode.bzl",
"link_mode_args",
)
load(
"//go/private/actions:deprecation.bzl",
"LEGACY_ACTIONS_DEPRECATION_NOTICE",
)

def emit_asm(
go,
source = None,
hdrs = []):
"""See go/toolchains.rst#asm for full documentation."""

print(LEGACY_ACTIONS_DEPRECATION_NOTICE.format(
old = "go_context.asm",
new = "go_context.archive",
))

if source == None:
fail("source is a required parameter")

Expand Down
9 changes: 9 additions & 0 deletions go/private/actions/compile.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ load(
"//go/private:mode.bzl",
"link_mode_args",
)
load(
"//go/private/actions:deprecation.bzl",
"LEGACY_ACTIONS_DEPRECATION_NOTICE",
)

def _archive(v):
importpaths = [v.data.importpath]
Expand All @@ -38,6 +42,11 @@ def emit_compile(
asmhdr = None):
"""See go/toolchains.rst#compile for full documentation."""

print(LEGACY_ACTIONS_DEPRECATION_NOTICE.format(
old = "go_context.compile",
new = "go_context.archive",
))

if sources == None:
fail("sources is a required parameter")
if out_lib == None:
Expand Down
15 changes: 15 additions & 0 deletions go/private/actions/deprecation.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2022 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

LEGACY_ACTIONS_DEPRECATION_NOTICE = "The rules_go team intends to remove '{old}' in version 0.36.0 as it is no longer used by the ruleset itself and entirely untested. Consider using '{new}' instead. If that should not be possible for you, please comment on https://github.com/bazelbuild/rules_go/issues/3168."
10 changes: 10 additions & 0 deletions go/private/actions/pack.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

load(
"//go/private/actions:deprecation.bzl",
"LEGACY_ACTIONS_DEPRECATION_NOTICE",
)

def emit_pack(
go,
in_lib = None,
Expand All @@ -20,6 +25,11 @@ def emit_pack(
archives = []):
"""See go/toolchains.rst#pack for full documentation."""

print(LEGACY_ACTIONS_DEPRECATION_NOTICE.format(
old = "go_context.asm",
new = "go_context.archive",
))

if in_lib == None:
fail("in_lib is a required parameter")
if out_lib == None:
Expand Down
12 changes: 12 additions & 0 deletions go/toolchains.rst
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,9 @@ It returns a GoArchive_.
asm
+++

**Deprecated:** Planned to be removed in rules_go version 0.36.0. Please use `archive` instead and
comment on https://github.com/bazelbuild/rules_go/issues/3168 if should not be possible.

The asm function adds an action that runs ``go tool asm`` on a source file to
produce an object, and returns the File of that object.

Expand Down Expand Up @@ -655,6 +658,9 @@ a ``runfiles`` object.
compile
+++++++

**Deprecated:** Planned to be removed in rules_go version 0.36.0. Please use `archive` instead and
comment on https://github.com/bazelbuild/rules_go/issues/3168 if should not be possible.

The compile function adds an action that compiles a list of source files into
a package archive (.a file).

Expand Down Expand Up @@ -716,6 +722,9 @@ It does not return anything.
cover
+++++

**Removed in rules_go 0.32.0:** Please comment on https://github.com/bazelbuild/rules_go/issues/3168
if you still use this feature and cannot rely on `archive` instead.

The cover function adds an action that runs ``go tool cover`` on a set of source
files to produce copies with cover instrumentation.

Expand Down Expand Up @@ -782,6 +791,9 @@ It does not return anything.
pack
++++

**Deprecated:** Planned to be removed in rules_go version 0.36.0. Please use `archive` instead and
comment on https://github.com/bazelbuild/rules_go/issues/3168 if should not be possible.

The pack function adds an action that produces an archive from a base archive
and a collection of additional object files.

Expand Down

0 comments on commit 5332e8d

Please sign in to comment.