forked from spacedriveapp/spacedrive
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New Android Build Script (spacedriveapp#2096)
* New Android Build Script * Clean up + Works for CI now * Simplify android build.sh - Fix /var/home/vitor fallback for Linux systems - Run a single cargo ndk for all targets (not parallel build, but a bit faster) - Fix android target s/x86/x86_64/ - Format setup.sh - Minor improvements to rust mobile targets installation step in setup.sh * Add notice to CONTRIBUTING that only Java <= 17 is supported for building android - Make prettier ignore some mobile build artifacts * When in CI, Fix build android core for host architecture --------- Co-authored-by: Vítor Vasconcellos <vasconcellos.dev@gmail.com>
- Loading branch information
1 parent
19b2243
commit 2a28347
Showing
5 changed files
with
110 additions
and
58 deletions.
There are no files selected for viewing
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#!/usr/bin/env sh | ||
|
||
set -eu | ||
|
||
if [ "${CI:-}" = "true" ]; then | ||
set -x | ||
fi | ||
|
||
err() { | ||
for _line in "$@"; do | ||
echo "$_line" >&2 | ||
done | ||
exit 1 | ||
} | ||
|
||
if [ -z "${HOME:-}" ]; then | ||
case "$(uname)" in | ||
"Darwin") | ||
HOME="$(CDPATH='' cd -- "$(osascript -e 'set output to (POSIX path of (path to home folder))')" && pwd -P)" | ||
;; | ||
"Linux") | ||
HOME="$(CDPATH='' cd -- "$(getent passwd "$(id -un)" | cut -d: -f6)" && pwd -P)" | ||
;; | ||
*) | ||
err "Your OS ($(uname)) is not supported by this script." \ | ||
'We would welcome a PR or some help adding your OS to this script.' \ | ||
'https://github.com/spacedriveapp/spacedrive/issues' | ||
;; | ||
esac | ||
|
||
export HOME | ||
fi | ||
|
||
echo "Building 'sd-mobile-android' library..." | ||
|
||
__dirname="$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)" | ||
|
||
# Ensure output dir exists | ||
OUTPUT_DIRECTORY="${__dirname}/../../../../../apps/mobile/android/app/src/main/jniLibs" | ||
mkdir -p "$OUTPUT_DIRECTORY" | ||
|
||
# Required for CI and for everyone I guess? | ||
export PATH="${CARGO_HOME:-"${HOME}/.cargo"}/bin:$PATH" | ||
|
||
# Set the targets to build | ||
# If CI, then we build x86_64 else we build all targets | ||
if [ "${CI:-}" = "true" ]; then | ||
# TODO: This need to be adjusted for future mobile release CI | ||
case "$(uname -m)" in | ||
"arm64" | "aarch64") | ||
ANDROID_BUILD_TARGET_LIST="arm64-v8a" | ||
;; | ||
"x86_64") | ||
ANDROID_BUILD_TARGET_LIST="x86_64" | ||
;; | ||
*) | ||
err 'Unsupported architecture for CI build.' | ||
;; | ||
esac | ||
else | ||
ANDROID_BUILD_TARGET_LIST="arm64-v8a armeabi-v7a x86_64" | ||
fi | ||
|
||
# Configure build targets CLI arg for `cargo ndk` | ||
echo "Building targets: $ANDROID_BUILD_TARGET_LIST" | ||
set -- | ||
for _target in $ANDROID_BUILD_TARGET_LIST; do | ||
set -- "$@" -t "$_target" | ||
done | ||
|
||
cd "${__dirname}/crate" | ||
cargo ndk --platform 34 "$@" -o "$OUTPUT_DIRECTORY" build --release |
This file contains 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 characters