Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions skills/apollo-build/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,18 @@ is missing, ask; don't guess the target OS, it decides the headers.
sh <this skill's folder>/scripts/find-acd.sh <project folder>
```

It prints `ACD_ROOT`, `PREFIX`, `GCC`, the template and project Makefile
versions, and `PROBLEM=` lines. Fix every `PROBLEM` before building, with
the user: a missing toolchain means installing ApolloCrossDev
(`KB toolchain/index.md`, section Install), a wrong `APOLLOCROSSDEV` means
correcting it. Act on the `NOTE=` lines too.
It prints `ACD_ROOT`, `PREFIX`, `GCC`, `BUILT`, the template and project
Makefile versions, `PROBLEM=`, `NOTE=` and `UPDATE=` lines (`--offline`
skips the check on GitHub).

- Fix every `PROBLEM` before building, with the user: a missing toolchain
means installing ApolloCrossDev (`KB toolchain/index.md`, section
Install), a wrong `APOLLOCROSSDEV` means correcting it.
- Act on the `NOTE=` lines.
- `UPDATE=` lines don't block the build. Mention them once per session and
let the user decide: `UPDATE=checkout` is a quick `git pull` (mind
`LOCAL_CHANGES=`), `UPDATE=compiler` a reinstall of about 30 minutes that
the user runs.

## 3. Build

Expand Down Expand Up @@ -69,7 +76,7 @@ code around a symptom, check whether it is a known trap:

| Symptom | Read in the KB |
|---|---|
| Internal compiler error, or wrong code that looks like a compiler bug | `toolchain/compiler-variants.md` (bug table: fixed only in a reinstalled GCC-6.50-Dev), then the pitfall it names |
| Internal compiler error, or wrong code that looks like a compiler bug | First an `UPDATE=compiler` from step 2: the fix may only need a reinstall. Then `toolchain/compiler-variants.md` (bug table: fixed only in a reinstalled GCC-6.50-Dev) and the pitfall it names |
| Floats wrong, or link errors about float functions | `toolchain/pitfalls/float-settings-mismatch.md` |
| `sprintf`, headers or libnix surprises | `toolchain/pitfalls/libnix-and-header-traps.md` |
| Other GCC oddities | `toolchain/pitfalls/gcc-misc-traps.md` |
Expand Down
56 changes: 53 additions & 3 deletions skills/apollo-build/scripts/find-acd.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
#!/bin/sh
# find-acd.sh - find ApolloCrossDev and check that it can build.
#
# Usage: sh find-acd.sh [project folder]
# Prints KEY=value lines (ACD_ROOT, PREFIX, GCC, TEMPLATE, MAKEFILE) and
# exits 0 when the GCC-6.50-Dev toolchain is complete; otherwise prints
# Usage: sh find-acd.sh [--offline] [project folder]
# Prints KEY=value lines (ACD_ROOT, PREFIX, GCC, BUILT, TEMPLATE, MAKEFILE)
# and exits 0 when the GCC-6.50-Dev toolchain is complete; otherwise prints
# PROBLEM= lines and exits 1.
#
# Updates (skipped with --offline or without network), as UPDATE= lines:
# UPDATE=checkout ... the ApolloCrossDev checkout is behind GitHub:
# git pull (quick; LOCAL_CHANGES= warns first)
# UPDATE=compiler ... GCC-6.50-Dev was built before its install script
# or the patches last changed on GitHub: reinstall
# UPDATES=none up to date
#
# Where it looks for ApolloCrossDev, in this order:
# 1. $APOLLOCROSSDEV
# 2. two folders above the project (the project is in ApolloCrossDev/Projects/)
# 3. $HOME/ApolloCrossDev

offline=0
[ "$1" = "--offline" ] && { offline=1; shift; }
project=${1:-.}
problems=0
problem() { echo "PROBLEM=$1"; problems=1; }
Expand All @@ -37,6 +46,14 @@ for b in m68k-amigaos-gcc m68k-amigaos-g++ vasmm68k_mot; do
done
[ -x "$prefix/bin/m68k-amigaos-gcc" ] && echo "GCC=$("$prefix/bin/m68k-amigaos-gcc" --version | head -n 1)"

# when the compiler was built (UTC), from the gcc binary's file time
built=""
if [ -f "$prefix/bin/m68k-amigaos-gcc" ]; then
t=$(stat -f %m "$prefix/bin/m68k-amigaos-gcc" 2>/dev/null || stat -c %Y "$prefix/bin/m68k-amigaos-gcc" 2>/dev/null)
built=$(date -u -r "$t" +%Y-%m-%dT%H:%M:%SZ 2>/dev/null || date -u -d "@$t" +%Y-%m-%dT%H:%M:%SZ 2>/dev/null)
[ -n "$built" ] && echo "BUILT=$built"
fi

template="$root/Projects/_makefiles/Makefile"
if [ -f "$template" ]; then
echo "TEMPLATE=$(sed -n 's/^# ApolloCrossDev Makefile Template //p' "$template" | head -n 1)"
Expand All @@ -50,4 +67,37 @@ if [ -f "$project/Makefile" ]; then
grep -q '^compile:' "$project/Makefile" || echo "NOTE=the project Makefile has no 'make compile' target; build with: make cleanbefore build"
fi

# updates on GitHub
if [ $offline = 0 ]; then
updates=0
if git -C "$root" rev-parse HEAD >/dev/null 2>&1; then
here=$(git -C "$root" rev-parse HEAD)
there=$(git -C "$root" ls-remote origin refs/heads/main 2>/dev/null | cut -f1)
if [ -z "$there" ]; then
echo "NOTE=could not reach GitHub to check for ApolloCrossDev updates"
elif [ "$here" != "$there" ] && ! git -C "$root" merge-base --is-ancestor "$there" "$here" 2>/dev/null; then
echo "UPDATE=checkout: local ${here%"${here#???????}"}, GitHub ${there%"${there#???????}"}; update with: git -C $root pull"
updates=1
changed=$(git -C "$root" status --porcelain --untracked-files=no | wc -l | tr -d ' ')
[ "$changed" != 0 ] && echo "LOCAL_CHANGES=$changed tracked files changed in $root; commit or stash them before git pull"
fi
fi
if [ -n "$built" ]; then
case $(uname) in Darwin) script=GCC-6.50-Dev-MacOS.sh ;; *) script=GCC-6.50-Dev-Linux.sh ;; esac
for path in "$script" Compilers/_archives/patches; do
json=$(curl -s -m 8 "https://api.github.com/repos/WDrijver/ApolloCrossDev/commits?path=$path&per_page=1" 2>/dev/null)
when=$(printf '%s' "$json" | sed -n 's/.*"date": *"\([^"]*\)".*/\1/p' | head -n 1)
what=$(printf '%s' "$json" | sed -n 's/.*"message": *"\([^"\\]*\).*/\1/p' | head -n 1)
if [ -z "$when" ]; then
echo "NOTE=could not check $path on GitHub"
elif [ "$when" \> "$built" ]; then
echo "UPDATE=compiler: built $built, $path changed $when ($what); reinstall with: cd $root && ./$script (about 30 minutes)"
updates=1
break
fi
done
fi
[ $updates = 0 ] && echo "UPDATES=none"
fi

exit $problems
32 changes: 19 additions & 13 deletions skills/apollo-new-project/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: apollo-new-project
description: Set up a new Apollo V4 software project (game, demo, tool, application, library, driver) as its own git repository with ApolloKnowledgeBase as submodule, a filled-in AGENTS.md, the ApolloCrossDev Makefile and a starting program for os-friendly or os-takeover mode that builds without warnings. Use when the user wants to start, create, scaffold or set up a new program or project for the Apollo V4, Vampire V4, 68080 or SAGA, or wants an existing folder of Apollo code prepared for AI-assisted work.
description: Set up a new Apollo V4 software project (game, demo, tool, application, library, driver) as its own git repository with ApolloKnowledgeBase as submodule, a filled-in AGENTS.md, the ApolloCrossDev Makefile and a starting program for os-friendly or os-takeover mode that builds without warnings. Checks ApolloCrossDev first and offers updates. Use when the user wants to start, create, scaffold or set up a new program or project for the Apollo V4, Vampire V4, 68080 or SAGA, or wants an existing folder of Apollo code prepared for AI-assisted work.
---

# apollo-new-project
Expand Down Expand Up @@ -33,20 +33,26 @@ answers to the first five.
8. **ApolloLib** for SAGA sound, pictures, PIP, pointer and input [yes]. See
`KB core/best-practices/prefer-library-calls-for-saga-chips.md`.

## 2. Check the toolchain
## 2. Check the toolchain, offer updates

Run the apollo-build skill's check:
`sh <skills folder>/apollo-build/scripts/find-acd.sh`. The project needs:
Before creating anything, run the apollo-build skill's check:
`sh <skills folder>/apollo-build/scripts/find-acd.sh`. Then tell the user
what you found and let them choose:

- GCC-6.50-Dev installed (no `PROBLEM=` lines);
- Makefile template v1.2 or later (`TEMPLATE=`), which builds projects
outside ApolloCrossDev and has `make compile`. Older: ask the user to
update ApolloCrossDev (`git pull` in its folder);
- `APOLLOCROSSDEV` set, because the project lives outside
`ApolloCrossDev/Projects/`. If the script notes it is unset, ask the user
to add `export APOLLOCROSSDEV="<ACD_ROOT>"` to `~/.zshrc` (macOS) or
`~/.bashrc` (Linux), next to `AMIGAHOST`. For this session, pass it on the
command line: `APOLLOCROSSDEV=<ACD_ROOT> make compile`.
| Finding | Offer |
|---|---|
| `PROBLEM=` ApolloCrossDev not found or incomplete | Install it first (`KB toolchain/index.md`, section Install; needs `sudo`, about 30 minutes). Stop until it is done. |
| `UPDATE=checkout` | `git pull` in the ApolloCrossDev folder: quick, brings new Makefile templates, ApolloLib and scripts. If `LOCAL_CHANGES=` is reported, the user decides about those first. Run the pull only with their consent. |
| `UPDATE=compiler` | Reinstall GCC-6.50-Dev (the command is in the line; needs `sudo`, about 30 minutes; the user runs it). Say what the newer build changes: the bug table in `KB toolchain/compiler-variants.md`. The user may also continue now and reinstall later. |
| `TEMPLATE=` older than v1.2 | `git pull` is required: the project needs `make compile` and builds outside ApolloCrossDev. |
| `UPDATES=none` | Nothing to offer; say the toolchain is up to date. |

Run the check again after an update. The project also needs
`APOLLOCROSSDEV`, because it lives outside `ApolloCrossDev/Projects/`. If
the check notes it is unset, ask the user to add
`export APOLLOCROSSDEV="<ACD_ROOT>"` to `~/.zshrc` (macOS) or `~/.bashrc`
(Linux), next to `AMIGAHOST`. For this session, pass it on the command
line: `APOLLOCROSSDEV=<ACD_ROOT> make compile`.

## 3. Create the repository

Expand Down
Loading