bbinternal

package
v0.0.0-...-d8fbaca Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 5, 2024 License: BSD-3-Clause Imports: 19 Imported by: 0

Documentation

Overview

Package bbinternal is the internal API for both bazel and standard Go busybox builds.

It contains exported functions that are not for user consumption and not stable.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateBBMainSource

func CreateBBMainSource(fset *token.FileSet, files []*ast.File, pkgs []string, destDir string) error

CreateBBMainSource creates a bb Go command main.go that imports all given pkgs and writes the command to destDir.

fset and files must be parsed bb template main.go, usually ./bbmain/cmd/main.go.

func ParseAST

func ParseAST(name string, files []string) (*token.FileSet, []*ast.File, []string, error)

ParseAST parses the given files for a package named name.

Only files with a matching package statement will be part of the AST returned.

func WritePkg

func WritePkg(p *packages.Package, destDir string) error

WritePkg writes p's files into destDir.

Types

type Package

type Package struct {
	// Name is the executable command name.
	//
	// In the standard Go tool chain, this is usually the base name of the
	// directory containing its source files.
	Name string

	// Pkg is the actual data about the package.
	Pkg *packages.Package
	// contains filtered or unexported fields
}

Package is a Go package.

func NewPackage

func NewPackage(name string, p *packages.Package) *Package

NewPackage creates a new Package based on an existing packages.Package.

func (*Package) PackageName

func (p *Package) PackageName() string

PackageName is teh name of the rewritten Go package.

func (*Package) Rewrite

func (p *Package) Rewrite(destDir, bbImportPath string) error

Rewrite rewrites p into destDir as a bb package, rewriting its init and main functions.

bbImportPath is the importpath to use for bbmain. bbImportPath is usually bb.u-root.com/bb/pkg/bbmain for the Go module/vendor-based compilations, but github.com/u-root/gobusybox/src/pkg/bb/bbmain for bazel-based compilations.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL