bldr_platform

package
v0.53.0 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const PlatformID_DESKTOP = "desktop"

PlatformID_DESKTOP builds Go binaries for desktop platforms. Builds a desktop binary with embedded assets (i.e. a .exe). Uses the NativePlatform base type to parse the platform ID.

View Source
const PlatformID_JS = "js"

PlatformID_JS builds binaries for JavaScript environments (quickjs or WebWorker).

View Source
const PlatformID_NONE = "none"

PlatformID_NONE indicates the manifest holds static files only.

View Source
const PlatformID_WEB = "web"

PlatformID_WEB builds Go binaries targeting web browsers (js/wasm). Uses the NativePlatform base type to parse the platform ID.

View Source
const TargetID_Browser = "browser"

TargetID_Browser is the target ID for web browser environments.

View Source
const TargetID_Desktop = "desktop"

TargetID_Desktop is the target ID for native desktop applications.

Variables

View Source
var BuiltinTargets = map[string]*Target{
	TargetID_Browser: {
		ID:          TargetID_Browser,
		PlatformIDs: []string{"web/js/wasm", PlatformID_JS},
		Description: "Web browser environment (WebAssembly + JavaScript)",
	},
}

BuiltinTargets contains the predefined targets. Note: desktop target uses the host platform, computed at call time via GetBuiltinTarget.

Functions

func GetAllNativePlatformIDs

func GetAllNativePlatformIDs() []string

GetAllNativePlatformIDs returns platform IDs for all common native targets.

func GetHostPlatformID

func GetHostPlatformID() string

GetHostPlatformID returns the platform ID for the current host.

func IsWebPlatform

func IsWebPlatform(p Platform) bool

IsWebPlatform returns true if the platform targets a web browser environment. This includes web/js/wasm (WebAssembly in browser) and js (pure JavaScript).

func ListBuiltinTargetIDs

func ListBuiltinTargetIDs() []string

ListBuiltinTargetIDs returns a list of all builtin target IDs.

Types

type JsPlatform

type JsPlatform struct {
	// InputPlatformID was the parsed platform ID string, if any.
	InputPlatformID string
}

JsPlatform represents the JavaScript platform type.

func NewJsPlatform

func NewJsPlatform() *JsPlatform

NewJsPlatform constructs a new default JsPlatform.

func ParseJsPlatform

func ParseJsPlatform(str string) (*JsPlatform, error)

ParseJsPlatform parses JavaScript platform based platform ID.

func (*JsPlatform) GetBasePlatformID

func (n *JsPlatform) GetBasePlatformID() string

GetBasePlatformID returns the base platform identifier w/o arch specifics. Values: PlatformID_DESKTOP, PlatformID_JS, and PlatformID_NONE

func (*JsPlatform) GetExecutableExt

func (n *JsPlatform) GetExecutableExt() string

GetExecutableExt returns the extension used for the primary executable artifact.

func (*JsPlatform) GetInputPlatformID

func (n *JsPlatform) GetInputPlatformID() string

GetInputPlatformID returns the platform ID used when parsing. If unknown, return the output of GetPlatformID instead.

func (*JsPlatform) GetPlatformID

func (n *JsPlatform) GetPlatformID() string

GetPlatformID converts the platform into a fully qualified platform ID. There should be exactly one representation of the platform ID possible.

type NativePlatform

type NativePlatform struct {
	// GOOS is the go operating system type.
	// If empty, use the host go os.
	GOOS *string
	// GOARCH is the go architecture.
	// If empty, use the host go arch.
	GOARCH *string
	// GOARM is the Go arm version.
	// Only used if GOOS=linux and GOARCH=arm
	// If empty (zero), use v7.
	GOARM *int
	// InputPlatformID was the parsed platform ID string, if any.
	InputPlatformID string
}

NativePlatform is a base type for any go compiler based platform ID.

func ParseNativePlatform

func ParseNativePlatform(str string) (*NativePlatform, error)

ParseNativePlatform parses a Go compiler based platform ID. Accepts both "desktop/" and "web/" prefixes.

func ToNativePlatform

func ToNativePlatform(p Platform) *NativePlatform

ToNativePlatform type-asserts the platform to NativePlatform.

Returns nil if type doesn't match

func (*NativePlatform) GetBasePlatformID

func (n *NativePlatform) GetBasePlatformID() string

GetBasePlatformID returns the base platform identifier w/o arch specifics. Values: PlatformID_DESKTOP, PlatformID_WEB, PlatformID_JS

func (*NativePlatform) GetExecutableExt

func (n *NativePlatform) GetExecutableExt() string

GetExecutableExt returns the extension used for executables.

func (*NativePlatform) GetGOARCH

