cfgtypes

package
v0.9.7 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultBuiltInIcon = "xgo-pack:default-icon"
View Source
const DefaultSchema = "https://raw.githubusercontent.com/cardinalby/xgo-pack/master/config_schema/config.schema.v1.json"

Variables

This section is empty.

Functions

This section is empty.

Types

type ArchTarget

type ArchTarget interface {
	ShouldKeepBin() bool
	ShouldBuildBin() bool
	GetOutDir() string
	SetOutDir(outDir string)
}

type Config

type Config struct {
	// Used for JSON schema
	Schema string `json:"$schema,omitempty"`
	// Presets is a preset config names list that will be used as a base for the config.
	// Presets will be applied in the order of appearance in the list, so the last one will override the previous ones.
	Presets []PresetName `json:"presets,omitempty"`
	// Root path of the project. Absolute or relative to working directory.
	Root string `json:"root,omitempty"`
	// DistDir is path (relative to root) of a directory for final build artifacts.
	// If not set, "dist" dir will be used
	DistDir string `json:"dist_dir,omitempty"`
	// TmpDir is path (relative to root) of a temp directory for temporary build artifacts. If not set, a temporary
	// directory will be created in DistDir
	TmpDir string `json:"tmp_dir,omitempty"`
	// Src sets paths of source files and an icon
	Src Src `json:"src,omitempty"`
	// XGoConfig is a config for xgo tool
	XGo config.XGoConfig `json:"xgo,omitempty"`
	// Targets is a config for building targets
	Targets Targets `json:"targets,omitempty"`
}

func (Config) GetDistDirPath

func (c Config) GetDistDirPath() string

func (Config) GetTmpDirPath

func (c Config) GetTmpDirPath() string

type OsTargets

type OsTargets interface {
	GetArches() map[consts.Arch]ArchTarget
	GetCommonCfg() TargetsCommon
	SetCommonCfg(cfg TargetsCommon)
}

type PresetName

type PresetName string

type Src

type Src struct {
	MainPkg string `json:"main_pkg,omitempty"`
	// Icon is a path to the icon file relative to Root. It will be converted to needed formats via imagemagick,
	// so for psd files you can use icon.psd[0] to convert all layers
	Icon string `json:"icon,omitempty"`
}

type TargetLinux

type TargetLinux struct {
	// Common will be used as defaults for all architectures
	Common TargetLinuxCommon `json:"common,omitempty"`
	Arm64  TargetLinuxArch   `json:"arm64,omitempty"`
	Amd64  TargetLinuxArch   `json:"amd64,omitempty"`
}

func (*TargetLinux) GetArches

func (t *TargetLinux) GetArches() map[consts.Arch]ArchTarget

func (*TargetLinux) GetCommonCfg

func (t *TargetLinux) GetCommonCfg() TargetsCommon

func (*TargetLinux) GetLinuxArches

func (t *TargetLinux) GetLinuxArches() map[consts.Arch]*TargetLinuxArch

func (*TargetLinux) SetCommonCfg

func (t *TargetLinux) SetCommonCfg(cfg TargetsCommon)

type TargetLinuxArch

type TargetLinuxArch struct {
	// OutDir is a path relative to Config.DistDir where the final artifacts will be placed
	// If not set, "linux_[arch]" will be used
	OutDir string `json:"out_dir,omitempty"`
	// Defines if binary should be built
	// If empty, the binary will be created only if it's needed for deb package
	BuildBin *bool `json:"build_bin,omitempty"`
	// Defines if deb package should be built
	// If empty, the deb package will not be created
	BuildDeb *bool `json:"build_deb,omitempty"`
}

func (*TargetLinuxArch) GetOutDir

func (t *TargetLinuxArch) GetOutDir() string

func (*TargetLinuxArch) SetOutDir

func (t *TargetLinuxArch) SetOutDir(outDir string)

func (*TargetLinuxArch) ShouldBuildBin

func (t *TargetLinuxArch) ShouldBuildBin() bool

func (*TargetLinuxArch) ShouldBuildDeb

