build

package
v0.5.25 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TempDir string //nolint:gochecknoglobals //no

Functions

This section is empty.

Types

type Common

type Common struct {
	CommonBase `yaml:",omitempty,inline,flow" json:",omitempty" toml:""`

	Disabled       bool     `yaml:"disabled,omitempty" json:"disabled,omitempty" toml:"disabled,omitempty"`
	KeepWorkdir    bool     `yaml:"keep-workdir,omitempty" json:"keep_workdir,omitempty" toml:"keep_workdir,omitempty"`
	UseWorkDir     string   `yaml:"use-workdir,omitempty" json:"use_work_dir,omitempty" toml:"use_work_dir,omitempty"`
	For            []string `yaml:"for,omitempty,flow" json:"for,omitempty" toml:"for,omitempty"`
	Os             []string `yaml:"os,omitempty,flow" json:"os,omitempty" toml:"os,omitempty"`
	Arch           []string `yaml:"arch,omitempty,flow" json:"arch,omitempty" toml:"arch,omitempty"`
	Goroot         string   `yaml:"goroot,omitempty,flow" json:"goroot,omitempty" toml:"goroot,omitempty"`
	PreAction      string   `yaml:"pre-action,omitempty" json:"pre_action,omitempty" toml:"pre_action,omitempty"`                   // bash script
	PostAction     string   `yaml:"post-action,omitempty" json:"post_action,omitempty" toml:"post_action,omitempty"`                // bash script
	PreActionFile  string   `yaml:"pre-action-file,omitempty" json:"pre_action_file,omitempty" toml:"pre_action_file,omitempty"`    // bash script
	PostActionFile string   `yaml:"post-action-file,omitempty" json:"post_action_file,omitempty" toml:"post_action_file,omitempty"` // bash script

	DeepReduce bool `yaml:"reduce,omitempty" json:"reduce,omitempty" toml:"reduce,omitempty"`
	Upx        Upx  `yaml:",omitempty" json:"upx,omitempty" toml:"upx,omitempty"`
}

func NewCommon

func NewCommon() *Common

func (*Common) CloneFrom

func (c *Common) CloneFrom(from *Common)

func (*Common) MergeFrom added in v0.5.7

func (c *Common) MergeFrom(from *Common)

type CommonBase

type CommonBase struct {
	OS   string `yaml:"-" json:"-" toml:"-"` // just for string template expansion
	ARCH string `yaml:"-" json:"-" toml:"-"` // just for string template expansion

	Args       []string `yaml:"args,omitempty,flow" json:"args,omitempty" toml:"args,omitempty"`
	Ldflags    []string `yaml:"ldflags,omitempty,flow" json:"ldflags,omitempty" toml:"ldflags,omitempty"`          // default ldflags is to get the smaller build for releasing
	Asmflags   []string `yaml:"asmflags,omitempty,flow" json:"asmflags,omitempty" toml:"asmflags,omitempty"`       //
	Gcflags    []string `yaml:"gcflags,omitempty,flow" json:"gcflags,omitempty" toml:"gcflags,omitempty"`          //
	Gccgoflags []string `yaml:"gccgoflags,omitempty,flow" json:"gccgoflags,omitempty" toml:"gccgoflags,omitempty"` //
	Tags       []string `yaml:"tags,omitempty,flow" json:"tags,omitempty" toml:"tags,omitempty"`                   //
	// Cgo option
	Cgo bool `yaml:",omitempty" json:"cgo,omitempty" toml:"cgo,omitempty"` //
	// Race option enables data race detection.
	//		Supported only on linux/amd64, freebsd/amd64, darwin/amd64, windows/amd64,
	//		linux/ppc64le and linux/arm64 (only for 48-bit VMA).
	Race bool `yaml:",omitempty" json:"race,omitempty" toml:"race,omitempty"` //
	// Msan option enables interoperation with memory sanitizer.
	//		Supported only on linux/amd64, linux/arm64
	//		and only with Clang/LLVM as the host C compiler.
	//		On linux/arm64, pie build mode will be used.
	Msan bool `yaml:",omitempty" json:"msan,omitempty" toml:"msan,omitempty"` //
	// Asan enables interoperation with address sanitizer.
	//		Supported only on linux/arm64, linux/amd64.
	//		Supported only on linux/amd64 or linux/arm64 and only with GCC 7 and higher
	//		or Clang/LLVM 9 and higher.
	Asan bool `yaml:",omitempty" json:"asan,omitempty" toml:"asan,omitempty"` //
	//
	Mod           string `yaml:",omitempty" json:"mod,omitempty" toml:"mod,omitempty"`                                     // -mod reaonly,vendor,mod
	Amd64         string `yaml:",omitempty" json:"goamd64,omitempty" toml:"goamd64,omitempty"`                             // GOAMD64 v1,v2,v3,v4
	Gocmd         string `yaml:",omitempty" json:"gocmd,omitempty" toml:"gocmd,omitempty"`                                 // -gocmd go
	Gen           bool   `yaml:",omitempty" json:"gen,omitempty" toml:"gen,omitempty"`                                     // go generate at first?
	Install       bool   `yaml:",omitempty" json:"install,omitempty" toml:"install,omitempty"`                             // install binary to $GOPATH/bin like 'go install' ?
	Debug         bool   `yaml:",omitempty" json:"debug,omitempty" toml:"debug,omitempty"`                                 // true to produce a larger build with debug info
	DisableResult bool   `yaml:"disable-result,omitempty" json:"disable_result,omitempty" toml:"disable_result,omitempty"` // no ll (Shell list) building result

	// -X for -ldflags,
	// -X importpath.name=value
	//    Set the value of the string variable in importpath named name to value.
	//    Note that before Go 1.5 this option took two separate arguments.
	//    Now it takes one argument split on the first = sign.
	Extends      []PackageNameValues `yaml:"extends,omitempty" json:"extends,omitempty" toml:"extends,omitempty"` //
	CmdrSpecials bool                `yaml:"cmdr,omitempty" json:"cmdr,omitempty" toml:"cmdr,omitempty"`
	CmdrVersion  string              `yaml:"cmdr-version,omitempty" json:"cmdr-version,omitempty" toml:"cmdr-version,omitempty"`
}

