Created
September 30, 2023 17:34
-
-
Save CompeyDev/7852bf43d6bcb49b4c5bb6442fccbe65 to your computer and use it in GitHub Desktop.
Revisions
-
CompeyDev created this gist
Sep 30, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,39 @@ > [!NOTE] > This guide assumes that you're building for aarch64-linux-android only, but a similar approach should apply to other CPU architectures too. To build and run lune for android, you need to do the following: - Set up your cargo config: ```toml [target.aarch64-linux-android] ar = "$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android-ar" rustflags = ["-C", "linker=aarch64-linux-android-clang", "-C", "link-args=-rdynamic", "-C", "default-linker-libraries"] linker = "$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android-clang" ``` - The latest android NDK has paths different from those that cargo expects, so we need to create the following symlinks: - `$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar -> aarch64-linux-android-ar` - `$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android33-clang -> aarch64-linux-android-clang` - Make sure that `$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin` is in your path. - Build the binary: ```sh cargo build --release --target aarch64-linux-android ``` - The compiled output can be found at: `./target/aarch64-linux-android/release/lune` - To run lune, we'll need `libc++` for the linker as `libc` is always linked dynamically by cargo. We can find the library at `$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/libc++_shared.so`. - On android, store the `libc++_shared.so` file at `$PREFIX/lib/libc++_shared.so`. - Add the `$PREFIX/lib` to LD_LIBRARY_PATH. ```sh export LD_LIBRARY_PATH=$PREFIX/lib ``` - Run lune. - Profit?