Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Document tvOS Rust build setup

Manav Rathie68cf8429709
diff --git a/mobile/native/android/packages/rust/scripts/build-rust.sh b/mobile/native/android/packages/rust/scripts/build-rust.sh
index 2fb672e476..ea95eae431 100755
--- a/mobile/native/android/packages/rust/scripts/build-rust.sh
+++ b/mobile/native/android/packages/rust/scripts/build-rust.sh
@@ -1,16 +1,7 @@
#!/usr/bin/env bash
-# Build Ensu's UniFFI Rust JNI libs for the current Gradle build.
-# Invoked from Gradle's `buildRustJni` task (../build.gradle.kts).
-#
-# Inputs (CLI args): --toolchain DIR --out-dir DIR <abi>...
-# <abi> is one of arm64-v8a, armeabi-v7a, x86_64.
-# Outputs (to $OUT_DIR/<abi>):
-# libcore.so libdb.so libsync.so libinference.so
-# libtranscription.so libc++_shared.so
-#
-# UniFFI Kotlin bindings are generated out-of-band by `cargo codegen
-# ensu-android`; this script only builds the JNI libs.
+# This script is invoked from Gradle's `buildRustJni` task.
+# It builds the JNI libraries used by Ensu's generated UniFFI bindings.
set -euo pipefail
diff --git a/mobile/native/darwin/Apps/Ensu/README.md b/mobile/native/darwin/Apps/Ensu/README.md
index d8abce3758..6618a42965 100644
--- a/mobile/native/darwin/Apps/Ensu/README.md
+++ b/mobile/native/darwin/Apps/Ensu/README.md
@@ -2,8 +2,6 @@
Source code for the Ensu iOS app.
-To know more about Ente, see [our main README](../../../../../README.md) or visit [ente.com](https://ente.com).
-
## Building from source
1. Install [Xcode](https://developer.apple.com/xcode/), [Rust](https://www.rust-lang.org/tools/install), and CMake (e.g. `brew install cmake`).
diff --git a/mobile/native/darwin/Apps/Ensu/scripts/build-rust.sh b/mobile/native/darwin/Apps/Ensu/scripts/build-rust.sh
index afd343eee1..728bfabb8f 100755
--- a/mobile/native/darwin/Apps/Ensu/scripts/build-rust.sh
+++ b/mobile/native/darwin/Apps/Ensu/scripts/build-rust.sh
@@ -1,17 +1,7 @@
#!/usr/bin/env bash
-# Build Ensu's UniFFI Rust static libs for the current Xcode build.
-# Invoked from an Xcode "Run Script" build phase.
-#
-# Inputs (from Xcode): SRCROOT, TARGET_TEMP_DIR, PLATFORM_NAME, ARCHS,
-# CONFIGURATION, IPHONEOS_DEPLOYMENT_TARGET,
-# ENTE_API_ENDPOINT.
-# Outputs (to $TARGET_TEMP_DIR/ensu_rust):
-# libcore.a libdb.a libsync.a libinference.a libtranscription.a
-#
-# UniFFI Swift bindings under $SRCROOT/Ensu/Generated/ are generated
-# out-of-band by `cargo codegen ensu-ios`; this script only checks that
-# they exist.
+# This script is invoked from Xcode's "Run Script" build phase.
+# It builds the Rust static libraries used by Ensu's generated UniFFI bindings.
set -euo pipefail
diff --git a/mobile/native/darwin/Apps/tv/README.md b/mobile/native/darwin/Apps/tv/README.md
new file mode 100644
index 0000000000..1df5520b71
--- /dev/null
+++ b/mobile/native/darwin/Apps/tv/README.md
@@ -0,0 +1,13 @@
+# Ente Cast for tvOS
+
+Source code for the Ente Cast tvOS app.
+
+## Building from source
+
+1. Install [Xcode](https://developer.apple.com/xcode/) and [Rust](https://www.rust-lang.org/tools/install). In Xcode install the tvOS platform.
+
+2. Open `tv.xcodeproj` in Xcode and run the `cast` scheme.
+
+> [!NOTE]
+>
+> The first build will install the Rust `nightly` toolchain and `rust-src`. They are needed for building Rust for tvOS targets.
diff --git a/mobile/native/darwin/Apps/tv/scripts/build-rust.sh b/mobile/native/darwin/Apps/tv/scripts/build-rust.sh
index 68dcb3bd82..bf268428e5 100644
--- a/mobile/native/darwin/Apps/tv/scripts/build-rust.sh
+++ b/mobile/native/darwin/Apps/tv/scripts/build-rust.sh
@@ -1,6 +1,9 @@
#!/bin/sh
set -eu
+# This script is invoked from Xcode's "Run Script" build phase.
+# It builds the Rust crypto static lib for the current tvOS target.
+
REPO_ROOT=$(cd "$SRCROOT/../../../../.." && pwd)
OUT_DIR="$TARGET_TEMP_DIR/ente_crypto_rust"
LIB=libente_crypto_ffi.a
@@ -9,6 +12,13 @@ export PATH="${CARGO_HOME:-$HOME/.cargo}/bin:/opt/homebrew/bin:/usr/local/bin:$P
mkdir -p "$OUT_DIR"
+# Rust supports tvOS targets, but rustup does not ship precompiled std for them.
+# Building std from source requires nightly and rust-src.
+rustup toolchain list | grep -q '^nightly-' \
+ || rustup toolchain install nightly --profile minimal
+rustup component list --toolchain nightly --installed | grep -qx rust-src \
+ || rustup component add rust-src --toolchain nightly
+
case "${CONFIGURATION:-Debug}" in
Release) profile=release; release_flag=--release ;;
*) profile=debug; release_flag= ;;
@@ -26,16 +36,12 @@ for arch in $ARCHS; do
*) echo "unsupported arch: $PLATFORM_NAME/$arch" >&2; exit 1 ;;
esac
- rustflags="-C linker=$clang -C link-arg=-isysroot -C link-arg=$sdk"
- if [ -n "${TVOS_DEPLOYMENT_TARGET:-}" ]; then
- rustflags="$rustflags -C link-arg=$min_flag=$TVOS_DEPLOYMENT_TARGET"
- fi
+ rustflags="-C linker=$clang -C link-arg=-isysroot -C link-arg=$sdk -C link-arg=$min_flag=$TVOS_DEPLOYMENT_TARGET"
(
cd "$REPO_ROOT/rust"
CC="$clang" \
CFLAGS="-isysroot $sdk" \
- CARGO_TARGET_DIR="$REPO_ROOT/rust/target" \
RUSTFLAGS="$rustflags" \
cargo +nightly build -Z build-std --locked -p ente_crypto_ffi --target "$target" $release_flag
)