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
- type Action
- type Context
- 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
Statistics
Force bool // force rebuild of packages
Install bool // copy packages into $PROJECT/pkg
Verbose bool // verbose output
Nope bool // command specific 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) 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) (*build.Package, error)
}
Importer resolves package import paths to *importer.Packages.
type Package ¶
type Package struct {
*Context
*build.Package
TestScope bool
NotStale bool // this package _and_ all its dependencies are not stale
Main bool // is this a command
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
// contains filtered or unexported methods
}
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()
}
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, files []string) error
Asm(pkg *Package, ofile, sfile string) error
Pack(pkg *Package, afiles ...string) error
Ld(*Package) 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
command
gb, a project based build tool for the Go programming language.
|
gb, a project based build tool for the Go programming language. |
|
gb-vendor
command
gb-vendor, a gb plugin to manage your vendored dependencies.
|
gb-vendor, a gb plugin to manage your vendored dependencies. |
|
internal
|
|
|
debug
debug provides a light weight debug facility.
|
debug provides a light weight debug facility. |
|
depfile
Package depfile loads a file of tagged key value pairs.
|
Package depfile loads a file of tagged key value pairs. |
|
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. |