improve the initial install experience.
Made it easier to get up and running wit Rust, rather than relying entirely on one-time configuration that is hard to remember, later down the line.
This commit is contained in:
parent
d1738e2862
commit
8fbb08aeae
|
@ -62,3 +62,6 @@ fastlane/Preview.html
|
|||
fastlane/screenshots
|
||||
fastlane/test_output
|
||||
fastlane/readme.md
|
||||
|
||||
# rust
|
||||
.cargo/
|
||||
|
|
|
@ -6,7 +6,7 @@ buildscript {
|
|||
|
||||
}
|
||||
dependencies {
|
||||
classpath("com.android.tools.build:gradle:3.3.0-alpha13")
|
||||
classpath("com.android.tools.build:gradle:3.4.0-alpha02")
|
||||
classpath(kotlin("gradle-plugin", version = "1.2.71"))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
#!/usr/bin/zsh
|
||||
|
||||
# put this somewhere that's often ignored by git
|
||||
output_dir=out/ndk/standalone
|
||||
|
||||
# check for NDK standalone
|
||||
[[ -d "$output_dir" ]] && echo "Standalone NDK files found!" && exit 1
|
||||
|
||||
standalone_script=$(find $ANDROID_HOME -name "*make_standalone_toolchain.py")
|
||||
|
||||
# Try to find and print some info about the NDK based on the location of the toolchain script
|
||||
if [ ! -f "$standalone_script" ]; then
|
||||
echo "NDK not found. Please make sure that ANDROID_HOME is set and the NDK has been installed there"
|
||||
else
|
||||
echo "Standalone NDK files appear to be missing.\n Attempting to install them..."
|
||||
ndk_dir=$(dirname $(dirname $(dirname $standalone_script 2>/dev/null) 2>/dev/null) 2>/dev/null)
|
||||
ndk_version=$(grep -oE "[0-9.]{5,}" /home/gmale/kg/setup/android/sdk/ndk-bundle/source.properties 2>/dev/null)
|
||||
echo " NDK version $ndk_version found at $ndk_dir"
|
||||
fi
|
||||
|
||||
echo " Installing the standalone NDK for x86|arm|arm64 into $output_dir"
|
||||
mkdir -p $output_dir
|
||||
"$standalone_script" --arch x86 --api 16 --install-dir "$output_dir/x86"
|
||||
"$standalone_script" --arch arm --api 16 --install-dir "$output_dir/arm"
|
||||
"$standalone_script" --arch arm64 --api 21 --install-dir "$output_dir/arm64"
|
||||
|
||||
# check for our generated cargo file
|
||||
generated_cargo_config=../.cargo/config
|
||||
|
||||
if [ -f "$generated_cargo_config" ]; then
|
||||
backup_config_filename="config.$(date +%s).backup"
|
||||
echo " existing config found. Backing it up from $generated_cargo_config to $(dirname $generated_cargo_config)/$backup_config_filename"
|
||||
cp $generated_cargo_config $(dirname $generated_cargo_config)/$backup_config_filename
|
||||
fi
|
||||
|
||||
echo " generating cargo config at $generated_cargo_config"
|
||||
|
||||
mkdir -p $(dirname $generated_cargo_config)
|
||||
|
||||
awk -v SA_NDK=$output_dir -v SCRIPT_DIR=$PWD 'BEGIN{
|
||||
|
||||
printf "#auto-generated by build-ndk-standalone.sh\n\n"
|
||||
|
||||
printf "[target.i686-linux-android]\n"
|
||||
printf "ar = \"%s/%s/x86/bin/i686-linux-android-ar\"\n", SCRIPT_DIR, SA_NDK
|
||||
printf "linker = \"%s/%s/x86/bin/i686-linux-android-clang\"\n\n", SCRIPT_DIR, SA_NDK
|
||||
|
||||
printf "[target.armv7-linux-androideabi]\n"
|
||||
printf "ar = \"%s/%s/arm/bin/arm-linux-androideabi-ar\"\n", SCRIPT_DIR, SA_NDK
|
||||
printf "linker = \"%s/%s/arm/bin/arm-linux-androideabi-clang\"\n\n", SCRIPT_DIR, SA_NDK
|
||||
|
||||
printf "[target.aarch64-linux-android]\n"
|
||||
printf "ar = \"%s/%s/arm64/bin/aarch64-linux-android-ar\"\n", SCRIPT_DIR, SA_NDK
|
||||
printf "linker = \"%s/%s/arm64/bin/aarch64-linux-android-clang\"\n\n", SCRIPT_DIR, SA_NDK
|
||||
|
||||
}' > $generated_cargo_config
|
||||
|
||||
echo "Done"
|
||||
|
||||
|
|
@ -1,3 +1,32 @@
|
|||
#!/usr/bin/zsh
|
||||
|
||||
# check for cargo installation
|
||||
if ! type -p ~/.cargo/bin/cargo > /dev/null; then
|
||||
echo "Cargo appears to be missing.\nTry installing it with the following command:\n curl https://sh.rustup.rs -sSf | sh"
|
||||
echo "and then run this script again."
|
||||
exit 1
|
||||
fi
|
||||
echo "Cargo found!"
|
||||
|
||||
# check for android targets
|
||||
installed_android_target_count=$(~/.cargo/bin/rustup target list | grep android | grep installed | wc -l)
|
||||
if [ "$installed_android_target_count" -lt "3" ]; then
|
||||
echo "The android targets do not appear to be installed."
|
||||
echo "attempting to install them...\n ~/.cargo/bin/rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android"
|
||||
~/.cargo/bin/rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android
|
||||
[[ $(~/.cargo/bin/rustup target list | grep android | grep installed | wc -l) -lt 3 ]] && echo "install failed. Aborting!" && exit 1
|
||||
echo "Done."
|
||||
fi
|
||||
|
||||
echo "Android targets found!"
|
||||
|
||||
# check for standalone NDK
|
||||
./build-ndk-standalone.sh
|
||||
|
||||
|
||||
echo "Building..."
|
||||
cargo build --target aarch64-linux-android --release
|
||||
cargo build --target i686-linux-android --release
|
||||
cargo build --target armv7-linux-androideabi --release
|
||||
cargo build --target armv7-linux-androideabi --release
|
||||
|
||||
echo "Done."
|
||||
|
|
Loading…
Reference in New Issue