Skip to content

Commit

Permalink
Drop support for bazel
Browse files Browse the repository at this point in the history
rules_go changes too often, I don't know of anyone using this, and I
don't have time to maintain this properly. If someone is interested in
this, please file an issue.

Signed-off-by: Chris Koch <chrisko@google.com>
  • Loading branch information
hugelgupf committed Feb 9, 2024
1 parent e7979cb commit 2515003
Show file tree
Hide file tree
Showing 49 changed files with 3 additions and 1,380 deletions.
94 changes: 0 additions & 94 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,6 @@ templates:
docker:
- image: cimg/go:1.21

bazel-template: &bazel-template
docker:
- image: cimg/go:1.21
working_directory: /home/circleci/go/bazel_gobusybox
environment:
- GOPATH: "/home/circleci/go"
resource_class: large

build-gomod-template: &build-gomod-template
steps:
- checkout
Expand Down Expand Up @@ -97,10 +89,6 @@ workflows:
- clean-gopath
- clean-gomod
- clean-makebb
- clean-bazel
- build-bazel
- build-bazel-cross
- build-bazel-test
- build-gopath-go118:
requires:
- clean-makebb
Expand Down Expand Up @@ -194,9 +182,6 @@ workflows:
- build-gomod-multi-go119
- build-gomod-multi-go120
- build-gomod-multi-go121
- build-bazel
- build-bazel-cross
- build-bazel-test

jobs:
clean-makebb:
Expand Down Expand Up @@ -329,82 +314,3 @@ jobs:

build-gomod-multi-go121:
<<: [*go121-template, *gomod-template, *build-gomod-multi-template]

clean-bazel:
<<: *bazel-template
steps:
- checkout
- run: go install github.com/bazelbuild/bazelisk@latest
- run:
name: run gazelle
command: |
bazelisk run :gazelle
git status
if [[ -n "$(git status --porcelain .)" ]]; then
echo 'BUILD files are out-of-date: run `bazel run :gazelle` and then check in the changes'
git status --porcelain .
exit 1
fi
- run:
name: sync bazel deps.bzl with src/go.mod
command: |
bazelisk run //:gazelle -- update-repos -from_file=src/go.mod -to_macro=deps.bzl%go_dependencies
git status
if [[ -n "$(git status --porcelain deps.bzl)" ]]; then
echo 'go.mod deps are out of sync with deps.bzl: run '
echo ' bazel run //:gazelle -- update-repos -from_file=src/go.mod -to_macro=deps.bzl%go_dependencies'
echo 'and then check in the changes in deps.bzl'
git status --porcelain .
exit 1
fi
- run:
name: run buildifier
command: |
bazelisk run :buildifier -- -r .
# For some reason, running buildifier or gazelle updates go.sum.
git checkout -- src/go.sum
git status
if [[ -n "$(git status --porcelain .)" ]]; then
echo 'BUILD files are out-of-date: run `bazel run :buildifier -- -r .` and then check in the changes'
git status --porcelain .
exit 1
fi
build-bazel:
<<: *bazel-template
steps:
- checkout
- run: go install github.com/bazelbuild/bazelisk@latest
- run:
name: build busybox
command: |
bazelisk build //src:bb
./bazel-bin/src/bb_/bb helloworld
- run:
name: build everything (amd64)
command: bazelisk build //src/...

build-bazel-cross:
<<: *bazel-template
steps:
- checkout
- run: go install github.com/bazelbuild/bazelisk@latest
- run:
name: bazel cross-compile
command: |
bazelisk build --platforms=@io_bazel_rules_go//go/toolchain:linux_arm64 //src:uroot_bb
bazelisk build --platforms=@io_bazel_rules_go//go/toolchain:linux_arm64 //src:bb
bazelisk build --platforms=@io_bazel_rules_go//go/toolchain:linux_arm //src:uroot_bb
bazelisk build --platforms=@io_bazel_rules_go//go/toolchain:linux_arm //src:bb
bazelisk build --platforms=@io_bazel_rules_go//go/toolchain:linux_riscv64 //src:uroot_bb
bazelisk build --platforms=@io_bazel_rules_go//go/toolchain:linux_riscv64 //src:bb
build-bazel-test:
<<: *bazel-template
steps:
- checkout
- run: go install github.com/bazelbuild/bazelisk@latest
- run:
name: bazel test
command: bazelisk query 'tests(//src/...) except attr(tags, notest, //src/...)' | xargs bazelisk test
14 changes: 0 additions & 14 deletions BUILD.bazel

This file was deleted.

48 changes: 3 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ determine which command is being called.
| Feature | Support status |
| ---------- | ----------------------------------------------------- |
| Go version | Tested are 1.18-1.21 |
| Packaging | Go modules, Go vendoring, bazel w/ [rules_go](https\://github.com/bazelbuild/rules_go) |
| Packaging | Go modules, Go vendoring |
| `GOOS` | linux (others may work, but untested) |
| `GOARCH` | amd64, arm, arm64, riscv64 (others may work, but untested) |
| CGO | *Not supported* |
Expand Down Expand Up @@ -156,49 +156,7 @@ makebb \
## APIs

Besides the makebb CLI command, there is a
[Go API at src/pkg/bb](https://pkg.go.dev/github.com/u-root/gobusybox/src/pkg/bb)
and bazel rules in [src/gobb2.bzl](src/gobb2.bzl).

### Using bazel go_busybox rule

Assuming you have [rules_go](https://github.com/bazelbuild/rules_go) set up, add
the following to your `WORKSPACE`:

```bzl
git_repository(
name = "com_github_u_root_gobusybox",

# We do not have regular releases yet.
#
# We also do not guarantee compatibility yet, so it may be worth choosing a
# commit and setting `commit = "hash"` here instead of the branch.
branch = "main",
remote = "https://github.com/u-root/gobusybox.git",
)
```

Then, in any `BUILD` file, you can create a busybox like this:

```bzl
load("@com_github_u_root_gobusybox//src:gobb2.bzl", "go_busybox")

go_busybox(
name = "bb",
cmds = [
# These must be absolute labels, for the moment, and each command must
# be listed individually. (No :... or :all target patterns.)
"//cmd/foobar",
"//cmd/otherbar",

# Another repository's go_binarys are totally fine, e.g. if imported
# with gazelle's go_repository rule.
"@com_github_u-root_u-root//cmds/core/ls",
],
)
```

For the moment, the targets listed on `cmds` must be **individual, absolute
labels** (issue [#38](https://github.com/u-root/gobusybox/issues/38)).
[Go API at src/pkg/bb](https://pkg.go.dev/github.com/u-root/gobusybox/src/pkg/bb).

## Shortcomings

Expand Down Expand Up @@ -381,7 +339,7 @@ func main() {
This would be rewritten to be:

```go
package sl // based on the directory name or bazel-rule go_binary name
package sl // based on the directory name

import (
"flag"
Expand Down
59 changes: 0 additions & 59 deletions WORKSPACE

This file was deleted.

88 changes: 0 additions & 88 deletions deps.bzl

This file was deleted.

Loading

0 comments on commit 2515003

Please sign in to comment.