AgentSkillsCN

build

为各平台构建 PeerTalk,并进行质量检查。适用于编译代码(快速语法检查、完整编译、测试)、打包 Mac 二进制文件以进行硬件传输,或运行包含质量门控的完整发布流水线时使用。

SKILL.md
--- frontmatter
name: build
description: Build PeerTalk for all platforms with quality checks. Use when compiling code (quick syntax check, full compile, tests), packaging Mac binaries for hardware transfer, or running the complete release pipeline with quality gates.
argument-hint: <mode>

Cross-Platform Build Orchestrator

Build PeerTalk for POSIX, 68k MacTCP, and PPC Open Transport platforms with integrated quality checks.

All builds run inside Docker containers per project requirements (see .claude/rules/build-requirements.md).

Quick Reference

ModeWhat It Does
testBuild + run all tests (default)
coverageTests with HTML coverage report
analyzeStatic analysis (cppcheck, complexity, duplicates)
quickFast syntax check (~5 sec)
compileFull compile with -Werror
valgrindMemory leak detection
integrationMulti-container network test
allAll platforms (POSIX + 68k + PPC)
packageCreate Mac .bin files for transfer
releaseFull pipeline with all quality gates
launcher-mactcpBuild LaunchAPPLServer for 68k
launcher-otBuild LaunchAPPLServer for PPC

Docker Images

ImageSizeUse For
peertalk-dev~2.5-3.7GBAll builds (tests, coverage, analysis, Mac)
peertalk-posix~580MBLightweight POSIX-only builds
ghcr.io/matthewdeaves/peertalk-dev:develop~2.5GBCI/pre-built dev image

The Makefile targets (docker-test, docker-coverage, docker-analyze) use peertalk-dev.


Mode Details

test (default)

Build and run all POSIX tests:

bash
make docker-test

This runs make clean && make all && make test-local inside the container.

coverage

Tests with HTML coverage report:

bash
make docker-coverage
# Report: build/coverage/html/index.html

analyze

Run static analysis suite:

bash
make docker-analyze
# Runs: cppcheck, pmccabe (complexity), jscpd (duplicates), lizard

quick

Fast syntax check without full compilation:

bash
docker run --rm -v "$(pwd)":/workspace -w /workspace peertalk-posix:latest \
    gcc -fsyntax-only -Wall -Wextra -I include -I src/core \
    src/core/*.c src/posix/*.c src/log/*.c

compile

Full compilation with warnings as errors:

bash
docker run --rm -v "$(pwd)":/workspace -w /workspace peertalk-dev make clean all

valgrind

Memory leak detection on core tests:

bash
make valgrind
# Runs test binaries through valgrind with --leak-check=full

integration

Multi-container network test (3 peers):

bash
make test-integration-docker
# Runs Alice, Bob, Charlie containers communicating over network

all

Build for all platforms (POSIX + 68k + PPC):

bash
./tools/build/build_all.sh all
# Uses Docker automatically when $RETRO68 not set

package

Build and create transferable Mac binaries:

bash
./tools/build/build_all.sh all
./tools/build/package.sh
# Creates: packages/PeerTalk-68k.bin, packages/PeerTalk-PPC.bin

release

Full pipeline with all quality gates:

bash
make docker-test
make docker-analyze
./tools/build/quality_gates.sh
./tools/build/build_all.sh all
./tools/build/package.sh

launcher-mactcp

Build LaunchAPPLServer for MacTCP (68k):

bash
./scripts/build-launcher.sh mactcp
# Output: LaunchAPPL-build/LaunchAPPLServer-MacTCP.bin

launcher-ot

Build LaunchAPPLServer for Open Transport (PPC):

bash
./scripts/build-launcher.sh ot
# Output: LaunchAPPL-build/LaunchAPPLServer-OpenTransport.bin

Makefile Targets Reference

The Makefile provides these Docker-wrapped targets:

TargetDescription
make docker-testRun all tests in container
make docker-coverageTests with coverage report
make docker-analyzeStatic analysis suite
make docker-buildJust compile (no tests)
make test-integration-dockerMulti-peer network test
make valgrindMemory leak detection

Local targets (run inside container or with deps installed):

TargetDescription
make test-localRun all tests
make coverage-localCoverage (requires lcov)
make test-logJust logging tests
make test-queueJust queue tests
make test-fuzzProtocol fuzz tests

Quality Gates

Enforced by ./tools/build/quality_gates.sh:

GateThresholdTool
File size500 lines maxwc -l
Function length100 lines max (prefer 50)ctags
Coverage10% minimumlcov
Compiler warningsTreat as errors-Werror
Cyclomatic complexity15 max per functionpmccabe/lizard
ISR safetyNo violations (Mac code)tools/validators/isr_safety.py

Run checks:

bash
./tools/build/quality_gates.sh         # Full check
./tools/build/quality_gates.sh quick   # Quick (no coverage)

Build Artifacts

DirectoryContents
build/lib/Static libraries (libpeertalk.a, libptlog.a)
build/bin/Test executables
build/coverage/html/Coverage report (open index.html)
packages/MacBinary packages for transfer
LaunchAPPL-build/Built LaunchAPPLServer binaries

Example Workflows

Quick Development Cycle

code
/build quick          # Fast syntax check
# Fix any errors
/build test           # Full test suite

Before Committing

code
/build test           # Verify tests pass
/build analyze        # Check for issues

Preparing for Mac Hardware

code
/build test           # Verify POSIX tests pass
/check-isr            # Validate ISR safety
/build package        # Create .bin files
# Transfer packages/*.bin to Mac

Full Release

code
/build release
# Creates tested, validated packages for all platforms

Setting Up LaunchAPPL for Hardware Testing

code
/build launcher-mactcp    # For 68k Macs (SE/30, IIci)
/build launcher-ot        # For PPC Macs
# Then use /deploy to transfer to Mac

Troubleshooting

Docker image not found

bash
# Pull pre-built dev image (recommended)
docker pull ghcr.io/matthewdeaves/peertalk-dev:develop
docker tag ghcr.io/matthewdeaves/peertalk-dev:develop peertalk-dev

# Or build POSIX image locally (lighter, POSIX-only)
docker build -t peertalk-posix -f docker/Dockerfile.posix .

# Or build full dev image (includes Retro68)
docker compose -f docker/docker-compose.yml build

Permission denied on build artifacts

The Makefile uses -u $(id -u):$(id -g) to match host user. If issues persist:

bash
sudo chown -R $(id -u):$(id -g) build/

Mac builds fail with "Retro68 not available"

Ensure Docker is running and the dev image is available:

bash
docker compose -f docker/docker-compose.yml run --rm peertalk-dev which m68k-apple-macos-gcc

Coverage shows 0%

Coverage requires tests to actually run. Check for test failures:

bash
make docker-test

Check prerequisites

bash
./.claude/skills/build/scripts/check-build-prereqs.sh