Documentation ¶
Overview ¶
Package gb is a tool kit for building Go packages and programs.
The executable, cmd/gb, is located in the respective subdirectory along with several plugin programs.
Index ¶
- func Build(pkgs ...*Package) error
- func Execute(a *Action) error
- func ExecuteConcurrent(a *Action, n int, interrupt <-chan struct{}) error
- func GOARCH(goarch string) func(*Context) error
- func GOOS(goos string) func(*Context) error
- func GcToolchain() func(c *Context) error
- func Gcflags(flags ...string) func(*Context) error
- func Ldflags(flags ...string) func(*Context) error
- func Tags(tags ...string) func(*Context) error
- func WithRace(c *Context) error
- func Workdir(pkg *Package) string
- type Action
- type Context
- func (c *Context) AddImporter(i Importer)
- func (c *Context) Destroy() error
- func (c *Context) IncludePaths() []string
- func (c *Context) NewPackage(p *importer.Package) (*Package, error)
- func (c *Context) Pkgdir() string
- func (c *Context) ResolvePackage(path string) (*Package, error)
- func (c *Context) Suffix() string
- func (c *Context) Workdir() string
- type Importer
- type Package
- type Project
- type Statistics
- type Toolchain
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Build ¶
Build builds each of pkgs in succession. If pkg is a command, then the results of build include linking the final binary into pkg.Context.Bindir().
func ExecuteConcurrent ¶
ExecuteConcurrent executes all actions in a tree concurrently. Each Action will wait until its dependant actions are complete.
func GcToolchain ¶
Types ¶
type Action ¶
type Action struct { // Name describes the action. Name string // Deps identifies the Actions that this Action depends. Deps []*Action // Run identifies the task that this action represents. Run func() error }
An Action describes a task to be performed and a set of Actions that the task depends on.
func BuildDependencies ¶
BuildDependencies returns a slice of Actions representing the steps required to build all dependant packages of this package.
func BuildPackage ¶
BuildPackage returns an Action representing the steps required to build this package.
func BuildPackages ¶
BuildPackages produces a tree of *Actions that can be executed to build a *Package. BuildPackages walks the tree of *Packages and returns a corresponding tree of *Actions representing the steps required to build *Package and any of its dependencies
type Context ¶
type Context struct { Project *importer.Context // TODO(dfc) this is a hack Statistics Force bool // force rebuild of packages Install bool // copy packages into $PROJECT/pkg Verbose bool // verbose output Nope bool // command specfic flag, under test it skips the execute action. // contains filtered or unexported fields }
Context represents an execution of one or more Targets inside a Project.
func NewContext ¶ added in v0.4.3
NewContext returns a new build context from this project. By default this context will use the gc toolchain with the host's GOOS and GOARCH values.
func (*Context) AddImporter ¶ added in v0.4.3
AddImporter adds an additional Importer to the Context.
func (*Context) IncludePaths ¶
IncludePaths returns the include paths visible in this context.
func (*Context) NewPackage ¶ added in v0.4.0
NewPackage creates a resolved Package for p.
func (*Context) ResolvePackage ¶
ResolvePackage resolves the package at path using the current context.
type Importer ¶ added in v0.4.3
type Importer interface { // Import attempts to resolve the package import path, path, // to an *importer.Package. Import(path string) (*importer.Package, error) }
Importer resolves package import paths to *importer.Packages.
type Package ¶
type Package struct { *Context *importer.Package TestScope bool ExtraIncludes string // hook for test Stale bool // is the package out of date wrt. its cached copy Imports []*Package }
Package represents a resolved package from the Project with respect to the Context.
type Project ¶
type Project interface { // Projectdir returns the path root of this project. Projectdir() string // Pkgdir returns the path to precompiled packages. Pkgdir() string // Bindir returns the path for compiled programs. Bindir() string // Srcdirs returns the path to the source directories. Srcdirs() []string }
Project represents a gb project. A gb project has a simlar layout to a $GOPATH workspace. Each gb project has a standard directory layout starting at the project root, which we'll refer too as $PROJECT.
$PROJECT/ - the project root $PROJECT/src/ - base directory for the source of packages $PROJECT/bin/ - base directory for the compiled binaries
func NewProject ¶
Example ¶
package main import ( "log" "path/filepath" "github.com/constabulary/gb" ) func main() { // Every project begins with a project root. // Normally you'd check this out of source control. root := filepath.Join("home", "dfc", "devel", "demo") // Create a new Project passing in the source directories // under this project's root. proj := gb.NewProject(root) // Create a new Context from the Project. A Context holds // the state of a specific compilation or test within the Project. ctx, err := gb.NewContext(proj) if err != nil { log.Fatal("Could not create new context:", err) } // Always remember to clean up your Context ctx.Destroy() }
Output:
type Statistics ¶
Statistics records the various Durations
func (*Statistics) String ¶
func (s *Statistics) String() string
func (*Statistics) Total ¶
func (s *Statistics) Total() time.Duration
type Toolchain ¶
type Toolchain interface { Gc(pkg *Package, searchpaths []string, importpath, srcdir, outfile string, files []string) error Asm(pkg *Package, srcdir, ofile, sfile string) error Pack(pkg *Package, afiles ...string) error Ld(*Package, []string, string, string) error Cc(pkg *Package, ofile string, cfile string) error // contains filtered or unexported methods }
Toolchain represents a standardised set of command line tools used to build and test Go programs.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package command holds support functions and types for writing gb and gb plugins
|
Package command holds support functions and types for writing gb and gb plugins |
gb
gb, a project based build tool for the Go programming language.
|
gb, a project based build tool for the Go programming language. |
gb-vendor
gb-vendor, a gb plugin to manage your vendored dependencies.
|
gb-vendor, a gb plugin to manage your vendored dependencies. |
gb/internal/depfile
depfile loads a file of tagged key value pairs.
|
depfile loads a file of tagged key value pairs. |
internal
|
|
debug
debug provides a light weight debug facility.
|
debug provides a light weight debug facility. |
fileutils
package fileutils provides utililty methods to copy and move files and directories.
|
package fileutils provides utililty methods to copy and move files and directories. |