func (t *TargetLinuxArch) ShouldBuildDeb() bool

func (*TargetLinuxArch) ShouldKeepBin

func (t *TargetLinuxArch) ShouldKeepBin() bool

type TargetLinuxCommon

type TargetLinuxCommon struct {
	TargetsCommon `json:",inline"`
	// Deb is a config for deb package
	Deb TargetLinuxDeb `json:"deb,omitempty"`
}

type TargetLinuxDeb

type TargetLinuxDeb struct {
	// Name of the resulting deb package file relative to arch `out_dir`
	// If empty, [common.product_name].deb will be used
	DebName string `json:"deb_name,omitempty"`
	// Path to custom nfpm config relative to the root.
	// If set, all other fields will be ignored and nfpm will be used with this config
	// and "XGO_PACK_" env variables that can be used in config fields as placeholders:
	// ${XGO_PACK_DASHED_PRODUCT_NAME}, ${XGO_PACK_ARCH}, ${XGO_PACK_VERSION}
	CustomNfpmConfig string `json:"custom_nfpm_config,omitempty"`
	// If empty, common.ProductName will be used.
	// For allowed format see https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-source
	// The string will be lower-cased and not supported symbols will be replaced with '-'
	Name string `json:"name,omitempty"`
	// If empty, "default" will be used
	Section string `json:"section,omitempty"`
	// Recommended to be filled. If empty common.identifier without last part will be used
	Maintainer  string `json:"maintainer,omitempty"`
	Description string `json:"description,omitempty"`
	Vendor      string `json:"vendor,omitempty"`
	Homepage    string `json:"homepage,omitempty"`
	License     string `json:"license,omitempty"`
	// Additional files to include to the package (local path -> destination abs path)
	Contents map[string]string `json:"contents,omitempty"`
	// Destination path for bin file in the package (as absolute path in the dest system)
	// If empty, "/usr/bin/{common.bin_name}" will be used
	DstBinPath string `json:"dst_bin_path,omitempty"`
	// desktop entry file options
	DesktopEntry TargetLinuxDebDesktopEntry `json:"desktop_entry,omitempty"`
}

type TargetLinuxDebDesktopEntry

type TargetLinuxDebDesktopEntry struct {
	// Defines if desktop entry should be added to the package
	// If empty, `true` will be used
	AddDesktopEntry *bool `json:"add_desktop_entry,omitempty"`
	// Defines if icon should be added to the package
	// If empty, `true` will be used (only if add_desktop_entry is true)
	AddIcon *bool `json:"add_icon,omitempty"`
	// If empty, "/usr/share/icons/[common.identifierProductName].png" will be used
	DstIconPath string `json:"dst_icon_path,omitempty"`
	// Desktop entry name.
	// If empty, common.product_name will be used
	Name string `json:"name,omitempty"`
	// Desktop entry type. If empty, "Application" will be used
	Type string `json:"type,omitempty"`
	// Desktop entry Terminal key.
	// If empty, `true` will be used
	Terminal *bool `json:"terminal,omitempty"`
	// Desktop entry NoDisplay key.
	// If empty, `false` will be used
	NoDisplay *bool `json:"no_display,omitempty"`
}

type TargetMacos

type TargetMacos struct {
	// Will be used as defaults for all architectures
	Common TargetMacosCommon `json:"common,omitempty"`
	Arm64  TargetMacosArch   `json:"arm64,omitempty"`
	Amd64  TargetMacosArch   `json:"amd64,omitempty"`
}

func (*TargetMacos) GetArches

func (t *TargetMacos) GetArches() map[consts.Arch]ArchTarget

func (*TargetMacos) GetCommonCfg

func (t *TargetMacos) GetCommonCfg() TargetsCommon

func (*TargetMacos) GetMacosArches

func (t *TargetMacos) GetMacosArches() map[consts.Arch]*TargetMacosArch

func (*TargetMacos) SetCommonCfg

func (t *TargetMacos) SetCommonCfg(cfg TargetsCommon)

func (*TargetMacos) ShouldBuildAnyBundle

