Skip to content

Commit

Permalink
Delete legacy actions API
Browse files Browse the repository at this point in the history
  • Loading branch information
fmeum committed Jun 3, 2022
1 parent 4d620fa commit df0fdc7
Show file tree
Hide file tree
Showing 12 changed files with 9 additions and 546 deletions.
3 changes: 0 additions & 3 deletions go/private/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,8 @@ bzl_library(
"//go/private:platforms",
"//go/private:providers",
"//go/private/actions:archive",
"//go/private/actions:asm",
"//go/private/actions:binary",
"//go/private/actions:compile",
"//go/private/actions:link",
"//go/private/actions:pack",
"//go/private/actions:stdlib",
],
)
Expand Down
20 changes: 0 additions & 20 deletions go/private/actions/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,6 @@ bzl_library(
],
)

bzl_library(
name = "asm",
srcs = ["asm.bzl"],
visibility = ["//go:__subpackages__"],
deps = ["//go/private:mode"],
)

bzl_library(
name = "binary",
srcs = ["binary.bzl"],
Expand All @@ -43,13 +36,6 @@ bzl_library(
],
)

bzl_library(
name = "compile",
srcs = ["compile.bzl"],
visibility = ["//go:__subpackages__"],
deps = ["//go/private:mode"],
)

bzl_library(
name = "compilepkg",
srcs = ["compilepkg.bzl"],
Expand All @@ -72,12 +58,6 @@ bzl_library(
],
)

bzl_library(
name = "pack",
srcs = ["pack.bzl"],
visibility = ["//go:__subpackages__"],
)