func (n *NativePlatform) GetGOARCH() string

GetGOARCH returns the GOARCH if set or the host GOARCH if not.

func (*NativePlatform) GetGOARM

func (n *NativePlatform) GetGOARM() int

GetGOARM returns the GOARM to use or 0 if not applicable.

func (*NativePlatform) GetGOOS

func (n *NativePlatform) GetGOOS() string

GetGOOS returns the GOOS if set or the host GOOs if not.

func (*NativePlatform) GetInputPlatformID

func (n *NativePlatform) GetInputPlatformID() string

GetInputPlatformID returns the platform ID used when parsing. If unknown, return the output of GetPlatformID instead.

func (*NativePlatform) GetPlatformID

func (n *NativePlatform) GetPlatformID() string

GetPlatformID converts the platform into a fully qualified platform ID. There should be exactly one representation of the platform ID possible. Web platforms (js/wasm) use the "web/" prefix, desktop uses "desktop/".

func (*NativePlatform) IsWebPlatform

func (n *NativePlatform) IsWebPlatform() bool

IsWebPlatform returns true if this is a web/browser platform (js/wasm or pure js).

type NonePlatform

type NonePlatform struct {
	// InputPlatformID was the parsed platform ID string, if any.
	InputPlatformID string
}

NonePlatform represents a platform with static files only.

func NewNonePlatform

func NewNonePlatform() *NonePlatform

NewNonePlatform constructs a new NonePlatform.

func ParseNonePlatform

func ParseNonePlatform(str string) (*NonePlatform, error)

ParseNonePlatform parses a none platform ID.

func (*NonePlatform) GetBasePlatformID

func (n *NonePlatform) GetBasePlatformID() string

GetBasePlatformID returns the base platform identifier w/o arch specifics. Values: PlatformID_DESKTOP, PlatformID_JS, and PlatformID_NONE

func (*NonePlatform) GetExecutableExt

func (n *NonePlatform) GetExecutableExt() string

GetExecutableExt returns the extension used for executables.

func (*NonePlatform) GetInputPlatformID

func (n *NonePlatform) GetInputPlatformID() string

GetInputPlatformID returns the platform ID used when parsing. If unknown, return the output of GetPlatformID instead.

func (*NonePlatform) GetPlatformID

func (n *NonePlatform) GetPlatformID() string

GetPlatformID converts the platform into a fully qualified platform ID. There should be exactly one representation of the platform ID possible.

type Platform

type Platform interface {
	// GetInputPlatformID returns the platform ID used when parsing.
	// If unknown, return the output of GetPlatformID instead.
	GetInputPlatformID() string
	// GetPlatformID converts the platform into a fully qualified platform ID.
	// There should be exactly one representation of the platform ID possible.
	GetPlatformID() string
	// GetBasePlatformID returns the base platform identifier w/o arch specifics.
	// Values: PlatformID_DESKTOP and PlatformID_JS
	GetBasePlatformID() string
	// GetExecutableExt returns the extension used for executables. May be empty.
	GetExecutableExt() string
}

Platform is the common interface for platform types.

func ParsePlatform

func ParsePlatform(id string) (Platform, error)

ParsePlatform parses the given platform ID. Result can be either *NativePlatform or *WebPlatform. Returns nil, err if not recognized.

type Target

type Target struct {
	// ID is the target identifier (e.g., "browser", "desktop").
	ID string
	// PlatformIDs is the ordered list of platform IDs (highest priority first).
	PlatformIDs []string
	// Description describes the target.
	Description string
}

Target represents a deployment target with prioritized platform support.

func GetBuiltinTarget

func GetBuiltinTarget(id string) *Target

GetBuiltinTarget returns a builtin target by ID. For targets that depend on the host platform (like "desktop"), this computes the correct platform IDs.

func ParseTarget

func ParseTarget(id string) (*Target, error)

ParseTarget parses a target string, supporting built-in and parameterized targets. Examples: "browser", "desktop", "desktop/darwin/arm64"

func (*Target) GetDescription

func (t *Target) GetDescription() string

GetDescription returns the target description.

func (*Target) GetID

func (t *Target) GetID() string

GetID returns the target identifier.

func (*Target) GetPlatformIDs

func (t *Target) GetPlatformIDs() []string

GetPlatformIDs returns the ordered list of platform IDs.

func (*Target) SelectPlatformForCompiler

func (t *Target) SelectPlatformForCompiler(supportedBasePlatforms []string) string

SelectPlatformForCompiler selects the best platform from the target for a compiler. supportedBasePlatforms is the list of base platform IDs the compiler supports (e.g., ["desktop"] or ["js"]). Returns the first platform ID from the target that matches a supported base platform. Returns empty string if no match found.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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