github.com/jlowellwofford/u-root@v1.0.0/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 "path/filepath" 12 13 "github.com/u-root/u-root/pkg/golang" 14 "github.com/u-root/u-root/pkg/uroot" 15 ) 16 17 var outputPath = flag.String("o", "bb", "Path to busybox binary") 18 19 func main() { 20 flag.Parse() 21 22 env := golang.Default() 23 if env.CgoEnabled { 24 log.Printf("Disabling CGO for u-root...") 25 env.CgoEnabled = false 26 } 27 log.Printf("Build environment: %s", env) 28 29 pkgs := flag.Args() 30 var err error 31 if len(pkgs) == 0 { 32 pkgs, err = uroot.DefaultPackageImports(env) 33 } else { 34 pkgs, err = uroot.ResolvePackagePaths(env, pkgs) 35 } 36 if err != nil { 37 log.Fatal(err) 38 } 39 40 o, err := filepath.Abs(*outputPath) 41 if err != nil { 42 log.Fatal(err) 43 } 44 45 if err := uroot.BuildBusybox(env, pkgs, o); err != nil { 46 log.Fatal(err) 47 } 48 }