| Initial commit: V -> Flutter FFI plugin ad0ccda nandi yesterday | 1 | #!/usr/bin/env bash |
| Replace V with Nim 472eb49 nandithebull 19h ago | 2 | # iOS/macOS cannot run `nim` from inside Xcode's sandbox, and App Store builds |
| 3 | # want a static archive. So Nim's C output is generated ahead of time and |
| Initial commit: V -> Flutter FFI plugin ad0ccda nandi yesterday | 4 | # checked in; CocoaPods then compiles it like any other C source. |
| 5 | # |
| Replace V with Nim 472eb49 nandithebull 19h ago | 6 | # Unlike a single-file C emitter, Nim writes one .c per module plus nimbase.h, |
| 7 | # so the whole set is copied in and the stale ones cleared out first. |
| 8 | # |
| 9 | # Re-run this whenever src/nimflutter.nim changes. |
| Initial commit: V -> Flutter FFI plugin ad0ccda nandi yesterday | 10 | set -euo pipefail |
| 11 | cd "$(dirname "$0")/.." |
| Replace V with Nim 472eb49 nandithebull 19h ago | 12 | |
| 13 | nim_bin="${NIM:-nim}" |
| 14 | command -v "$nim_bin" >/dev/null || { |
| 15 | echo "Nim compiler not on PATH (set NIM=/path/to/nim)"; exit 1; } |
| 16 | nim_lib="$(dirname "$(dirname "$(command -v "$nim_bin")")")/lib" |
| 17 | |
| 18 | cache=build/nimcache_ios |
| 19 | rm -rf "$cache" |
| 20 | "$nim_bin" c --compileOnly --nimcache:"$cache" --mm:arc -d:danger \ |
| 21 | --threads:on --noMain src/nimflutter.nim |
| 22 | |
| 23 | for dir in ios/Classes macos/Classes; do |
| 24 | rm -f "$dir"/*.c "$dir"/*.h |
| 25 | mkdir -p "$dir" |
| 26 | # Nim's filenames encode module paths with @ and @s; harmless for the |
| 27 | # compiler, but CocoaPods globs are happier with flat names. |
| 28 | i=0 |
| 29 | for c in "$cache"/*.c; do |
| 30 | cp "$c" "$dir/nimflutter_$(printf '%02d' "$i").c" |
| 31 | i=$((i + 1)) |
| 32 | done |
| 33 | cp "$nim_lib/nimbase.h" "$dir/nimbase.h" |
| 34 | cp src/nimflutter.h "$dir/nimflutter.h" |
| 35 | done |
| 36 | |
| 37 | echo "regenerated ios/ + macos/ sources ($(ls ios/Classes/*.c | wc -l) C files)" |