Documentation ¶
Index ¶
- Variables
- func BuildBusybox(env golang.Environ, pkgs []string, binaryPath string) error
- func CreateBBMainSource(fset *token.FileSet, astp *ast.Package, pkgs []string, destDir string) error
- func ParseAST(p *build.Package) (*token.FileSet, *ast.Package, error)
- func RewritePackage(env golang.Environ, pkgPath, destDir, bbImportPath string, ...) error
- type BBBuilder
- type BinaryBuilder
- type Builder
- type Opts
- type Package
- type SourceBuilder
Constants ¶
This section is empty.
Variables ¶
var Builders = map[string]Builder{ "bb": BBBuilder{}, "source": SourceBuilder{}, "binary": BinaryBuilder{}, }
Functions ¶
func BuildBusybox ¶
BuildBusybox builds a busybox of the given Go packages.
pkgs is a list of Go import paths. If nil is returned, binaryPath will hold the busybox-style binary.
func CreateBBMainSource ¶
func CreateBBMainSource(fset *token.FileSet, astp *ast.Package, pkgs []string, destDir string) error
CreateBBMainSource creates a bb Go command that imports all given pkgs.
p must be the bb template.
- For each pkg in pkgs, add import _ "pkg" to astp's first file.
- Write source file out to destDir.
func RewritePackage ¶
func RewritePackage(env golang.Environ, pkgPath, destDir, bbImportPath string, importer types.Importer) error
RewritePackage rewrites pkgPath to be bb-mode compatible, where destDir is the file system destination of the written files and bbImportPath is the Go import path of the bb package to register with.
Types ¶
type BBBuilder ¶
type BBBuilder struct{}
BBBuilder is an implementation of Builder that compiles many Go commands into one busybox-style binary.
func (BBBuilder) Build ¶
Build is an implementation of uroot.Builder.Build for a busybox-like initramfs.
Build rewrites the source files of the packages given to create one busybox-like binary containing all commands in opts.Packages.
See pkg/uroot/README.md for a detailed explanation of busybox mode.
func (BBBuilder) DefaultBinaryDir ¶
type BinaryBuilder ¶
type BinaryBuilder struct{}
func (BinaryBuilder) Build ¶
func (BinaryBuilder) Build(af initramfs.Files, opts Opts) error
Build builds all given packages as separate binaries and includes them in the archive.
func (BinaryBuilder) DefaultBinaryDir ¶
func (BinaryBuilder) DefaultBinaryDir() string
type Builder ¶
type Builder interface { // Build uses the given options to build Go packages and adds its files // to be included in the initramfs to the given ArchiveFiles. Build(initramfs.Files, Opts) error // DefaultBinaryDir is the initramfs' default directory for binaries // built using this builder. DefaultBinaryDir() string }
Builder builds Go packages and adds the binaries to an initramfs.
The resulting files need not be binaries per se, but exec'ing the resulting file should result in the Go program being executed.
func GetBuilder ¶
GetBuilder returns the Build function for the named build mode.
type Opts ¶
type Opts struct { // Env is the Go compiler environment. Env golang.Environ // Packages are the Go packages to compile. // // Only an explicit list of Go import paths is accepted. // // E.g. cmd/go or github.com/u-root/u-root/cmds/ls. Packages []string // TempDir is a temporary directory where the compilation mode compiled // binaries can be placed. // // TempDir should contain no files. TempDir string // BinaryDir is the initramfs directory for built binaries. // // BinaryDir must be specified. BinaryDir string }
Opts are arguments to the Builder.Build function.
type Package ¶
type Package struct {
// contains filtered or unexported fields
}
Package is a Go package.
It holds AST, type, file, and Go package information about a Go package.
func NewPackage ¶
NewPackage gathers AST, type, and token information about package p, using the given importer to resolve dependencies.
type SourceBuilder ¶
type SourceBuilder struct{}
SourceBuilder
func (SourceBuilder) Build ¶
func (SourceBuilder) Build(af initramfs.Files, opts Opts) error
Build is an implementation of Build that includes opts.Packages' full source in the initramfs.
It then also includes the Go toolchain (go, compile, link, asm) and an init process that can compile other programs in the initramfs.
func (SourceBuilder) DefaultBinaryDir ¶
func (SourceBuilder) DefaultBinaryDir() string
DefaultBinaryDir implements Builder.DefaultBinaryDir.