xcelerate

package
v3.2.3 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ActivateXcodeSuccessful = "✅ Bitrise Build Cache for Xcode activated"
	AddXcelerateToPath      = "ℹ️ To start building, run `export PATH=~/.bitrise-xcelerate/bin:$PATH` or restart your terminal."
	ErrFmtCreateXcodeConfig = "failed to create Xcode config: %w"
)
View Source
const (
	DefaultXcodePath = "/usr/bin/xcodebuild"
	DefaultXcrunPath = "/usr/bin/xcrun"

	ErrFmtCreateConfigFile = `failed to create xcelerate config file: %w`
	ErrFmtEncodeConfigFile = `failed to encode xcelerate config file: %w`
	ErrFmtCreateFolder     = `failed to create .xcelerate folder (%s): %w`
	ErrNoAuthConfig        = "resolve auth config: %w"
)
View Source
const (
	BinDir              = "bin"
	ErrFmtDetermineHome = `could not determine home: %w`
)
View Source
const EnvInactivityTimeout = "TEST_BITRISE_XCELERATE_INACTIVITY_TIMEOUT"

EnvInactivityTimeout overrides the xcelerate proxy inactivity window that triggers a slim invocation emit. Value is a time.ParseDuration string. Test-only knob: sole caller is the e2e-xcode-wrapper-watcher-race workflow, which forces slim-emit slow so the watcher's poll observes the manifest first.

View Source
const EnvProxySocketPath = "BITRISE_XCELERATE_PROXY_SOCKET_PATH"

EnvProxySocketPath overrides the default xcelerate proxy socket location when set.

Variables

This section is empty.

Functions

func Activate

func Activate(
	ctx context.Context,
	logger log.Logger,
	osProxy utils.OsProxy,
	commandFunc utils.CommandFunc,
	encoderFactory utils.EncoderFactory,
	decoderFactory utils.DecoderFactory,
	activateXcodeParams Params,
	envs map[string]string,
) error

Activate creates the Xcode build cache configuration, copies the CLI binary, and sets up the xcodebuild wrapper script.

func ApplyBenchmarkPhase

func ApplyBenchmarkPhase(
	params *Params,
	logger log.Logger,
	benchmarkProvider common.BenchmarkPhaseProvider,
	metadata common.CacheConfigMetadata,
	exporter EnvExporter,
)

ApplyBenchmarkPhase queries the benchmark phase and overrides xcode params accordingly. Baseline phase disables cache. The phase is exported as BITRISE_BUILD_CACHE_BENCHMARK_PHASE_XCODE env var and written to ~/.local/state/xcelerate/benchmark/benchmark-phase-xcode.json as fallback. The user-facing log line is emitted once by common.LogBenchmarkSummary at the end of activation, not from this function.

func ConfigFile

func ConfigFile(osProxy utils.OsProxy) string

ConfigFile returns the absolute path of the xcelerate config.json.

func DirPath

func DirPath(osProxy utils.OsProxy) string

DirPath returns the xcelerate root dir (~/.bitrise-xcelerate) using osProxy's home; falls back to working dir / executable dir / "." when home cannot be resolved.

func PathFor

func PathFor(osProxy utils.OsProxy, subpath string) string

func ResolveProxySocketPath

func ResolveProxySocketPath(override string, envs map[string]string, osProxy utils.OsProxy) string

ResolveProxySocketPath returns the proxy unix socket path in the same order activate uses: explicit override → BITRISE_XCELERATE_PROXY_SOCKET_PATH env var → <temp-dir>/xcelerate-proxy.sock.

Types

type Config

type Config struct {
	ProxyVersion    string `json:"proxyVersion"`
	ProxySocketPath string `json:"proxySocketPath"`
	// ConfigVersion is the semver of this config's schema. Refresh nudges only when this bumps.
	ConfigVersion string `json:"configVersion,omitempty"`
	// WrittenAt records when the config was last (re-)written by activate.
	WrittenAt              time.Time `json:"writtenAt,omitzero"`
	WrapperVersion         string    `json:"wrapperVersion"`
	OriginalXcodebuildPath string    `json:"originalXcodebuildPath"`
	OriginalXcrunPath      string    `json:"originalXcrunPath"`
	BuildCacheEnabled      bool      `json:"buildCacheEnabled"`
	BuildCacheSkipFlags    bool      `json:"buildCacheSkipFlags"`
	DisablePrefixMapping   bool      `json:"disablePrefixMapping,omitempty"`
	BuildCacheEndpoint     string    `json:"buildCacheEndpoint"`
	PushEnabled            bool      `json:"pushEnabled"`
	DebugLogging           bool      `json:"debugLogging,omitempty"`
	Silent                 bool      `json:"silent,omitempty"`
	XcodebuildTimestamps   bool      `json:"xcodebuildTimestamps,omitempty"`
	// AuthConfig is sourced from the multiplatform analytics config at runtime
	// (single canonical source for auth credentials on disk). The JSON tag is
	// preserved for read-side backwards compatibility with older xcelerate
	// configs that still have `authConfig` on disk from a previous CLI version;
	// Save zeroes it before writing and `omitzero` keeps it out of the file.
	AuthConfig           common.CacheAuthConfig `json:"authConfig,omitzero"`
	ExternalAppID        string                 `json:"externalAppId,omitempty"`
	ExternalBuildID      string                 `json:"externalBuildId,omitempty"`
	ExternalWorkflowName string                 `json:"externalWorkflowName,omitempty"`
}

Config is the xcelerate config saved to ~/.bitrise-xcelerate/config.json. Note: the benchmark phase is NOT stored here — matching gradle, it is exported as the BITRISE_BUILD_CACHE_BENCHMARK_PHASE env var and written to ~/.local/state/xcelerate/benchmark/benchmark-phase.json during activation.

func DefaultConfig

func DefaultConfig() Config

func NewConfig

func NewConfig(ctx context.Context,
	logger log.Logger,
	params Params,
	envs map[string]string,
	osProxy utils.OsProxy,
	cmdFunc utils.CommandFunc,
	exporter EnvExporter,
	benchmarkProvider common.BenchmarkPhaseProvider,
) (Config, error)

func ReadConfig

func ReadConfig(osProxy utils.OsProxy, decoderFactory utils.DecoderFactory) (Config, error)

func (Config) Save

func (config Config) Save(logger log.Logger, os utils.OsProxy, encoderFactory utils.EncoderFactory) error

type ConfigMigrator

type ConfigMigrator struct {
	Logger log.Logger
}

ConfigMigrator implements toolconfig.Migrator for ~/.bitrise-xcelerate/config.json.

func (ConfigMigrator) Migrate

func (m ConfigMigrator) Migrate(_ string) error

func (ConfigMigrator) Tool

type EnvExporter

type EnvExporter interface {
	Export(key, value string)
	ExportToShellRC(blockName, content string)
}

EnvExporter abstracts environment variable export for testability.

type Params

type Params struct {
	BuildCacheEnabled           bool
	BuildCacheEndpoint          string
	BuildCacheSkipFlags         bool
	DisablePrefixMapping        bool
	DebugLogging                bool
	Silent                      bool
	XcodePathOverride           string
	XcrunPathOverride           string
	ProxySocketPathOverride     string
	PushEnabled                 bool
	XcodebuildTimestampsEnabled bool
}

func DefaultParams

func DefaultParams() Params

Jump to

Keyboard shortcuts

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