Page MenuHomePhorge

D5509.1768800589.diff
No OneTemporary

Size
2 KB
Referenced Files
None
Subscribers
None

D5509.1768800589.diff

diff --git a/nix/dev-shell.nix b/nix/dev-shell.nix
--- a/nix/dev-shell.nix
+++ b/nix/dev-shell.nix
@@ -7,7 +7,6 @@
, better-prompt
, boost
, c-ares_cmake-config
-, cargo
, cmake
, cmake-format
, cocoapods
@@ -34,7 +33,6 @@
, python3
, redis
, redis-up
-, rustc
, rustup
, shellcheck
, sqlite
@@ -64,8 +62,6 @@
# native dependencies
# C/CXX toolchains are already brought in with mkShell
# Identity Service
- cargo # includes rustc
- rustc # allow for direct invocation of rustc
rustfmt
rustup
@@ -137,6 +133,9 @@
# Render default configuration for keyserver
$PRJ_ROOT/scripts/create_url_facts.sh
+ # Ensure rustup tooling is installed
+ $PRJ_ROOT/scripts/ensure_rustup_setup.sh
+
# Provide decent bash prompt
source "${better-prompt}/bin/better-prompt"
diff --git a/scripts/build-rust-native-library.sh b/scripts/build-rust-native-library.sh
--- a/scripts/build-rust-native-library.sh
+++ b/scripts/build-rust-native-library.sh
@@ -3,6 +3,7 @@
set -euxo pipefail
COMM_NIX_PATH="$HOME/.cache/comm/path"
+PRJ_ROOT="$(git rev-parse --show-toplevel)"
# If in nix environment, re-expose nix PATH
if [[ -f "$COMM_NIX_PATH" ]]; then
@@ -15,13 +16,13 @@
# developer tools that your Cargo isn't expecting to use, fix that.
# Note: This assumes a default `rustup` setup and default path.
build_path="$HOME/.cargo/bin:/usr/local/bin:/usr/bin:/bin${PATH:+:}$PATH"
+
# cd to Cargo project
cd "${SRCROOT}/../native_rust_library" || exit
-# Add iOS targets for cross-compilation
-env PATH="${build_path}" rustup target add aarch64-apple-ios
-env PATH="${build_path}" rustup target add x86_64-apple-ios
-# Install cargo lipo
-env PATH="${build_path}" cargo install cargo-lipo
+
+# Ensure rust tooling is available
+env PATH="${build_path}" "$PRJ_ROOT/scripts/ensure_rustup_setup.sh"
+
# Set C++ standard and build cxx bridge
export CXXFLAGS="-std=c++14"
env PATH="${build_path}" cargo build
diff --git a/scripts/ensure_rustup_setup.sh b/scripts/ensure_rustup_setup.sh
new file mode 100755
--- /dev/null
+++ b/scripts/ensure_rustup_setup.sh
@@ -0,0 +1,25 @@
+#!/usr/bin/env bash
+
+ensure_target() {
+ local target="$1"
+
+ if ! rustup target list --installed | grep "$target" > /dev/null; then
+ rustup target add "$1"
+ fi
+}
+
+if ! command -v rustup > /dev/null; then
+ echo "Please install rustup" >&2
+ exit 1
+fi
+
+if [[ "$(rustup toolchain list)" == "no installed toolchains" ]]; then
+ rustup toolchain install stable
+fi
+
+ensure_target aarch64-apple-ios
+ensure_target x86_64-apple-ios
+
+if ! command -v cargo-lipo > /dev/null; then
+ cargo install cargo-lipo
+fi

File Metadata

Mime Type
text/plain
Expires
Mon, Jan 19, 5:29 AM (19 h, 10 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5954603
Default Alt Text
D5509.1768800589.diff (2 KB)

Event Timeline