https://github.com/wezm/classic-mac-rust
Experiments using Rust code in classic Mac applications
https://github.com/wezm/classic-mac-rust
classic-mac-os retrocomputing rust
Last synced: about 1 year ago
JSON representation
Experiments using Rust code in classic Mac applications
- Host: GitHub
- URL: https://github.com/wezm/classic-mac-rust
- Owner: wezm
- Created: 2023-03-28T02:49:58.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-29T01:59:52.000Z (about 3 years ago)
- Last Synced: 2025-03-17T11:55:04.925Z (about 1 year ago)
- Topics: classic-mac-os, retrocomputing, rust
- Language: Rust
- Homepage: https://www.wezm.net/v2/posts/2023/rust-classic-mac-os-app/
- Size: 17.6 KB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Rust on Classic Mac OS
======================
This repo includes my experiments running Rust code on PPC classic Mac OS.
Building
--------
**Note:** these steps have only been tested on Linux (Arch).
### Prerequisites
1. [My fork of the Retro68 with updated binutils][Retro68] (`binutils` branch)
built and on `$PATH`. E.g. `export PATH=$PATH:/home/you/path/to/Retro68-build/toolchain/bin`
2. `rustup`
3. Docker (if not on Debian based system) or `binutils-powerpc-linux-gnu` on
Debian based systems For non-Debian systems build the binutils docker image:
`(cd powerpc-binutils && docker build -t binutils-objcopy .)`
### Prepare
```
mkdir build
cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=path/to/Retro68-build/toolchain/powerpc-apple-macos/cmake/retroppc.toolchain.cmake
cd ..
```
### Build
Compile the Rust code with:
```
cargo build --release -Z build-std=core,alloc --target powerpc-apple-macos.json
```
Convert the static library to XCOFF, either via Docker or `powerpc-linux-gnu-objcopy`
directly:
```
docker run --rm -it -v $(pwd):/src binutils-objcopy -O aixcoff-rs6000 /src/target/powerpc-apple-macos/release/libclassic_mac_rust.a /src/target/powerpc-apple-macos/release/libclassic_mac_rust.obj
```
Build the C code, link in the Rust code, and produce the final binary:
```
cmake --build build --target Dialog_APPL
```
### Running
`Dialog.bin` is the MacBinary encoded application, you can copy this to a
machine or emulator to run it. Retro68 provides the `LaunchAAPL` tool, which
combined with its server counterpart makes this very easy. With the server
running on a machine or emulator you can launch the binary directly from you
host with:
```
LaunchAPPL -e tcp --tcp-address 127.0.0.1 build/Dialog.bin
```
[Retro68]: https://github.com/wezm/Retro68/tree/binutils