Skip to content

Commit

Permalink
Register new gobb flags
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Koch <[email protected]>
  • Loading branch information
hugelgupf committed Dec 27, 2023
1 parent 70d0367 commit f7391ca
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions u-root.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"time"

gbbgolang "github.com/u-root/gobusybox/src/pkg/golang"
"github.com/u-root/gobusybox/src/pkg/uflag"
"github.com/u-root/u-root/pkg/shlex"
"github.com/u-root/u-root/pkg/ulog"
"github.com/u-root/u-root/pkg/uroot"
Expand Down Expand Up @@ -54,7 +55,6 @@ var (
statsOutputPath *string
statsLabel *string
shellbang *bool
tags *string
// For the new gobusybox support
usegobusybox *bool
genDir *string
Expand Down Expand Up @@ -93,8 +93,6 @@ func init() {
statsOutputPath = flag.String("stats-output-path", "", "Write build stats to this file (JSON)")
statsLabel = flag.String("stats-label", "", "Use this statsLabel when writing stats")

tags = flag.String("tags", "", "Comma separated list of build tags")

// Flags for the gobusybox, which we hope to move to, since it works with modules.
genDir = flag.String("gen-dir", "", "Directory to generate source in")

Expand Down Expand Up @@ -186,21 +184,25 @@ func main() {
if err := checkArgs(os.Args...); err != nil {
log.Fatal(err)
}

gbbOpts := &gbbgolang.BuildOpts{}
gbbOpts.RegisterFlags(flag.CommandLine)

l := log.New(os.Stderr, "", log.Ltime)

// Register an alias for -go-no-strip for backwards compatibility.
flag.CommandLine.BoolVar(&gbbOpts.NoStrip, "no-strip", false, "Build unstripped binaries")

env := gbbgolang.Default()
env.RegisterFlags(flag.CommandLine)
tags := (*uflag.Strings)(&env.BuildTags)
flag.CommandLine.Var(tags, "tags", "Go build tags -- repeat the flag for multiple values")

flag.Parse()

l := log.New(os.Stderr, "", log.Ltime)

if usrc := os.Getenv("UROOT_SOURCE"); usrc != "" && *urootSourceDir == "" {
*urootSourceDir = usrc
}

env := gbbgolang.Default()
env.BuildTags = strings.Split(*tags, ",")
if env.CgoEnabled {
l.Printf("Disabling CGO for u-root...")
env.CgoEnabled = false
Expand Down

0 comments on commit f7391ca

Please sign in to comment.