github.com/oweisse/u-root@v0.0.0-20181109060735-d005ad25fef1/tools/makebb/makebb.go (about) 1 // Copyright 2015-2018 the u-root Authors. All rights reserved 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // makebb compiles many Go commands into one bb-style binary. 6 package main 7 8 import ( 9 "flag" 10 "log" 11 "os" 12 "path/filepath" 13 14 "github.com/u-root/u-root/pkg/golang" 15 "github.com/u-root/u-root/pkg/uroot" 16 "github.com/u-root/u-root/pkg/uroot/builder/bb" 17 ) 18 19 var outputPath = flag.String("o", "bb", "Path to busybox binary") 20 21 func main() { 22 flag.Parse() 23 24 // Why doesn't the log package export this as a default? 25 l := log.New(os.Stdout, "", log.LstdFlags) 26 env := golang.Default() 27 if env.CgoEnabled { 28 l.Printf("Disabling CGO for u-root...") 29 env.CgoEnabled = false 30 } 31 l.Printf("Build environment: %s", env) 32 33 pkgs := flag.Args() 34 if len(pkgs) == 0 { 35 pkgs = []string{"github.com/u-root/u-root/cmds/*"} 36 } 37 pkgs, err := uroot.ResolvePackagePaths(l, env, pkgs) 38 if err != nil { 39 l.Fatal(err) 40 } 41 42 o, err := filepath.Abs(*outputPath) 43 if err != nil { 44 l.Fatal(err) 45 } 46 47 if err := bb.BuildBusybox(env, pkgs, o); err != nil { 48 l.Fatal(err) 49 } 50 }