cross

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 31, 2019 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTooManyArguments  = errors.New("too many arguments")
	ErrMissingGoFile     = errors.New("missing target .go file")
	ErrUnexpectedParams  = errors.New("unexpected list of parameters")
	ErrNoMatchedPlatform = errors.New("no matched platform")
)

Here defines a set of standard errors

View Source
var CmdCross = &cobra.Command{
	Use:   "cross [common go build flags] [file] [darwin|linux|windows|freebsd|netbsd|all] [amd64|386|arm|s390x|mips|mipsle|mips64|mips64le|all]",
	Short: "agile and fast cross compiling",
	Long: `
Usage:
	gos cross [common go build flags] [-e] [go file] [os] [arch]

	[common go build flags] you can use any standard flag for go build here, such as /-tags="..."/-a/-o/..., as you would with native go build
	[-e] when you specify -e, compilation errors will be printed
	[file] the go file you wanna to build
	[os] the OS such as linux/darwin/windows/freebsd/netbsd/openbsd/android/dragonfly/nacl/solaris/plan9, you can also use "all" to compile all OS
	[arch] the Arch such as amd64/386/arm/arm64/s390x/mips/mipsle/mips64/mips64le, you can also use "all" to compile all Arch

	- Compile all platform
	gos cross main.go all all

	- Compile all linux arch
	gos cross main.go linux all

	- Compile windows/amd64
	gos cross main.go windows amd64

	- Compile with standard go build flags
	gos cross -tags="prod" -ldflags="-s -w" -a main.go all all

	- Compile with error info printed
	gos cross -e main.go all all
	`,
	DisableFlagParsing: true,
}

CmdCross is the command line for cross compilation

Functions

func Run

func Run(cmd *cobra.Command, args []string)

Run command

Types

type Options

type Options struct {

	// * Cross will parse an -e identifier to determine
	// * if a compilation error message needs to be printed. The default is not to print.
	StandardGO []string

	Output  string
	Package string
	Platform
	// * ShowErr will be true when the -e identifier is present
	ShowErr bool
	// contains filtered or unexported fields
}

Options defines the structure of compilation options

func NewOptions

func NewOptions(args []string) (*Options, error)

NewOptions is used to parse cmd args

func (*Options) GetCompileWorkhorse

func (o *Options) GetCompileWorkhorse() ([]*Workhorse, error)

GetCompileWorkhorse is used to get all compilation tasks

type Platform

type Platform struct {
	OS   string
	Arch string
}

Platform defines the compilation platform

func (*Platform) String

func (p *Platform) String() string

type Platforms

type Platforms []Platform

Platforms defines a set of compilation platforms

func (Platforms) FilterByArch

func (p Platforms) FilterByArch(arch string) (ps Platforms)

FilterByArch filters the platform by type of arch

func (Platforms) FilterByOS

func (p Platforms) FilterByOS(os string) (ps Platforms)

FilterByOS filters the platform by type of OS

type Workhorse

type Workhorse struct {
	Package    string
	StandardGO []string
	Output     string
	Platform
}

Workhorse is a compilation unit

func (*Workhorse) Compile

func (h *Workhorse) Compile() error

Compile is the highlight

func (*Workhorse) GetCGOEnv

func (h *Workhorse) GetCGOEnv() string

GetCGOEnv is used to determine whether to enable CGO when there is no corresponding environment variable.

func (*Workhorse) GetRealOutput

func (h *Workhorse) GetRealOutput() (string, error)

GetRealOutput is used to generate the real output address

Jump to

Keyboard shortcuts

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