nandi/vflutter_ffipublic Fork 0
4506a586d7400b00d732dcb97167be75ab41cab1
Commits
Clone
git clone https://git.rickub.com/nandi/vflutter_ffi.git
git clone ssh://git@rickub.com/nandi/vflutter_ffi.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

gen_ios_sources.sh · 37 lines · 1.3 KBBash Blame HistoryRaw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env bash
# iOS/macOS cannot run `nim` from inside Xcode's sandbox, and App Store builds
# want a static archive. So Nim's C output is generated ahead of time and
# checked in; CocoaPods then compiles it like any other C source.
#
# Unlike a single-file C emitter, Nim writes one .c per module plus nimbase.h,
# so the whole set is copied in and the stale ones cleared out first.
#
# Re-run this whenever src/nimflutter.nim changes.
set -euo pipefail
cd "$(dirname "$0")/.."

nim_bin="${NIM:-nim}"
command -v "$nim_bin" >/dev/null || {
  echo "Nim compiler not on PATH (set NIM=/path/to/nim)"; exit 1; }
nim_lib="$(dirname "$(dirname "$(command -v "$nim_bin")")")/lib"

cache=build/nimcache_ios
rm -rf "$cache"
"$nim_bin" c --compileOnly --nimcache:"$cache" --mm:arc -d:danger \
  --threads:on --noMain src/nimflutter.nim

for dir in ios/Classes macos/Classes; do
  rm -f "$dir"/*.c "$dir"/*.h
  mkdir -p "$dir"
  # Nim's filenames encode module paths with @ and @s; harmless for the
  # compiler, but CocoaPods globs are happier with flat names.
  i=0
  for c in "$cache"/*.c; do
    cp "$c" "$dir/nimflutter_$(printf '%02d' "$i").c"
    i=$((i + 1))
  done
  cp "$nim_lib/nimbase.h" "$dir/nimbase.h"
  cp src/nimflutter.h "$dir/nimflutter.h"
done

echo "regenerated ios/ + macos/ sources ($(ls ios/Classes/*.c | wc -l) C files)"