Skip to content

Commit

Permalink
Move BuildOpts -- allow specifying different BuildOpts for different …
Browse files Browse the repository at this point in the history
…commands

Signed-off-by: Chris Koch <[email protected]>
  • Loading branch information
hugelgupf committed Jan 28, 2024
1 parent f84a23d commit 8dc1068
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions cmd/mkuimage/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,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 +367,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
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

0 comments on commit 8dc1068

Please sign in to comment.