Skip to content

Commit

Permalink
Move to go:embed
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Koch <[email protected]>
  • Loading branch information
hugelgupf committed Dec 24, 2023
1 parent cefa938 commit 406acb2
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 102 deletions.
38 changes: 0 additions & 38 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,75 +96,58 @@ workflows:
jobs:
- clean-gopath
- clean-gomod
- clean-makebb
- clean-bazel
- build-gopath-go118:
requires:
- clean-makebb
- clean-gopath
- build-gopath-go119:
requires:
- clean-makebb
- clean-gopath
- build-gopath-go120:
requires:
- clean-makebb
- clean-gopath
- build-gopath-go121:
requires:
- clean-makebb
- clean-gopath
- test-go118:
requires:
- clean-makebb
- clean-gopath
- clean-gomod
- test-go119:
requires:
- clean-makebb
- clean-gopath
- clean-gomod
- test-go120:
requires:
- clean-makebb
- clean-gopath
- clean-gomod
- test-go121:
requires:
- clean-makebb
- clean-gopath
- clean-gomod
- build-gomod-go118:
requires:
- clean-makebb
- clean-gomod
- build-gomod-go119:
requires:
- clean-makebb
- clean-gomod
- build-gomod-go120:
requires:
- clean-makebb
- clean-gomod
- build-gomod-go121:
requires:
- clean-makebb
- clean-gomod
- build-gomod-multi-go118:
requires:
- clean-makebb
- clean-gomod
- build-gomod-multi-go119:
requires:
- clean-makebb
- clean-gomod
- build-gomod-multi-go120:
requires:
- clean-makebb
- clean-gomod
- build-gomod-multi-go121:
requires:
- clean-makebb
- clean-gomod
- build-bazel:
requires:
Expand Down Expand Up @@ -205,27 +188,6 @@ workflows:
- build-bazel-test

jobs:
clean-makebb:
<<: [*go121-template, *gomod-template]
steps:
- checkout
- run:
name: check generated code
command: |
mkdir -p /home/circleci/go/bin
go build ./src/cmd/embedvar
cp ./embedvar $GOPATH/bin
export PATH=$GOPATH/bin:$PATH
cd src/pkg/bb
go generate
git status
if [[ -n "$(git status --porcelain .)" ]]; then
echo 'Generated bbmain code is out of date. Run `go install ./src/cmd/embevar && cd src/pkg/bb && go generate` and then check changes in git.'
git status --porcelain .
git diff
exit 1
fi
clean-gopath:
<<: [*go121-template, *gopath-template]
steps:
Expand Down
1 change: 0 additions & 1 deletion src/cmd/embedvar/.gitignore

This file was deleted.

14 changes: 0 additions & 14 deletions src/cmd/embedvar/BUILD.bazel

This file was deleted.

35 changes: 0 additions & 35 deletions src/cmd/embedvar/embedvar.go

This file was deleted.

9 changes: 5 additions & 4 deletions src/pkg/bb/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
load("@io_bazel_rules_go//go:def.bzl", "go_embed_data", "go_library")
load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "bb",
srcs = [
"bb.go",
"bbmain_src.go",
"bbregister_src.go",
"generate.go",
],
embedsrcs = [
"//src/pkg/bb/bbmain/cmd:main.go",
"//src/pkg/bb/bbmain:register.go",
],
importpath = "github.com/u-root/gobusybox/src/pkg/bb",
visibility = ["//visibility:public"],
Expand Down
7 changes: 7 additions & 0 deletions src/pkg/bb/bb.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
package bb

import (
_ "embed"
"fmt"
"io"
"io/ioutil"
Expand All @@ -45,6 +46,12 @@ import (
"github.com/u-root/uio/ulog"
)

//go:embed bbmain/cmd/main.go
var bbMainSource []byte

//go:embed bbmain/register.go
var bbRegisterSource []byte

func listStrings(m map[string]struct{}) []string {
var l []string
for k := range m {
Expand Down
2 changes: 2 additions & 0 deletions src/pkg/bb/bbmain/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")

exports_files(["register.go"])

go_library(
name = "bbmain",
srcs = ["register.go"],
Expand Down
3 changes: 0 additions & 3 deletions src/pkg/bb/bbmain_src.go

This file was deleted.

3 changes: 0 additions & 3 deletions src/pkg/bb/bbregister_src.go

This file was deleted.

4 changes: 0 additions & 4 deletions src/pkg/bb/generate.go

This file was deleted.

0 comments on commit 406acb2

Please sign in to comment.