gitee.com/mirrors_u-root/u-root@v7.0.0+incompatible/pkg/uroot/builder/builder.go (about) 1 // Copyright 2015-2017 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 package builder 6 7 import ( 8 "github.com/u-root/u-root/pkg/golang" 9 "github.com/u-root/u-root/pkg/uroot/initramfs" 10 ) 11 12 var ( 13 BusyBox = BBBuilder{} 14 Source = SourceBuilder{} 15 Binary = BinaryBuilder{} 16 ) 17 18 // Opts are options passed to the Builder.Build function. 19 type Opts struct { 20 // Env is the Go compiler environment. 21 Env golang.Environ 22 23 // Packages are the Go packages to compile. 24 // 25 // Only an explicit list of Go import paths is accepted. 26 // 27 // E.g. cmd/go or github.com/u-root/u-root/cmds/ls. 28 Packages []string 29 30 // TempDir is a temporary directory where the compilation mode compiled 31 // binaries can be placed. 32 // 33 // TempDir should contain no files. 34 TempDir string 35 36 // BinaryDir is the initramfs directory for built binaries. 37 // 38 // BinaryDir must be specified. 39 BinaryDir string 40 41 // NoStrip builds unstripped binaries. 42 NoStrip bool 43 } 44 45 // Builder builds Go packages and adds the binaries to an initramfs. 46 // 47 // The resulting files need not be binaries per se, but exec'ing the resulting 48 // file should result in the Go program being executed. 49 type Builder interface { 50 // Build uses the given options to build Go packages and adds its files 51 // to be included in the initramfs to the given ArchiveFiles. 52 Build(*initramfs.Files, Opts) error 53 54 // DefaultBinaryDir is the initramfs' default directory for binaries 55 // built using this builder. 56 DefaultBinaryDir() string 57 }