Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API improvements #6

Merged
merged 3 commits into from
Jan 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions cmd/mkuimage/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,6 @@ func Main(l ulog.Logger, env *golang.Environ, buildOpts *golang.BuildOpts) error
var b builder.Builder
switch *build {
case "bb", "gbb":
l.Printf("NOTE: building with the new gobusybox; to get the old behavior check out commit 8b790de")
b = builder.GBBBuilder{ShellBang: *shellbang}
case "binary":
b = builder.BinaryBuilder{}
Expand Down Expand Up @@ -350,8 +349,9 @@ func Main(l ulog.Logger, env *golang.Environ, buildOpts *golang.BuildOpts) error
// The command-line tool only allows specifying one build mode
// right now.
c = append(c, uroot.Commands{
Builder: b,
Packages: pkgs,
Builder: b,
Packages: pkgs,
BuildOpts: buildOpts,
})
}

Expand All @@ -366,7 +366,6 @@ func Main(l ulog.Logger, env *golang.Environ, buildOpts *golang.BuildOpts) error
UseExistingInit: *useExistingInit,
InitCmd: initCommand,
DefaultShell: *defaultShell,
BuildOpts: buildOpts,
}
uinitArgs := shlex.Split(*uinitCmd)
if len(uinitArgs) > 0 {
Expand Down
54 changes: 0 additions & 54 deletions cmd/mkuimage/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,42 +144,6 @@ func TestUrootCmdline(t *testing.T) {
"github.com/u-root/u-root/cmds/core/echo",
},
},
{
name: "MIPS build",
env: []string{"GOARCH=mips"},
args: []string{
"github.com/u-root/u-root/cmds/core/init",
"github.com/u-root/u-root/cmds/core/elvish",
"github.com/u-root/u-root/cmds/core/echo",
},
},
{
name: "MIPSLE build",
env: []string{"GOARCH=mipsle"},
args: []string{
"github.com/u-root/u-root/cmds/core/init",
"github.com/u-root/u-root/cmds/core/elvish",
"github.com/u-root/u-root/cmds/core/echo",
},
},
{
name: "MIPS64 build",
env: []string{"GOARCH=mips64"},
args: []string{
"github.com/u-root/u-root/cmds/core/init",
"github.com/u-root/u-root/cmds/core/elvish",
"github.com/u-root/u-root/cmds/core/echo",
},
},
{
name: "MIPS64LE build",
env: []string{"GOARCH=mips64le"},
args: []string{
"github.com/u-root/u-root/cmds/core/init",
"github.com/u-root/u-root/cmds/core/elvish",
"github.com/u-root/u-root/cmds/core/echo",
},
},
{
name: "ARM7 build",
env: []string{"GOARCH=arm", "GOARM=7"},
Expand All @@ -198,24 +162,6 @@ func TestUrootCmdline(t *testing.T) {
"github.com/u-root/u-root/cmds/core/echo",
},
},
{
name: "386 (32 bit) build",
env: []string{"GOARCH=386"},
args: []string{
"github.com/u-root/u-root/cmds/core/init",
"github.com/u-root/u-root/cmds/core/elvish",
"github.com/u-root/u-root/cmds/core/echo",
},
},
{
name: "Power 64bit build",
env: []string{"GOARCH=ppc64le"},
args: []string{
"github.com/u-root/u-root/cmds/core/init",
"github.com/u-root/u-root/cmds/core/elvish",
"github.com/u-root/u-root/cmds/core/echo",
},
},
{
name: "RISCV 64bit build",
env: []string{"GOARCH=riscv64"},
Expand Down
18 changes: 9 additions & 9 deletions uroot/uroot.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ type Commands struct {
// BinaryDir may be empty, in which case Builder.DefaultBinaryDir()
// will be used.
BinaryDir string

// Build options for building go binaries. Ultimate this holds all the
// args that end up being passed to `go build`.
BuildOpts *golang.BuildOpts
}

// TargetDir returns the initramfs binary directory for these Commands.
Expand Down Expand Up @@ -224,10 +228,6 @@ type Opts struct {
//
// This must be specified to have a default shell.
DefaultShell string

// Build options for building go binaries. Ultimate this holds all the
// args that end up being passed to `go build`.
BuildOpts *golang.BuildOpts
}

// CreateInitramfs creates an initramfs built to opts' specifications.
Expand All @@ -243,10 +243,6 @@ func CreateInitramfs(logger ulog.Logger, opts Opts) error {
if opts.Env != nil {
env = opts.Env
}
if opts.BuildOpts == nil {
opts.BuildOpts = &golang.BuildOpts{}
}

files := initramfs.NewFiles()

lookupEnv := findpkg.DefaultEnv()
Expand All @@ -269,11 +265,15 @@ func CreateInitramfs(logger ulog.Logger, opts Opts) error {
if err != nil {
return err
}
buildOpts := cmds.BuildOpts
if buildOpts == nil {
buildOpts = &golang.BuildOpts{}
}

// Build packages.
bOpts := builder.Opts{
Env: env,
BuildOpts: opts.BuildOpts,
BuildOpts: buildOpts,
Packages: cmds.Packages,
TempDir: builderTmpDir,
BinaryDir: cmds.TargetDir(),
Expand Down
Loading