xcodeargs

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

Overview

nolint:gochecknoglobals

Index

Constants

View Source
const (
	ClangEnablePrefixMappingKey = "CLANG_ENABLE_PREFIX_MAPPING"
	OtherCFlagsKey              = "OTHER_CFLAGS"
	ProjectTempDirKey           = "PROJECT_TEMP_DIR"
	DerivedDataPathFlag         = "-derivedDataPath"
)

Build-setting keys and derivedDataPath flag literal used by the wrapper when injecting prefix-map rules.

Variables

View Source
var CacheArgs = map[string]string{
	"COMPILATION_CACHE_ENABLE_CACHING":              "YES",
	"COMPILATION_CACHE_ENABLE_PLUGIN":               "YES",
	"COMPILATION_CACHE_ENABLE_INTEGRATED_QUERIES":   "YES",
	"COMPILATION_CACHE_ENABLE_DETACHED_KEY_QUERIES": "YES",
	"SWIFT_ENABLE_COMPILE_CACHE":                    "YES",
	"SWIFT_ENABLE_EXPLICIT_MODULES":                 "YES",
	"SWIFT_USE_INTEGRATED_DRIVER":                   "YES",
	"CLANG_ENABLE_COMPILE_CACHE":                    "YES",
	"CLANG_ENABLE_MODULES":                          "YES",
	"COMPILATION_CACHE_REMOTE_SUPPORTED_LANGUAGES":  "swift c c++ objective-c objective-c++",
}

Xcode 26 gates the compile-cache plugin behind the master toggle COMPILATION_CACHE_ENABLE_CACHING. Without it, SwiftBuild resolves the individual COMPILATION_CACHE_* keys but never emits -cache-compile-job on swiftc argv, so the plugin never loads and the remote CAS stays dark for projects whose target defaults don't already have caching on.

Functions

func BuildOtherCFlagsValue added in v3.2.0

func BuildOtherCFlagsValue(p PrefixMapPaths) string

BuildOtherCFlagsValue returns the suffix to append after "$(inherited) " in OTHER_CFLAGS. Rule ordering is narrowest-first: when one mapped path sits inside another (e.g. DerivedDataPath under $HOME), the narrower rule must fire first so its virtual name wins regardless of whether clang interprets -fdepscan-prefix-map as first-match-wins or longest-match-wins.

func HasBuildAction added in v3.2.0

func HasBuildAction(argv []string) bool

HasBuildAction reports whether argv triggers a real xcodebuild build. An explicit build-action keyword wins; otherwise argv is a build unless a query-only action (-list, -version, -showBuildSettings, ...) is present.

func MergeOtherCFlagsValue added in v3.2.0

func MergeOtherCFlagsValue(userValue, suffix string) string

MergeOtherCFlagsValue splices the injected prefix-map suffix into a user-supplied OTHER_CFLAGS value. Any leading $(inherited) markers in the user value are collapsed to a single leading marker so the final layout is:

$(inherited) <user tokens minus $(inherited)> <suffix>

An empty user value + empty suffix returns "". An empty user value with a non-empty suffix still emits $(inherited) so the target/xcconfig chain is not lost.

Types

type CompCacheStats

type CompCacheStats struct {
	Hits       int64
	TotalTasks int64
}

type Default

type Default struct {
	Cmds         []*cobra.Command
	OriginalArgs []string
	// contains filtered or unexported fields
}

func NewDefault

func NewDefault(
	cmd *cobra.Command,
	originalArgs []string,
	logger log.Logger,
) *Default

func (Default) Args

func (p Default) Args(additional map[string]string) []string

func (Default) Command

func (p Default) Command() string

func (Default) DerivedDataPath added in v3.2.0

func (p Default) DerivedDataPath() string

DerivedDataPath returns the last -derivedDataPath value from OriginalArgs, supporting both `-derivedDataPath X` and `-derivedDataPath=X` forms. A value that begins with `-` in the space form is treated as the next flag and the current one as missing. Relative values are resolved against the current working directory — clang rejects non-absolute inputs to -fdepscan-prefix-map=.

func (Default) HasBuildAction added in v3.2.0

func (p Default) HasBuildAction() bool

func (Default) ProjectDir added in v3.2.0

func (p Default) ProjectDir() string

ProjectDir returns the parent directory of the -project or -workspace value on OriginalArgs. -project wins when both are present. When neither flag is present xcodebuild auto-discovers a single .xcworkspace/.xcodeproj in CWD, so CWD is the project dir. Relative -project/-workspace values are resolved against the current working directory before taking the parent — a bare `App.xcworkspace` would otherwise give `.`, which clang rejects as a -fdepscan-prefix-map= input.

func (Default) ProjectTempDir added in v3.2.0

func (p Default) ProjectTempDir() string

ProjectTempDir returns the last PROJECT_TEMP_DIR=... build-setting value from OriginalArgs. Missing → empty. Relative values are resolved against the current working directory — clang rejects non-absolute inputs to -fdepscan-prefix-map=.

func (Default) ShortCommand

func (p Default) ShortCommand() string

func (Default) UserOtherCFlags added in v3.2.0

func (p Default) UserOtherCFlags() string

UserOtherCFlags returns the last OTHER_CFLAGS=... build-setting value from OriginalArgs. Missing → empty.

type DefaultRunner

type DefaultRunner struct {
	// contains filtered or unexported fields
}

func NewRunner

func NewRunner(logger log.Logger, config xcelerate.Config, logFile io.Writer) *DefaultRunner

func (*DefaultRunner) Run

func (runner *DefaultRunner) Run(ctx context.Context, args []string) RunStats

nolint: gosec

type PrefixMapPaths added in v3.2.0

type PrefixMapPaths struct {
	Home            string
	ProjectDir      string
	DerivedDataPath string
	ProjectTempDir  string
}

PrefixMapPaths is the set of absolute paths whose values will be rewritten to stable virtual names in clang's CAS cache keys via -fdepscan-prefix-map. Empty fields produce no rule.

type RunStats

type RunStats struct {
	StartTime        time.Time
	Success          bool
	Error            error
	ExitCode         int
	DurationMS       int64
	XcodeVersion     string
	XcodeBuildNumber string
	CacheStats       CompCacheStats
}

type XcodeArgs

type XcodeArgs interface {
	Args(additional map[string]string) []string
	Command() string
	ShortCommand() string
	HasBuildAction() bool
	DerivedDataPath() string
	ProjectTempDir() string
	ProjectDir() string
	UserOtherCFlags() string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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