bzl_library(
name = "stdlib",
srcs = ["stdlib.bzl"],
Expand Down
3 changes: 0 additions & 3 deletions go/private/context.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -481,11 +481,8 @@ def go_context(ctx, attr = None):

# Action generators
archive = toolchain.actions.archive,
asm = toolchain.actions.asm,
binary = toolchain.actions.binary,
compile = toolchain.actions.compile,
link = toolchain.actions.link,
pack = toolchain.actions.pack,

# Helpers
args = _new_args, # deprecated
Expand Down
6 changes: 0 additions & 6 deletions go/private/go_toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@ Toolchain rules used by go.
load("//go/private:platforms.bzl", "PLATFORMS")
load("//go/private:providers.bzl", "GoSDK")
load("//go/private/actions:archive.bzl", "emit_archive")
load("//go/private/actions:asm.bzl", "emit_asm")
load("//go/private/actions:binary.bzl", "emit_binary")
load("//go/private/actions:compile.bzl", "emit_compile")
load("//go/private/actions:link.bzl", "emit_link")
load("//go/private/actions:pack.bzl", "emit_pack")
load("//go/private/actions:stdlib.bzl", "emit_stdlib")

def _go_toolchain_impl(ctx):
Expand All @@ -36,11 +33,8 @@ def _go_toolchain_impl(ctx):
default_goarch = ctx.attr.goarch,
actions = struct(
archive = emit_archive,
asm = emit_asm,
binary = emit_binary,
compile = emit_compile,
link = emit_link,
pack = emit_pack,
stdlib = emit_stdlib,
),
flags = struct(
Expand Down
146 changes: 0 additions & 146 deletions go/toolchains.rst
Original file line number Diff line number Diff line change
Expand Up @@ -546,12 +546,8 @@ Methods
* Action generators

* archive_
* asm_
* binary_
* compile_
* cover_
* link_
* pack_

* Helpers

Expand Down Expand Up @@ -582,30 +578,6 @@ It returns a GoArchive_.
+--------------------------------+-----------------------------+-----------------------------------+


asm
+++

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.

+--------------------------------+-----------------------------+-----------------------------------+
| **Name** | **Type** | **Default value** |
+--------------------------------+-----------------------------+-----------------------------------+
| :param:`go` | :type:`GoContext` | |mandatory| |
+--------------------------------+-----------------------------+-----------------------------------+
| This must be the same GoContext object you got this function from. |
+--------------------------------+-----------------------------+-----------------------------------+
| :param:`source` | :type:`File` | |mandatory| |
+--------------------------------+-----------------------------+-----------------------------------+
| A source code artifact to assemble. |
| This must be a ``.s`` file that contains code in the platform neutral `go assembly`_ language. |
+--------------------------------+-----------------------------+-----------------------------------+
| :param:`hdrs` | :type:`File iterable` | :value:`[]` |
+--------------------------------+-----------------------------+-----------------------------------+
| The list of .h files that may be included by the source. |
+--------------------------------+-----------------------------+-----------------------------------+


binary
++++++

Expand Down Expand Up @@ -652,90 +624,6 @@ a ``runfiles`` object.
| file name based on ``name``, the target platform, and the link mode. |
+--------------------------------+-----------------------------+-----------------------------------+

compile
+++++++

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

It does not return anything.

+--------------------------------+-----------------------------+-----------------------------------+
| **Name** | **Type** | **Default value** |
+--------------------------------+-----------------------------+-----------------------------------+
| :param:`go` | :type:`GoContext` | |mandatory| |
+--------------------------------+-----------------------------+-----------------------------------+
| This must be the same GoContext object you got this function from. |
+--------------------------------+-----------------------------+-----------------------------------+
| :param:`sources` | :type:`File iterable` | |mandatory| |
+--------------------------------+-----------------------------+-----------------------------------+
| An iterable of source code artifacts. |
| These must be pure .go files, no assembly or cgo is allowed. |
+--------------------------------+-----------------------------+-----------------------------------+
| :param:`importpath` | :type:`string` | :value:`""` |
+--------------------------------+-----------------------------+-----------------------------------+
| The import path this package represents. This is passed to the -p flag. When the actual import |
| path is different than the source import path (i.e., when ``importmap`` is set in a |
| ``go_library`` rule), this should be the actual import path. |
+--------------------------------+-----------------------------+-----------------------------------+
| :param:`archives` | :type:`GoArchive iterable` | :value:`[]` |
+--------------------------------+-----------------------------+-----------------------------------+
| An iterable of all directly imported libraries. |
| The action will verify that all directly imported libraries were supplied, not allowing |
| transitive dependencies to satisfy imports. It will not check that all supplied libraries were |
| used though. |
+--------------------------------+-----------------------------+-----------------------------------+
| :param:`out_lib` | :type:`File` | |mandatory| |
+--------------------------------+-----------------------------+-----------------------------------+
| The archive file that should be produced. |
+--------------------------------+-----------------------------+-----------------------------------+
| :param:`out_export` | :type:`File` | :value:`None` |
+--------------------------------+-----------------------------+-----------------------------------+
| File where extra information about the package may be stored. This is used |
| by nogo to store serialized facts about definitions. In the future, it may |
| be used to store export data (instead of the .a file). |
+--------------------------------+-----------------------------+-----------------------------------+
| :param:`gc_goopts` | :type:`string_list` | :value:`[]` |
+--------------------------------+-----------------------------+-----------------------------------+
| Additional flags to pass to the compiler. |
+--------------------------------+-----------------------------+-----------------------------------+
| :param:`testfilter` | :type:`string` | :value:`"off"` |
+--------------------------------+-----------------------------+-----------------------------------+
| Controls how files with a ``_test`` suffix are filtered. |
| |
| * ``"off"`` - files with and without a ``_test`` suffix are compiled. |
| * ``"only"`` - only files with a ``_test`` suffix are compiled. |
| * ``"exclude"`` - only files without a ``_test`` suffix are compiled. |
+--------------------------------+-----------------------------+-----------------------------------+
| :param:`asmhdr` | :type:`File` | :value:`None` |
+--------------------------------+-----------------------------+-----------------------------------+
| If provided, the compiler will write an assembly header to this file. |
+--------------------------------+-----------------------------+-----------------------------------+


cover
+++++

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

Returns a covered GoSource_ with the required source files process for coverage.

Note that this removes most comments, including cgo comments.

+--------------------------------+-----------------------------+-----------------------------------+
| **Name** | **Type** | **Default value** |
+--------------------------------+-----------------------------+-----------------------------------+
| :param:`go` | :type:`GoContext` | |mandatory| |
+--------------------------------+-----------------------------+-----------------------------------+
| This must be the same GoContext object you got this function from. |
+--------------------------------+-----------------------------+-----------------------------------+
| :param:`source` | :type:`GoSource` | |mandatory| |
+--------------------------------+-----------------------------+-----------------------------------+
| The source object to process. Any source files in the object that have been marked as needing |
| coverage will be processed and substiuted in the returned GoSource. |
+--------------------------------+-----------------------------+-----------------------------------+


link
++++
Expand Down Expand Up @@ -779,40 +667,6 @@ It does not return anything.
| Info file used for link stamping. |
+--------------------------------+-----------------------------+-----------------------------------+

pack
++++

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

It does not return anything.

+--------------------------------+-----------------------------+-----------------------------------+
| **Name** | **Type** | **Default value** |
+--------------------------------+-----------------------------+-----------------------------------+
| :param:`go` | :type:`GoContext` | |mandatory| |
+--------------------------------+-----------------------------+-----------------------------------+
| This must be the same GoContext object you got this function from. |
+--------------------------------+-----------------------------+-----------------------------------+
| :param:`in_lib` | :type:`File` | |mandatory| |
+--------------------------------+-----------------------------+-----------------------------------+
| The archive that should be copied and appended to. |
| This must always be an archive in the common ar form (like that produced by the go compiler). |
+--------------------------------+-----------------------------+-----------------------------------+
| :param:`out_lib` | :type:`File` | |mandatory| |
+--------------------------------+-----------------------------+-----------------------------------+
| The archive that should be produced. |
| This will always be an archive in the common ar form (like that produced by the go compiler). |
+--------------------------------+-----------------------------+-----------------------------------+
| :param:`objects` | :type:`File iterable` | :value:`()` |
+--------------------------------+-----------------------------+-----------------------------------+
| An iterable of object files to be added to the output archive file. |
+--------------------------------+-----------------------------+-----------------------------------+
| :param:`archives` | :type:`list of File` | :value:`[]` |
+--------------------------------+-----------------------------+-----------------------------------+
| Additional archives whose objects will be appended to the output. |
| These can be ar files in either common form or either the bsd or sysv variations. |
+--------------------------------+-----------------------------+-----------------------------------+

args
++++
Expand Down
1 change: 0 additions & 1 deletion go/tools/builders/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ filegroup(
"asm.go",
"builder.go",
"cgo2.go",
"compile.go",
"compilepkg.go",
"cover.go",
"edit.go",
Expand Down
40 changes: 0 additions & 40 deletions go/tools/builders/asm.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
package main

import (
"flag"
"fmt"
"go/build"
"io/ioutil"
"os"
"path/filepath"
Expand All @@ -26,43 +23,6 @@ import (
"strings"
)

// asm builds a single .s file with "go tool asm". It is invoked by the
// Go rules as an action.
func asm(args []string) error {
// Parse arguments.
args, err := expandParamsFiles(args)
if err != nil {
return err
}
builderArgs, asmFlags := splitArgs(args)
var outPath string
flags := flag.NewFlagSet("GoAsm", flag.ExitOnError)
flags.StringVar(&outPath, "o", "", "The output archive file to write")
goenv := envFlags(flags)
if err := flags.Parse(builderArgs); err != nil {
return err
}
if err := goenv.checkFlags(); err != nil {
return err
}
if flags.NArg() != 1 {
return fmt.Errorf("wanted exactly 1 source file; got %d", flags.NArg())
}
source := flags.Args()[0]

// Filter the input file.
metadata, err := readFileInfo(build.Default, source)
if err != nil {
return err
}
if !metadata.matched {
source = os.DevNull
}

// Build source with the assembler.
return asmFile(goenv, source, asmFlags, outPath)
}

// buildSymabisFile generates a file from assembly files that is consumed
// by the compiler. This is only needed in go1.12+ when there is at least one
// .s file. If the symabis file is not needed, no file will be generated,
Expand Down
8 changes: 0 additions & 8 deletions go/tools/builders/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,8 @@ func main() {

var action func(args []string) error
switch verb {
case "asm":
action = asm
case "compile":
action = compile
case "compilepkg":
action = compilePkg
case "cover":
action = cover
case "filterbuildid":
action = filterBuildID
case "gentestmain":
Expand All @@ -55,8 +49,6 @@ func main() {
action = link
case "gennogomain":
action = genNogoMain
case "pack":
action = pack
case "stdlib":
action = stdlib
case "stdliblist":
Expand Down
Loading

0 comments on commit df0fdc7

Please sign in to comment.