func (t *TargetMacos) ShouldBuildAnyBundle() bool

type TargetMacosArch

type TargetMacosArch struct {
	// OutDir is a path relative to Config.DistDir where the final artifacts will be placed
	// If not set, "macos_[arch]" will be used
	OutDir string `json:"out_dir,omitempty"`
	// Defines if binary should be built.
	// If false, the binary will be built only in case it's required to build bundle or dmg.
	// Temporary path will be used in this case.
	BuildBin *bool `json:"build_bin,omitempty"`
	// Defines if app bundle should be built.
	// If false, the bundle will be created only in case it's required to build dmg.
	// Temporary path will be used in this case.
	BuildBundle *bool `json:"build_bundle,omitempty"`
	// Defines if dmg should be built.
	// If empty, the dmg will not be created
	BuildDmg *bool `json:"build_dmg,omitempty"`
}

func (*TargetMacosArch) GetOutDir

func (t *TargetMacosArch) GetOutDir() string

func (*TargetMacosArch) SetOutDir

func (t *TargetMacosArch) SetOutDir(outDir string)

func (*TargetMacosArch) ShouldBuildBin

func (t *TargetMacosArch) ShouldBuildBin() bool

func (*TargetMacosArch) ShouldBuildBundle

func (t *TargetMacosArch) ShouldBuildBundle() bool

func (*TargetMacosArch) ShouldBuildDmg

func (t *TargetMacosArch) ShouldBuildDmg() bool

func (*TargetMacosArch) ShouldKeepBin

func (t *TargetMacosArch) ShouldKeepBin() bool

func (*TargetMacosArch) ShouldKeepBundle

func (t *TargetMacosArch) ShouldKeepBundle() bool

type TargetMacosCommon

type TargetMacosCommon struct {
	TargetsCommon `json:",inline"`
	Codesign      TargetMacosCommonCodesign `json:"codesign,omitempty"`
	Bundle        TargetMacosCommonBundle   `json:"bundle,omitempty"`
	Dmg           TargetMacosCommonDmg      `json:"dmg,omitempty"`
}

type TargetMacosCommonBundle

type TargetMacosCommonBundle struct {
	// BundleName is a name of the resulting app bundle relative to TargetMacosArch.OutDir.
	// If empty, "[targets.common.product_name].app" will be used
	BundleName string `json:"bundle_name,omitempty"`
	// HideInDock sets the plist flag in the app bundle to hide the app in dock
	HideInDock *bool `json:"hide_in_dock,omitempty"`
}

TargetMacosCommonBundle is an arches common settings for MacOS bundle

type TargetMacosCommonCodesign added in v0.9.7

type TargetMacosCommonCodesign struct {
	// Use codesign tool to sign a binary and a bundle. Default is true.
	// By default, self-signed certificate will be used.
	// rcodesign.toml in root dir can be used to configure custom options.
	Sign *bool `json:"sign,omitempty"`
}

TargetMacosCommonCodesign is options for rcodesign tool run against binary and bundle

type TargetMacosCommonDmg

type TargetMacosCommonDmg struct {
	// DmgName is a name of the resulting dmg file relative to TargetMacosArch.OutDir.
	// If empty, "[targets.common.product_name].dmg" will be used
	DmgName string `json:"dmg_name,omitempty"`
	// AddApplicationsSymlink is a flag to add a symlink to the /Applications folder in the dmg
	// If not set, true will be used
	AddApplicationsSymlink *bool `json:"add_applications_symlink,omitempty"`
}

TargetMacosCommonDmg is an arches common settings for MacOS dmg

type TargetWindows

type TargetWindows struct {
	// Common will be used as defaults for all architectures
	Common TargetWindowsCommon `json:"common,omitempty"`
	Amd64  TargetWindowsArch   `json:"amd64,omitempty"`
}

func (*TargetWindows) GetArches

func (t *TargetWindows) GetArches() map[consts.Arch]ArchTarget

func (*TargetWindows) GetCommonCfg

func (t *TargetWindows) GetCommonCfg() TargetsCommon

