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

add option to specify go -compiler, e.g. tinygo see u-root/gobusybox#121 #34

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions uimage/mkuimage/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ func CreateUimage(l *llog.Logger, base []uimage.Modifier, tf *TemplateFlags, f *
l.Infof("Could not get environment's Go version, using runtime's version: %v", err)
v = runtime.Version()
}
if len(env.Compiler.VersionOutput) != 0 {
l.Infof("Compiler: %v", env.Compiler.VersionOutput)
}
if !isRecommendedVersion(v) {
l.Warnf(`You are not using one of the recommended Go versions (have = %s, recommended = %v).
Some packages may not compile.
Expand Down
13 changes: 10 additions & 3 deletions uimage/mkuimage/uflags.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type CommandFlags struct {
Mod golang.ModBehavior
BuildTags []string
BuildOpts *golang.BuildOpts
Compiler string
}

// RegisterFlags registers flags related to Go commands being built.
Expand All @@ -61,6 +62,8 @@ func (c *CommandFlags) RegisterFlags(f *flag.FlagSet) {
// Register an alias for -go-build-tags for backwards compatibility.
f.Var((*uflag.Strings)(&c.BuildTags), "tags", "Go build tags -- repeat the flag for multiple values")
f.Var((*uflag.Strings)(&c.BuildTags), "go-build-tags", "Go build tags -- repeat the flag for multiple values")
f.StringVar((*string)(&c.Compiler), "compiler", "", "override go compiler to use (e.g. \"/path/to/tinygo\")")

}

// Modifiers turns the flag values into uimage modifiers.
Expand All @@ -77,9 +80,13 @@ func (c *CommandFlags) Modifiers(packages ...string) ([]uimage.Modifier, error)
switch c.Builder {
case "bb", "gbb":
return []uimage.Modifier{
uimage.WithEnv(golang.WithBuildTag(c.BuildTags...), func(e *golang.Environ) {
e.Mod = c.Mod
}),
uimage.WithEnv(
golang.WithBuildTag(c.BuildTags...),
golang.WithCompiler(c.Compiler),
func(e *golang.Environ) {
e.Mod = c.Mod
},
),
uimage.WithBusyboxCommands(packages...),
uimage.WithShellBang(c.ShellBang),
uimage.WithBusyboxBuildOpts(c.BuildOpts),
Expand Down