func (*CommonBase) CloneFrom

func (c *CommonBase) CloneFrom(from *CommonBase)

type Context

type Context struct {
	WorkDir    string
	TempDir    string
	PackageDir string

	// Output collects the target binary executable path pieces in building
	Output PathPieces

	*Common
	*Info
	*DynBuildInfo
}

func NewContext

func NewContext() *Context

func (*Context) CalcVersion added in v0.3.13

func (bc *Context) CalcVersion() (ver string)

func (*Context) FindAppName added in v0.3.11

func (bc *Context) FindAppName(knownName, knownProjectName, knownPackageName string)

type DynBuildInfo

type DynBuildInfo struct {
	ProjectName         string
	AppName             string
	Version             string // copied from Project.Version
	BgoGroupKey         string // project-group key in .bgo.yml
	BgoGroupLeadingText string // same above,
	HasGoMod            bool   //
	GoModFile           string //
	GOROOT              string // force using a special GOROOT
	Dir                 string
}

type Info

type Info struct {
	GoVersion      string // the result from 'go version'
	GoVersionMajor int    // 1
	GoVersionMinor int    // 17
	GitVersion     string // the result from `git describe --tags --abbrev=0`
	GitRevision    string // revision, git hash code, from `git rev-parse --short HEAD`
	GitSummary     string // `git describe --tags --dirty --always`
	GitDesc        string // `git log --online -1`
	BuilderComment string //
	BuildTime      string // format is like '2023-01-22T09:26:07+08:00'
	GOOS           string // a copy from runtime.GOOS
	GOARCH         string // a copy from runtime.GOARCH
	GOVERSION      string // a copy from runtime.Version()

	RandomString string
	RandomInt    int
	Serial       int64
}

func NewBuildInfo

func NewBuildInfo() *Info

func (*Info) VersionIsGreaterThan added in v0.3.13

func (c *Info) VersionIsGreaterThan(major, minor int) bool

type PackageNameValues

type PackageNameValues struct {
	Package string            `yaml:"pkg,omitempty" json:"package,omitempty" toml:"package,omitempty"`
	Values  map[string]string `yaml:"values,omitempty" json:"values,omitempty" toml:"values,omitempty"`
}

type PathPieces

type PathPieces struct {
	Path    string
	Dir     string
	Base    string
	Ext     string
	AbsPath string
}

func (*PathPieces) Set

func (s *PathPieces) Set(file string)

type TargetPlatforms

type TargetPlatforms struct {
	// OsArchMap is a map by key OS and CPUArch
	// key1: os
	// key2: arch
	OsArchMap map[string]map[string]bool `yaml:"os-arch-map"`
	// Sources is a map by key PackageName
	// key: packageName
	Sources map[string]*DynBuildInfo `yaml:"sources"`
	// Locked identify only os,arch pairs in OsArchMap should
	// be applied for building.
	Locked bool
}

func NewTargetPlatforms

func NewTargetPlatforms() *TargetPlatforms

func (*TargetPlatforms) FilterBy

func (ss *TargetPlatforms) FilterBy(scope string, forSlice, osSlice, archSlice []string)

func (*TargetPlatforms) Init added in v0.3.1

func (ss *TargetPlatforms) Init() (err error)

func (*TargetPlatforms) SetOsArch

func (ss *TargetPlatforms) SetOsArch(os, arch string)

type Upx added in v0.5.0

type Upx struct {
	Enable bool     `yaml:",omitempty" json:"enable,omitempty" toml:"enable,omitempty"`
	Params []string `yaml:",omitempty" json:"params,omitempty" toml:"params,omitempty"`
}

Upx params package.

Jump to

Keyboard shortcuts

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