build

package
v0.0.0-...-f8c0f81 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2011 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Overview

Package build provides tools for building Go packages.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound     = os.NewError("go/build: package could not be found locally")
	ErrTreeNotFound = os.NewError("go/build: no valid GOROOT or GOPATH could be found")
)
View Source
var DefaultContext = Context{
	envOr("GOARCH", runtime.GOARCH),
	envOr("GOOS", runtime.GOOS),
}

The DefaultContext is the default Context for builds. It uses the GOARCH and GOOS environment variables if set, or else the compiled code's GOARCH and GOOS.

View Source
var Path []*Tree

Path is a validated list of Trees derived from $GOROOT and $GOPATH at init.

Functions

func ArchChar

func ArchChar(goarch string) (string, os.Error)

ArchChar returns the architecture character for the given goarch. For example, ArchChar("amd64") returns "6".

Types

type Cmd

type Cmd struct {
	Args   []string // command-line
	Stdout string   // write standard output to this file, "" is passthrough
	Dir    string   // working directory
	Env    []string // environment
	Input  []string // file paths (dependencies)
	Output []string // file paths
}

A Cmd describes an individual build command.

func (*Cmd) Run

func (c *Cmd) Run() os.Error

Run executes the Cmd.

func (*Cmd) String

func (c *Cmd) String() string

type Context

type Context struct {
	GOARCH string // target architecture
	GOOS   string // target operating system

}

A Context specifies the supporting context for a build.

func (*Context) ScanDir

func (ctxt *Context) ScanDir(dir string, allowMain bool) (info *DirInfo, err os.Error)

ScanDir returns a structure with details about the Go content found in the given directory. The file lists exclude:

  • files in package main (unless allowMain is true)
  • files in package documentation
  • files ending in _test.go
  • files starting with _ or .

type DirInfo

type DirInfo struct {
	GoFiles      []string // .go files in dir (excluding CgoFiles)
	CgoFiles     []string // .go files that import "C"
	CFiles       []string // .c files in dir
	SFiles       []string // .s files in dir
	Imports      []string // All packages imported by GoFiles
	TestImports  []string // All packages imported by (X)TestGoFiles
	PkgName      string   // Name of package in dir
	TestGoFiles  []string // _test.go files in package
	XTestGoFiles []string // _test.go files outside package
}

func ScanDir

func ScanDir(dir string, allowMain bool) (info *DirInfo, err os.Error)

ScanDir calls DefaultContext.ScanDir.

func (*DirInfo) IsCommand

func (d *DirInfo) IsCommand() bool

type Script

type Script struct {
	Cmd          []*Cmd
	Input        []string
	Intermediate []string
	Output       []string
}

A Script describes the build process for a Go package. The Input, Intermediate, and Output fields are lists of absolute paths.

func Build

func Build(tree *Tree, pkg string, info *DirInfo) (*Script, os.Error)

Build produces a build Script for the given package.

func (*Script) Clean

func (s *Script) Clean() (err os.Error)

Clean removes the Script's Intermediate files. It tries to remove every file and returns the first error it encounters.

func (*Script) Nuke

func (s *Script) Nuke() (err os.Error)

Nuke removes the Script's Intermediate and Output files. It tries to remove every file and returns the first error it encounters.

func (*Script) Run

func (s *Script) Run() os.Error

Run runs the Script's Cmds in order.

func (*Script) Stale

func (s *Script) Stale() bool

Stale returns true if the build's inputs are newer than its outputs.

type Tree

type Tree struct {
	Path   string
	Goroot bool
}

Tree describes a Go source tree, either $GOROOT or one from $GOPATH.

func FindTree

func FindTree(path string) (tree *Tree, pkg string, err os.Error)

FindTree takes an import or filesystem path and returns the tree where the package source should be and the package import path.

func (*Tree) BinDir

func (t *Tree) BinDir() string

BinDir returns the tree's binary executable directory.

func (*Tree) HasPkg

func (t *Tree) HasPkg(pkg string) bool

HasPkg returns whether the given package's object file can be found inside this Tree.

func (*Tree) HasSrc

func (t *Tree) HasSrc(pkg string) bool

HasSrc returns whether the given package's source can be found inside this Tree.

func (*Tree) PkgDir

func (t *Tree) PkgDir() string

PkgDir returns the tree's package object directory.

func (*Tree) SrcDir

func (t *Tree) SrcDir() string

SrcDir returns the tree's package source directory.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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