Skip to content

Package macOS builds as Picori.app - #228

Open
awkitsune wants to merge 1 commit into
999sian:masterfrom
awkitsune:macos-app-bundle
Open

awkitsune wants to merge 1 commit into
999sian:masterfrom
awkitsune:macos-app-bundle

Conversation

@awkitsune

Copy link
Copy Markdown

Problem

On macOS the build is a bare tmc_pc executable, so double-clicking it in Finder opens a Terminal window. A plain .app wrapper isn't enough on its own, for two reasons:

  • Finder launches apps with the working directory set to /. The port keeps all its state relative to the working directory or the binary's folder (config.json, tmc.sav, the asset cache, quicksaves, bug reports, the installed baserom.gba).
  • Writing into the bundle (the asset cache, a picked ROM) breaks its code signature.

Changes

  • port/port_macos_bundle.{c,h} (new; SDL-free, no-op outside a bundle): when the binary runs from <name>.app/Contents/MacOS, Port_MacBundle_Init() does the following, mirroring the existing Android data-dir approach:
    • switches the working directory to ~/Library/Application Support/Picori
    • stages the public defaults from Contents/Resources (voxel_shapes.json, assets/rando/default.logic) if they're missing
    • when there's no terminal, redirects stdout/stderr to picori.log, keeping the previous run's log as picori.log.1
  • port_main.c: calls it before anything opens a file relative to the working directory.
  • port_asset_bootstrap.cpp / port_rom_picker.c: in a bundle, the asset cache and a picked ROM go to the data dir instead of next to the binary. Mods, rando logic and the ROM probe already search the working directory, so they work unchanged.
  • tools/make_macos_app.py (new): wraps a built tmc_pc into Picori.app. It writes an Info.plist (NSHighResolutionCapable, GCSupportsGameMode, games category, version taken from xmake.lua), turns docs/picori-logo.png into .icns with sips/iconutil, copies the same public defaults the tarball ships, and ad-hoc signs the result with codesign -s -. No ROM or ROM-derived data goes into the bundle.
  • build.py: on macOS, also produces dist/<VERSION>/Picori.app.
  • CI (_build.yaml): macOS legs add a step that packages tmc-multi-macos-<arch>-<version>-app.tar.gz (with COPYFILE_DISABLE=1, so no ._* entries) and runs codesign --verify --strict on it. The existing *.tar.gz release glob picks it up, so release.yaml is untouched, and the existing tarball payload, along with its regression test, is unchanged.
  • README: a short note on Picori.app and where its data lives.

Testing (Apple Silicon, macOS 27, USA ROM)

  • python3 build.py --usa → dist/USA/Picori.app; codesign --verify --strict passes.
  • Launched with open (as Finder does: working directory /, no TTY):
    • the data dir is created and the defaults are staged
    • the log goes to picori.log
    • the ROM is found in the data dir, and assets self-extract into assets/usa there
    • the game boots and tmc.sav is written there
    • the bundle is unmodified afterwards and its signature is still valid
  • The plain dist/USA/tmc_pc run from a terminal behaves as before: no bundle mode, and ROM and assets are found next to the binary.
  • Ran the CI packaging commands locally; the signature still verifies after the tar round-trip.

Notes

  • The bundle ID io.github.999sian.picori is a placeholder. Happy to change it.
  • The app is ad-hoc signed, not notarized, so downloaded copies still need a one-time Gatekeeper approval, the same as the bare binary today. Notarization would need a Developer ID.
  • The new CI steps haven't run on GitHub yet; I could only test their commands locally.
  • Unrelated, but I noticed it: tools/release_payload_regression_test.py already fails on master when run on macOS, because macOS tar adds ._* AppleDouble entries. It passes with COPYFILE_DISABLE=1.
  • Independent of Enable HiDPI window on macOS (fixes blurry rendering on Retina) #227 (HiDPI fix). The two PRs touch nearby lines in port_main.c but merge cleanly.

🤖 Generated with Claude Code

Launching the bare tmc_pc from Finder opens a Terminal window. Wrap it in
an ad-hoc-signed Picori.app instead (tools/make_macos_app.py), produced by
build.py on macOS and shipped by CI as a separate *-app.tar.gz.

A Finder launch starts with CWD = / and the bundle must not be written to,
so when running from <name>.app/Contents/MacOS the port now chdirs to
~/Library/Application Support/Picori (like Android's data dir), stages the
public defaults from Contents/Resources there, and logs to picori.log. The
asset cache and a picked ROM go to that dir instead of beside the binary.
The plain tarball layout is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant