Skip to content

Commit cc99f23

Browse files
committed
Changes per PR feedback
Fix script to use NDK version found in tools.versions.toml
1 parent 14b9d95 commit cc99f23

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

file_operations/setup_rust_android.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,25 @@ find_android_sdk() {
3535
fi
3636
}
3737

38-
# Function to find the latest NDK version
38+
# Function to find the NDK version (from tools.versions.toml or latest)
3939
find_ndk_version() {
4040
local sdk_path="$1"
4141
local ndk_dir="$sdk_path/ndk"
42-
42+
local version_catalog="../gradle/tools.versions.toml"
43+
44+
# First, try to read NDK version from tools.versions.toml
45+
if [ -f "$version_catalog" ]; then
46+
local ndk_version=$(grep "^ndk" "$version_catalog" | cut -d '"' -f 2)
47+
if [ -n "$ndk_version" ] && [ -d "$ndk_dir/$ndk_version" ]; then
48+
echo "$ndk_version"
49+
return
50+
elif [ -n "$ndk_version" ]; then
51+
echo "⚠️ Warning: NDK version $ndk_version specified in tools.versions.toml not found in $ndk_dir" >&2
52+
echo " Falling back to latest available version..." >&2
53+
fi
54+
fi
55+
56+
# Fall back to finding the latest version
4357
if [ -d "$ndk_dir" ]; then
4458
# Find the latest version (highest version number)
4559
ls -1 "$ndk_dir" | sort -V | tail -n 1

0 commit comments

Comments
 (0)