|
| 1 | +# `scripts/` — index |
| 2 | + |
| 3 | +Every shell script in the repo lives in one of these places, organized by scope: |
| 4 | + |
| 5 | +## Repo-root `scripts/` (cross-cutting) |
| 6 | + |
| 7 | +| Script | Purpose | |
| 8 | +|---|---| |
| 9 | +| `detect-mode.sh` | Sources `$CI` / `$GITHUB_ACTIONS` to export `RAC_BUILD_MODE=local\|ci`. Other scripts `source` it to share the same detection. | |
| 10 | +| `sync-versions.sh <version>` | Bumps the version string in every manifest across the monorepo (`VERSION`, `VERSIONS`, `Package.swift`, `gradle.properties`, all `package.json`, all `pubspec.yaml`). Run locally before tagging a release. | |
| 11 | +| `sync-checksums.sh <zip_dir>` | Reads SHA-256 of freshly-built XCFramework zips and updates the `checksum: "..."` lines in root `Package.swift`. Run in the release workflow after native iOS/macOS builds produce the zips. | |
| 12 | +| `validate-artifact.sh <file>...` | Type-aware sanity check for each artifact extension (XCFramework Info.plist + slices, `.so` ELF magic, `.aar` classes.jar + jni, `.wasm` magic bytes, `.tgz` package.json). Same script runs locally and in CI. | |
| 13 | +| `lint-all.sh`, `lint-android.sh`, `lint-ios.sh` | Cross-project lint runners (pre-existing — not part of the artifact system). | |
| 14 | + |
| 15 | +## Per-SDK `sdk/runanywhere-<lang>/scripts/` |
| 16 | + |
| 17 | +Each client SDK has a `scripts/` folder next to its source with scripts scoped to that SDK. Two canonical names to know: |
| 18 | + |
| 19 | +| Name | Purpose | |
| 20 | +|---|---| |
| 21 | +| `build-<lang>.sh` | **Developer pipeline orchestrator.** Full build from source — rebuilds C++ (runanywhere-commons), copies natives into place, then builds the SDK. For day-to-day iteration. | |
| 22 | +| `package-sdk.sh` | **Unified release packaging contract.** Consumes *pre-built* natives (from `--natives-from PATH` or canonical `dist/` location) and produces the SDK's distributable artifacts (AAR/JAR, npm `.tgz`, etc.) with `.sha256` sidecars. Same interface across every SDK: `package-sdk.sh [--mode local|ci] [--natives-from PATH]`. | |
| 23 | + |
| 24 | +Per-SDK scripts currently in tree: |
| 25 | + |
| 26 | +``` |
| 27 | +sdk/runanywhere-swift/scripts/ |
| 28 | + build-swift.sh # --setup | --build-commons | --set-local | --set-remote |
| 29 | + package-sdk.sh # unified contract |
| 30 | + create-onnxruntime-xcframework.sh # one-shot helper for building the combined ONNXRuntime xcframework |
| 31 | +
|
| 32 | +sdk/runanywhere-kotlin/scripts/ |
| 33 | + build-kotlin.sh # full pipeline |
| 34 | + build-sdk.sh # thin wrapper over build-kotlin.sh |
| 35 | + package-sdk.sh # unified contract |
| 36 | +
|
| 37 | +sdk/runanywhere-web/scripts/ |
| 38 | + build-web.sh # WASM + TypeScript build |
| 39 | + package-sdk.sh # unified contract |
| 40 | +
|
| 41 | +sdk/runanywhere-flutter/scripts/ |
| 42 | + build-flutter.sh # developer pipeline |
| 43 | + package-sdk.sh # unified contract |
| 44 | +
|
| 45 | +sdk/runanywhere-react-native/scripts/ |
| 46 | + build-react-native.sh # developer pipeline |
| 47 | + package-sdk.sh # unified contract |
| 48 | +``` |
| 49 | + |
| 50 | +## `sdk/runanywhere-commons/scripts/` (C++ native build) |
| 51 | + |
| 52 | +Native library build scripts for commons + each backend. Stay here because they use relative paths to commons' `CMakeLists.txt` and `third_party/`. |
| 53 | + |
| 54 | +``` |
| 55 | +sdk/runanywhere-commons/scripts/ |
| 56 | + build-ios.sh # iOS + macOS XCFrameworks |
| 57 | + build-android.sh # per-ABI .so via NDK |
| 58 | + build-linux.sh # Linux x86_64 .so / static .a |
| 59 | + build-windows.bat # Windows MSVC .lib/.dll |
| 60 | + build-server.sh # OpenAI-compatible HTTP server (optional target) |
| 61 | + load-versions.sh # sources VERSIONS file into $ENV; sourced by all build-*.sh |
| 62 | +
|
| 63 | + ios/download-onnx.sh # ONNX Runtime for iOS |
| 64 | + ios/download-sherpa-onnx.sh # Sherpa-ONNX for iOS |
| 65 | + android/download-sherpa-onnx.sh # Sherpa-ONNX for Android (all ABIs) |
| 66 | + linux/download-sherpa-onnx.sh # Sherpa-ONNX for Linux |
| 67 | + macos/download-onnx.sh # ONNX Runtime for macOS |
| 68 | + macos/download-sherpa-onnx.sh # Sherpa-ONNX for macOS |
| 69 | + windows/download-sherpa-onnx.bat # Sherpa-ONNX for Windows |
| 70 | +``` |
| 71 | + |
| 72 | +Output convention: all scripts write to `sdk/runanywhere-commons/dist/<platform>/...` (canonical). |
| 73 | + |
| 74 | +## Test scripts — `sdk/runanywhere-commons/tests/scripts/` |
| 75 | + |
| 76 | +``` |
| 77 | +run-tests.sh # per-platform entry |
| 78 | +run-tests-{ios,android,linux,web}.sh |
| 79 | +run-tests-all.sh |
| 80 | +download-test-models.sh |
| 81 | +``` |
| 82 | + |
| 83 | +## WASM build — `sdk/runanywhere-web/wasm/scripts/` |
| 84 | + |
| 85 | +Emscripten-specific helpers invoked by the top-level `build-web.sh`: |
| 86 | + |
| 87 | +``` |
| 88 | +build.sh # WASM compile orchestrator |
| 89 | +build-sherpa-onnx.sh # Sherpa-ONNX WASM module |
| 90 | +setup-emsdk.sh # installs Emscripten toolchain |
| 91 | +``` |
| 92 | + |
| 93 | +## Why scripts aren't all in one folder |
| 94 | + |
| 95 | +The build scripts use `SCRIPT_DIR/..` relative paths to find their project's `CMakeLists.txt`, `VERSIONS` file, and `third_party/` folder. Moving them would require rewriting those paths and breaks the "script is scoped to the project it builds" convention that every platform's build system follows. |
| 96 | + |
| 97 | +**Rule of thumb when adding a new script:** |
| 98 | +- **Cross-cutting utility that operates on multiple SDKs or the whole repo?** → `scripts/` at repo root. |
| 99 | +- **Scoped to one SDK's build/release/test flow?** → `sdk/runanywhere-<lang>/scripts/`. |
| 100 | +- **Native build helper that depends on commons' CMake?** → `sdk/runanywhere-commons/scripts/`. |
| 101 | +- **Test runner?** → `sdk/runanywhere-commons/tests/scripts/`. |
| 102 | + |
| 103 | +## CI workflows that call these scripts |
| 104 | + |
| 105 | +- `.github/workflows/pr-build.yml` — calls `build-{ios,android,linux,web}.sh` and `build-windows.bat` for native matrix jobs; calls each SDK's build/gradle/npm tooling for SDK jobs. |
| 106 | +- `.github/workflows/release.yml` — same native matrix, plus invokes `package-sdk.sh` per SDK and `sync-checksums.sh` after iOS builds land. |
| 107 | +- `.github/actions/setup-toolchain/action.yml` — loads `sdk/runanywhere-commons/VERSIONS` into `$GITHUB_ENV` so every script sees the same pinned tool versions. |
0 commit comments