func (*TargetWindows) GetWinArches

func (t *TargetWindows) GetWinArches() map[consts.Arch]*TargetWindowsArch

func (*TargetWindows) SetCommonCfg

func (t *TargetWindows) SetCommonCfg(cfg TargetsCommon)

func (*TargetWindows) ShouldBuildAnySyso

func (t *TargetWindows) ShouldBuildAnySyso() bool

type TargetWindowsArch

type TargetWindowsArch struct {
	// OutDir is a path relative to Config.DistDir where the final artifacts will be placed
	// If not set, "windows_[arch]" will be used
	OutDir string `json:"out_dir,omitempty"`
	// BuildSyso defines if .syso file should be built.
	// If false, the .syso file will be built only in case it's required to build binary
	// Temporary path will be used in this case.
	// To keep the .syso file, set it to true
	BuildSyso *bool `json:"build_syso,omitempty"`
	// Defines if binary should be built
	BuildBin *bool `json:"build_bin,omitempty"`
}

func (*TargetWindowsArch) GetOutDir

func (t *TargetWindowsArch) GetOutDir() string

func (*TargetWindowsArch) SetOutDir

func (t *TargetWindowsArch) SetOutDir(outDir string)

func (*TargetWindowsArch) ShouldBuildBin

func (t *TargetWindowsArch) ShouldBuildBin() bool

func (*TargetWindowsArch) ShouldBuildSyso

func (t *TargetWindowsArch) ShouldBuildSyso() bool

func (*TargetWindowsArch) ShouldKeepBin

func (t *TargetWindowsArch) ShouldKeepBin() bool

func (*TargetWindowsArch) ShouldKeepSyso

func (t *TargetWindowsArch) ShouldKeepSyso() bool

type TargetWindowsCommon

type TargetWindowsCommon struct {
	TargetsCommon `json:",inline"`
}

type Targets

type Targets struct {
	// Common will be used as defaults for all other targets
	Common  TargetsCommon `json:"common,omitempty"`
	Windows TargetWindows `json:"windows,omitempty"`
	Macos   TargetMacos   `json:"macos,omitempty"`
	Linux   TargetLinux   `json:"linux,omitempty"`
}

func (*Targets) GetOsArches

func (t *Targets) GetOsArches() map[consts.Os]OsTargets

func (*Targets) GetOsCommonCfg

func (t *Targets) GetOsCommonCfg(os consts.Os) *TargetsCommon

type TargetsCommon

type TargetsCommon struct {
	// ProductName is a human-readable name of the product. Is used in MacOS app bundle, dmg and Windows manifest
	// If not set, the last part of module name will be used
	ProductName string `json:"product_name,omitempty"`
	// Version is a version of the app. It's used in MacOS app bundle and Windows manifest
	// If not set, "1.0.0" will be used
	Version string `json:"version,omitempty"`
	// Identifier is a unique identifier for the app (used in MacOS bundle plist and Windows manifest),
	// usually in reverse domain notation e.g. com.example.myapp
	// If not set, the reversed module name will be used
	Identifier string `json:"identifier,omitempty"`
	// Copyright is a copyright string (used in MacOS bundle plist and deb package)
	// If not set, the "© [current_year], [identifier without the last part]" will be used
	Copyright string `json:"copyright,omitempty"`
	// HighDpi is a flag to enable high dpi support on Windows and MacOS
	HighDpi *bool `json:"high_dpi,omitempty"`
	// Arguments of go build command
	GoBuild config.TargetBuildConfig `json:"go_build,omitempty"`
	// The name of the resulting binary file. For Windows '.exe' extension will be added automatically
	// If not set, the last part of the main package path will be used
	BinName string `json:"bin_name,omitempty"`
}

type XGoConfig

type XGoConfig struct {
	// Go release to use for cross compilation
	GoVersion string `json:"go_version,omitempty"`
	// Set a Global Proxy for Go Modules
	GoProxy string `json:"go_proxy,omitempty"`
	Verbose *bool  `json:"verbose,omitempty"`
}

Jump to

Keyboard shortcuts

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