Documentation
¶
Overview ¶
Package dopler is Dopler as a Go library: build, package and install programs from a Go build script in any Go project.
A build script, e.g. cmd/build/main.go:
package main
import "github.com/mefoxdev/dopler-installer"
func main() {
p := dopler.NewProject("myapp", "1.0.0")
p.GoPackage = "./cmd/myapp"
p.Manifest.License = "Proprietary"
p.Manifest.Targets = map[string]dopler.Target{
"linux/amd64": {}, "windows/amd64": {}, "darwin/arm64": {},
}
dopler.Main(p) // flags: -t -format -o -installer -no-build
}
Run it with "go run ./cmd/build -format appimage,dop". Per-OS steps go into hooks registered with Project.OnBuild, which makes cmd/build/linux.go, windows.go and darwin.go natural places for them.
The package pulls in the Linux, Windows and macOS packages, so every format and platform is available. It needs only the Go toolchain.
Index ¶
- Constants
- func FormatNames() []string
- func InstallBinary(src, dir string) (string, error)
- func Main(p *Project)
- func PackageName(m *Manifest, target string) string
- func RunUI(spec UISpec, h UIHandler) error
- func Uninstall(dir string, progress Progress) error
- func UninstallBinary(path string) error
- type BuildContext
- type BuildInput
- type Format
- type HookFunc
- type InstallOptions
- type Manifest
- type Package
- type Progress
- type Project
- type Receipt
- type RunOptions
- type Target
- type UI
- type UIAction
- type UIField
- type UIHandler
- type UISpec
Constants ¶
const ManifestFile = core.FileName
ManifestFile is the default manifest file name.
Variables ¶
This section is empty.
Functions ¶
func InstallBinary ¶
InstallBinary copies a bare binary or AppImage into dir (empty = the platform's bin directory).
func Main ¶
func Main(p *Project)
Main is a ready-made command line for a build script: it parses flags, runs the project and prints the artifacts. It exits the process on error.
-t os/arch,... targets (default: all in the manifest, or the host) -format a,b output formats (default dop) -o dir output directory -installer also build self-extracting installers -no-build do not compile, reuse the staging dirs
func PackageName ¶
PackageName is the file name of the .dop for a target.
func UninstallBinary ¶
UninstallBinary removes a file installed by InstallBinary.
Types ¶
type BuildContext ¶
type BuildContext struct {
Project *Project
Target string // "os/arch"
GOOS string
GOARCH string
Dir string // directory whose contents will be packaged
Exec string // main executable, relative to Dir
}
BuildContext is passed to build hooks.
func (*BuildContext) GoBuild ¶
func (c *BuildContext) GoBuild(pkg, name, ldflags string, goFlags ...string) error
GoBuild compiles the Go package pkg (relative to the project's BaseDir) for this target into ctx.Dir as name (".exe" is added on Windows). Extra ldflags are appended to Project.Ldflags; use it from hooks to build several programs into one package, or to vary flags per OS.
type HookFunc ¶
type HookFunc func(ctx *BuildContext) error
HookFunc runs after a target was compiled and before it is packaged. Use it to add files (assets, licenses, config) to ctx.Dir.
type InstallOptions ¶
type InstallOptions = core.InstallOptions
InstallOptions tunes Package.Install.
type Manifest ¶
Manifest describes a program (the contents of dopler.json).
func LoadManifest ¶
LoadManifest reads and validates a dopler.json.
type Package ¶
Package is an opened .dop package or self-extracting installer.
func OpenPackage ¶
OpenPackage opens a .dop file or a self-extracting installer.
type Project ¶
type Project struct {
// Manifest describes the program. Targets may be empty (then the
// requested targets, or the host, are used) and individual Target
// values may be empty when GoPackage is set.
Manifest *Manifest
// BaseDir resolves relative paths; default ".".
BaseDir string
// OutDir receives the artifacts; default "out".
OutDir string
// BuildDir holds per-target staging dirs and stubs; default ".dopler".
BuildDir string
// GoPackage, when set (e.g. "./cmd/myapp"), is compiled with the Go
// toolchain for every target. When empty, Manifest must name existing
// directories.
GoPackage string
// Ldflags and GoFlags are passed to "go build".
Ldflags string
GoFlags []string
// Env is added to the environment of "go build". CGO_ENABLED defaults
// to 0 so cross-compilation needs no C compiler.
Env []string
// contains filtered or unexported fields
}
Project is a build: a manifest plus how to produce the files to package.
func NewProject ¶
NewProject returns a project for a program called name.
type RunOptions ¶
type RunOptions struct {
Targets []string // "os/arch"; empty = all targets of the manifest (or the host)
Formats []string // empty = ["dop"]; see FormatNames
Installer bool // also build self-extracting installers
SkipBuild bool // do not run "go build" (use what is in the staging dirs)
}
RunOptions selects what Project.Run does.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
cli
command
Command cli (built as "dopler") is the command-line client:
|
Command cli (built as "dopler") is the command-line client: |
|
installer
command
Command installer (built as "dopler-installer") is the graphical installer.
|
Command installer (built as "dopler-installer") is the graphical installer. |
|
packer
command
Command packer (built as "dopler-packer") is the graphical packager: pick a manifest and an output folder, get .dop packages and installers.
|
Command packer (built as "dopler-packer") is the graphical packager: pick a manifest and an output folder, get .dop packages and installers. |
|
examples
|
|
|
build
command
Example build script.
|
Example build script. |
|
build/cmd/hello
command
|
|
|
internal
|
|
|
core
Package core holds the OS-independent part of Dopler: the manifest, the .dop package format, install/uninstall logic, the platform registry and the UI contract implemented natively by each OS package.
|
Package core holds the OS-independent part of Dopler: the manifest, the .dop package format, install/uninstall logic, the platform registry and the UI contract implemented natively by each OS package. |
|
linux
Package linux holds the Linux-specific part of Dopler: install paths, desktop-menu integration and the native (GTK) GUI.
|
Package linux holds the Linux-specific part of Dopler: install paths, desktop-menu integration and the native (GTK) GUI. |
|
macos
Package macos holds the macOS-specific part of Dopler: install paths, command-line integration and the native (Cocoa) GUI.
|
Package macos holds the macOS-specific part of Dopler: install paths, command-line integration and the native (Cocoa) GUI. |
|
windows
Package windows holds the Windows-specific part of Dopler: install paths, Add/Remove Programs integration and the native (Win32) GUI.
|
Package windows holds the Windows-specific part of Dopler: install paths, Add/Remove Programs integration and the native (Win32) GUI. |