|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with |
| 4 | +code in this repository. |
| 5 | + |
| 6 | +## Project Overview |
| 7 | + |
| 8 | +macOS Emacs building system with Ruby and Go components: |
| 9 | + |
| 10 | +- **Ruby script** (`build-emacs-for-macos`): Main build script for creating |
| 11 | + self-contained Emacs.app bundles |
| 12 | +- **Go CLI tool** (`emacs-builder`): Packaging, signing, notarization, and |
| 13 | + release management |
| 14 | +- **Dual dependency management**: Nix (preferred) or Homebrew |
| 15 | + |
| 16 | +## Common Commands |
| 17 | + |
| 18 | +```bash |
| 19 | +# Environment setup (Nix preferred) |
| 20 | +nix develop # Default macOS 11 SDK |
| 21 | +nix develop .#macos{11-15,26} # Target specific SDK version |
| 22 | + |
| 23 | +# Go development |
| 24 | +make build # Build emacs-builder CLI |
| 25 | +make test # Run tests with race detection |
| 26 | +make lint # Run golangci-lint |
| 27 | +make format # Format with gofumpt |
| 28 | + |
| 29 | +# Ruby development |
| 30 | +bundle exec rubocop # Lint (with development group) |
| 31 | + |
| 32 | +# Build Emacs |
| 33 | +./build-emacs-for-macos # Build from master |
| 34 | +./build-emacs-for-macos emacs-29.4 |
| 35 | +``` |
| 36 | + |
| 37 | +## Architecture |
| 38 | + |
| 39 | +### Ruby Build Script (`build-emacs-for-macos`) |
| 40 | + |
| 41 | +Single-file Ruby script (~2500 lines) that: |
| 42 | + |
| 43 | +- Downloads source tarballs from emacs-mirror/emacs on GitHub |
| 44 | +- Configures and compiles Emacs with native-comp, tree-sitter support |
| 45 | +- Creates self-contained .app bundles by embedding/relinking dependencies |
| 46 | +- Uses `ruby-macho` gem for Mach-O binary manipulation (RPATH handling) |
| 47 | + |
| 48 | +### Go CLI (`cmd/emacs-builder/`) |
| 49 | + |
| 50 | +Uses `urfave/cli/v2` framework. Key packages in `pkg/`: |
| 51 | + |
| 52 | +- `cli/`: Commands (plan, sign, sign-files, notarize, package, release, cask) |
| 53 | +- `sign/`: macOS code signing via `codesign` |
| 54 | +- `notarize/`: Apple notarization workflow via `notarytool` |
| 55 | +- `release/`: GitHub release management |
| 56 | +- `dmgbuild/`: DMG creation using Python dmgbuild |
| 57 | +- `plan/`: Build plan JSON parsing and management |
| 58 | + |
| 59 | +### Nix Environment (`flake.nix`) |
| 60 | + |
| 61 | +- Multi-SDK support: macOS 11-15, 26 via `.#macos{11,12,13,14,15,26}` |
| 62 | +- Excludes ncurses intentionally (links against system version for TUI) |
| 63 | +- Sets `MACOSX_DEPLOYMENT_TARGET`, `DEVELOPER_DIR`, `NIX_LIBGCCJIT_*` |
| 64 | + |
| 65 | +## Testing |
| 66 | + |
| 67 | +```bash |
| 68 | +make test # All Go tests |
| 69 | +go test ./pkg/release/... # Single package |
| 70 | +go test -run TestName ./pkg/... # Single test |
| 71 | +``` |
| 72 | + |
| 73 | +Tests use `_test.go` suffix alongside source files. |
| 74 | + |
| 75 | +## Working Directories |
| 76 | + |
| 77 | +- `sources/`: Downloaded/extracted Emacs source (gitignored) |
| 78 | +- `builds/`: Build outputs and .app bundles (gitignored) |
| 79 | +- `patches/`: Emacs patches applied during build |
| 80 | +- `bin/`: Built Go binaries (gitignored) |
0 commit comments