-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
172 lines (163 loc) · 12.2 KB
/
Copy pathMakefile
File metadata and controls
172 lines (163 loc) · 12.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# Purpose: Provide the stable top-level CueLoop build, test, release, and developer command entrypoint.
# Responsibilities: Define global Make settings, shared variables, public phony targets, help text, and include focused target fragments.
# Scope: Compatibility shell only; target bodies live in mk/*.mk fragments.
# Usage: Run `make <target>` from the repository root.
# Invariants/Assumptions: GNU Make >= 4 parses this file before included fragments, and all public targets remain invokable from this root entrypoint.
RUST_WORKSPACE := .
PREFIX ?= $(HOME)/.local
BIN_DIR ?= $(PREFIX)/bin
BIN_NAME ?= cueloop
CARGO_PACKAGE_NAME ?= cueloop
CARGO_HTTP_MULTIPLEXING ?= false
CUELOOP_CI_JOBS ?= 0
RUST_JOBS ?= $(CUELOOP_CI_JOBS)
SCCACHE ?= $(shell which sccache 2>/dev/null)
AGENT_ID ?= manual
AGENT_TARGET := $(CURDIR)/target/agents/$(AGENT_ID)
CUELOOP_CARGO_MODE ?= local
XCODE_DERIVED_DATA_ROOT ?= target/tmp/xcode-deriveddata
# Pin destination arch to avoid xcodebuild's "first of multiple matching destinations" warning.
# Override if you intentionally want a different destination.
XCODE_DESTINATION ?= platform=macOS,arch=$(shell uname -m)
# Local CI validates the host architecture that XCTest can execute. Release artifact
# packaging remains responsible for any multi-architecture distribution builds.
XCODE_ARCHS ?= $(shell uname -m)
# UI tests: Set to 1 to include UI tests (headed, mouse-interactive), 0 to skip (default for CI)
CUELOOP_UI_TESTS ?= 0
# UI screenshots: opt-in evidence capture for headed macOS UI tests.
CUELOOP_UI_SCREENSHOTS ?= 0
# UI screenshot mode: off|checkpoints|timeline (empty lets tests decide from CUELOOP_UI_SCREENSHOTS).
CUELOOP_UI_SCREENSHOT_MODE ?=
# Optional focused UI test selector for retest loops.
CUELOOP_UI_ONLY_TESTING ?=
# Result bundle path override for UI evidence export workflows.
XCODE_RESULT_BUNDLE_PATH ?=
# Root directory for exported UI visual artifacts.
CUELOOP_UI_ARTIFACTS_ROOT ?= target/ui-artifacts
MACOS_APP_INSTALL_DIR ?= /Applications
XCODE_BUILD_LOCK_DIR ?= target/tmp/locks/xcodebuild.lock
# Default to Cargo/nextest-managed parallelism for normal incremental local and agent runs.
# Set an explicit cap (for example `CUELOOP_CI_JOBS=4`) on shared workstations.
# `RUST_JOBS` remains available as the lower-level CARGO_BUILD_JOBS cap.
# Default to xcodebuild-managed parallelism for best local throughput.
# Set an explicit cap (for example `CUELOOP_XCODE_JOBS=4`) on shared workstations.
CUELOOP_XCODE_JOBS ?= 0
# Build stamp path to avoid duplicate release builds in a single make invocation.
CUELOOP_STAMP_DIR ?= target/tmp/stamps
CUELOOP_RELEASE_BUILD_STAMP := $(CUELOOP_STAMP_DIR)/cueloop-release-build.stamp
# Inputs that affect the release CLI binary; when newer than the stamp, `make build` re-runs `cueloop-cli-bundle.sh`.
CUELOOP_RELEASE_STAMP_INPUTS := Makefile mk/rust.mk Cargo.toml Cargo.lock VERSION rust-toolchain.toml scripts/cueloop-cli-bundle.sh scripts/lib/cueloop-shell.sh
CUELOOP_CLI_INPUT_FILES := $(shell find crates/cueloop -type f \( -path '*/src/*.rs' -o -name 'Cargo.toml' -o -name 'build.rs' -o -path '*/assets/*' \) 2>/dev/null | LC_ALL=C sort)
CUELOOP_CARGO_CONFIG_INPUT_FILES := $(shell find .cargo -type f 2>/dev/null | LC_ALL=C sort)
# Default local Xcode builds/tests to normal incremental DerivedData reuse.
# Set CUELOOP_XCODE_CLEAN_DERIVED_DATA=1, or run explicit *-clean targets, when a fresh Xcode build tree is required.
CUELOOP_XCODE_CLEAN_DERIVED_DATA ?= 0
# Internal ship-gate toggle: reuse one derived-data tree across macos-build/test/contracts.
CUELOOP_XCODE_REUSE_SHIP_DERIVED_DATA ?= 0
# Prefer the rustup-managed pinned toolchain from rust-toolchain.toml when present.
CUELOOP_RUST_TOOLCHAIN_FILE := rust-toolchain.toml
CUELOOP_PINNED_RUST_TOOLCHAIN := $(shell sed -n 's/^[[:space:]]*channel = "\(.*\)"/\1/p' $(CUELOOP_RUST_TOOLCHAIN_FILE) 2>/dev/null | head -1)
CUELOOP_PINNED_RUSTC := $(shell if command -v rustup >/dev/null 2>&1 && [ -n "$(CUELOOP_PINNED_RUST_TOOLCHAIN)" ]; then rustup which rustc --toolchain "$(CUELOOP_PINNED_RUST_TOOLCHAIN)" 2>/dev/null; fi)
CUELOOP_PINNED_RUST_BIN_DIR := $(patsubst %/,%,$(dir $(CUELOOP_PINNED_RUSTC)))
# Shell snippets that make Cargo build mode explicit for every recipe.
CUELOOP_RUSTUP_ENV_RESET := :
ifneq ($(strip $(CUELOOP_PINNED_RUST_BIN_DIR)),)
CUELOOP_RUSTUP_ENV_RESET := export PATH="$(CUELOOP_PINNED_RUST_BIN_DIR):$$PATH"; export RUSTC="$(CUELOOP_PINNED_RUSTC)"
endif
CUELOOP_CARGO_BUILD_JOBS_ENV := $(if $(filter-out 0,$(RUST_JOBS)),export CARGO_BUILD_JOBS="$(RUST_JOBS)",unset CARGO_BUILD_JOBS)
ifeq ($(CUELOOP_CARGO_MODE),agent)
ifneq ($(strip $(SCCACHE)),)
CUELOOP_CARGO_ENV_RESET := export CARGO_TARGET_DIR="$(AGENT_TARGET)"; export RUSTC_WRAPPER="$(SCCACHE)"; unset CARGO_INCREMENTAL; $(CUELOOP_CARGO_BUILD_JOBS_ENV)
else
CUELOOP_CARGO_ENV_RESET := export CARGO_TARGET_DIR="$(AGENT_TARGET)"; unset RUSTC_WRAPPER CARGO_INCREMENTAL; $(CUELOOP_CARGO_BUILD_JOBS_ENV)
endif
else
CUELOOP_CARGO_ENV_RESET := unset RUSTC_WRAPPER RUSTFLAGS CARGO_ENCODED_RUSTFLAGS CARGO_TARGET_DIR CARGO_INCREMENTAL; $(CUELOOP_CARGO_BUILD_JOBS_ENV)
endif
CUELOOP_ENV_RESET := $(CUELOOP_RUSTUP_ENV_RESET); $(CUELOOP_CARGO_ENV_RESET)
CARGO_JOBS_FLAG := $(if $(filter-out 0,$(CUELOOP_CI_JOBS)),--jobs $(CUELOOP_CI_JOBS),)
NEXTEST_JOBS_FLAG := $(if $(filter-out 0,$(CUELOOP_CI_JOBS)),--jobs $(CUELOOP_CI_JOBS),)
CARGO_TEST_THREADS_FLAG := $(if $(filter-out 0,$(CUELOOP_CI_JOBS)),--test-threads $(CUELOOP_CI_JOBS),)
XCODE_JOBS_FLAG := $(if $(filter-out 0,$(CUELOOP_XCODE_JOBS)),-jobs $(CUELOOP_XCODE_JOBS),)
XCODE_ACTIVE_ARCH_FLAGS := ARCHS=$(XCODE_ARCHS) ONLY_ACTIVE_ARCH=YES
CUELOOP_CLI_BUILD_JOBS_ARG := $(if $(filter-out 0,$(CUELOOP_CI_JOBS)),--jobs $(CUELOOP_CI_JOBS),)
XCODE_MACOS_BUILD_DERIVED_DATA_PATH := $(if $(filter 1,$(CUELOOP_XCODE_REUSE_SHIP_DERIVED_DATA)),$(XCODE_DERIVED_DATA_ROOT)/ship,$(XCODE_DERIVED_DATA_ROOT)/build)
XCODE_MACOS_TEST_DERIVED_DATA_PATH := $(if $(filter 1,$(CUELOOP_XCODE_REUSE_SHIP_DERIVED_DATA)),$(XCODE_DERIVED_DATA_ROOT)/ship,$(XCODE_DERIVED_DATA_ROOT)/test)
XCODE_MACOS_RELEASE_APP_BUNDLE := $(XCODE_MACOS_BUILD_DERIVED_DATA_PATH)/Build/Products/Release/CueLoopMac.app
.DELETE_ON_ERROR:
.ONESHELL:
SHELL := bash
.SHELLFLAGS := -eu -o pipefail -c
# Require GNU Make >= 4.x (Homebrew `make` provides `gmake`, plus a `make` shim under `.../gnubin`).
ifeq ($(filter 4.% 5.%,$(MAKE_VERSION)),)
$(error GNU Make >= 4 is required (found: $(MAKE_VERSION)). On macOS: `brew install make` then run `gmake <target>` or add Homebrew gnubin to PATH (Apple Silicon: /opt/homebrew/opt/make/libexec/gnubin, Intel: /usr/local/opt/make/libexec/gnubin).)
endif
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
.PHONY: help install install-verify macos-install-app update security-audit lint lint-fix format format-check type-check clean clean-temp test generate docs build ci ci-fast ci-docs deps \
rust-toolchain-check rust-toolchain-drift-check \
changelog changelog-preview changelog-check version-check version-sync publish-check release release-verify release-artifacts pre-commit pre-public-check release-gate \
profile-ship-gate profile-ship-gate-clean agent-ci build-cache-doctor check-env-safety check-backup-artifacts check-file-size-limits check-repo-safety macos-preflight macos-build macos-build-clean macos-test macos-test-clean macos-ci macos-ci-clean macos-test-ui \
macos-ui-build-for-testing macos-ui-build-for-testing-clean macos-ui-retest macos-test-ui-artifacts macos-ui-artifacts-clean \
macos-test-window-shortcuts macos-test-window-shortcuts-clean macos-test-contracts macos-test-settings-smoke macos-test-workspace-routing-contract coverage coverage-clean
help:
@echo "Everyday commands:"
@echo " make agent-ci # Required pre-commit gate: routes from the current local diff"
@echo " make release-gate # Heaviest final gate: macOS when available, otherwise Rust-only"
@echo " make pre-public-check # Publication audit + full local CI"
@echo " make install # Install release CLI; on macOS also installs CueLoopMac.app"
@echo ""
@echo "Lower-level / power-user gates:"
@echo " make ci-docs # Docs/community-only gate with markdown and path checks"
@echo " make ci-fast # Fast deterministic Rust/CLI gate for day-to-day development"
@echo " make ci # Full Rust release gate (ci-fast + build/generate/install verification)"
@echo " make macos-ci # Rust gate + macOS app build+test + deterministic contract smoke (requires Xcode)"
@echo " make test # Nextest workspace tests + cargo doc tests (auto-fallback if nextest missing)"
@echo " make coverage # Generate code coverage report (requires cargo-llvm-cov)"
@echo " make coverage-clean # Remove coverage artifacts"
@echo " make macos-test-window-shortcuts # Run focused multi-window shortcut UI regressions"
@echo " make macos-build-clean / macos-test-clean / macos-ci-clean # Clean Xcode DerivedData, then run target"
@echo " make build-cache-doctor # Inspect Cargo/Xcode cache state and suspicious target growth"
@echo " make macos-test-contracts # Run deterministic non-XCTest macOS contract checks"
@echo " make macos-test-settings-smoke # Run noninteractive Settings open-path contract coverage"
@echo " make macos-test-workspace-routing-contract # Run noninteractive workspace routing contract coverage"
@echo " make macos-ui-build-for-testing # Build/sign UI test bundles once for local iteration"
@echo " make macos-ui-retest # Re-run UI tests without rebuilding bundles"
@echo " make macos-test-ui-artifacts # Run UI suite with xcresult capture + summary"
@echo " make macos-ui-artifacts-clean # Remove captured UI visual artifacts"
@echo " make profile-ship-gate # Capture canonical local ship-gate profiling bundle (requires Xcode)"
@echo " make profile-ship-gate-clean # Remove ship-gate profiling bundles"
@echo " make lint # Clippy with -D warnings"
@echo " make generate # Regenerate committed JSON schemas via release binary"
@echo " make update # Refresh Cargo.lock to latest compatible deps; edit Cargo.toml for requirement bumps"
@echo " make security-audit # Audit Cargo.lock against RustSec advisories (requires cargo-audit)"
@echo " make rust-toolchain-check # Verify repo-pinned Rust toolchain baseline"
@echo " make rust-toolchain-drift-check # Compare repo-pinned Rust against global rustup stable"
@echo " make macos-install-app # Copy latest Release CueLoopMac.app into Applications"
@echo " make version-check # Verify VERSION, Cargo, and Xcode version metadata are synchronized"
@echo " make version-sync VERSION=x.y.z # Sync repo version metadata from one canonical semver"
@echo " make publish-check # Run cargo package review + crates.io dry-run for $(CARGO_PACKAGE_NAME)"
@echo " make release-verify VERSION=x.y.z # Mutating local preflight: prepares the exact release snapshot that make release will publish"
@echo " make check-repo-safety # Fast required-files + env/runtime + secret checks"
@echo " make check-file-size-limits # Report file-size advisories and fail only extreme unallowlisted files"
@echo ""
@echo "Resource knobs (optional):"
@echo " CUELOOP_CI_JOBS=4 # Example Rust/nextest job cap for shared workstations (0 = tool default)"
@echo " AGENT_ID=agent-a # Isolated target/agents/<id> directory for make agent-ci"
@echo " CUELOOP_XCODE_JOBS=4 # Example cap for shared workstations (0 = xcodebuild default)"
@echo " XCODE_ARCHS=$$(uname -m) # Host-arch Xcode CI/test builds (override only for cross-arch validation)"
@echo " rust-toolchain.toml is respected automatically when rustup is available"
@echo " CUELOOP_UI_SCREENSHOT_MODE=timeline # off|checkpoints|timeline (for macos-ui-retest debugging)"
@echo " CUELOOP_UI_ONLY_TESTING=CueLoopMacUITests/CueLoopMacUILaunchAndTaskFlowTests/test_createNewTask_viaQuickCreate # Target macOS UI retests"
@echo " CUELOOP_UI_ARTIFACTS_ROOT=target/ui-artifacts # Export root for visual artifacts"
@echo " CUELOOP_XCODE_CLEAN_DERIVED_DATA=1 # Delete the target's Xcode DerivedData before building (default 0 = incremental)"
@echo " CUELOOP_AGENT_CI_MIN_TIER=macos-ci|ci|ci-fast # Floor for agent-ci routing (optional)"
@echo " CUELOOP_AGENT_CI_FORCE_MACOS=1 # Always run macos-ci from agent-ci"
include mk/rust.mk
include mk/repo-safety.mk
include mk/ci.mk
include mk/macos.mk
include mk/coverage.mk
.PHONY: cutover-check
cutover-check:
@scripts/check-cueloop-cutover.sh --enforce