Locate the Android SDK and the library directory the way the build
system lays them out download-sdk.sh unpacks the SDK as buildscripts/sdk/android-sdk-linux, and mpv-android keeps the libraries in app/src/main/libs with jniLibs pointing at it. Check those names first, fall back to a platforms/ search, and write the libraries into libs/<abi> while recreating the alias.
This commit is contained in:
1 parent
68fc020260
commit
8ed49a1170
1 file changed
+27
-16
@@ -166,18 +166,18 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
abi=arm64-v8a
|
abi=arm64-v8a
|
||||||
jni="$GITHUB_WORKSPACE/android/app/src/main/jniLibs"
|
main="$GITHUB_WORKSPACE/android/app/src/main"
|
||||||
# The checkout carries this path as a symlink (pointing at a prefix
|
# mpv-android keeps the libraries in src/main/libs and points jniLibs
|
||||||
# directory for an ABI we do not build), and mkdir -p refuses a
|
# at it with a relative symlink; the link dangles until that directory
|
||||||
# dangling link with "File exists". Replace it with a plain directory.
|
# exists, so write into libs and keep the alias intact.
|
||||||
if [ -L "$jni" ]; then
|
if [ -L "$main/jniLibs" ]; then
|
||||||
echo "jniLibs is a symlink to $(readlink "$jni" 2>/dev/null || echo '?'); replacing it"
|
echo "jniLibs is a symlink to $(readlink "$main/jniLibs" 2>/dev/null || echo '?')"
|
||||||
rm -f "$jni"
|
rm -f "$main/jniLibs"
|
||||||
elif [ -e "$jni" ] && [ ! -d "$jni" ]; then
|
elif [ -e "$main/jniLibs" ] && [ ! -d "$main/jniLibs" ]; then
|
||||||
echo "jniLibs is a file; replacing it with a directory"
|
echo "jniLibs is a file; moving it aside"
|
||||||
rm -f "$jni"
|
rm -f "$main/jniLibs"
|
||||||
fi
|
fi
|
||||||
libs="$jni/$abi"
|
libs="$main/libs/$abi"
|
||||||
mkdir -p "$libs"
|
mkdir -p "$libs"
|
||||||
cp "$GITHUB_WORKSPACE/android/buildscripts/prefix/arm64/lib/libmpv.so" "$libs/"
|
cp "$GITHUB_WORKSPACE/android/buildscripts/prefix/arm64/lib/libmpv.so" "$libs/"
|
||||||
cp "$GITHUB_WORKSPACE/joc/build-android/libjoc_core.so" "$libs/"
|
cp "$GITHUB_WORKSPACE/joc/build-android/libjoc_core.so" "$libs/"
|
||||||
@@ -186,6 +186,9 @@ jobs:
|
|||||||
-path '*/sysroot/usr/lib/aarch64-linux-android/libc++_shared.so' -print -quit)
|
-path '*/sysroot/usr/lib/aarch64-linux-android/libc++_shared.so' -print -quit)
|
||||||
test -n "$libcxx"
|
test -n "$libcxx"
|
||||||
cp "$libcxx" "$libs/"
|
cp "$libcxx" "$libs/"
|
||||||
|
if [ ! -e "$main/jniLibs" ]; then
|
||||||
|
ln -s libs "$main/jniLibs"
|
||||||
|
fi
|
||||||
ls -lh "$libs"
|
ls -lh "$libs"
|
||||||
|
|
||||||
- name: Cache the Gradle home
|
- name: Cache the Gradle home
|
||||||
@@ -201,26 +204,34 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
# download-sdk.sh unpacks the SDK under android/buildscripts/sdk; find
|
# download-sdk.sh unpacks the SDK under android/buildscripts/sdk; find
|
||||||
# the root by its platforms/ directory instead of hard-coding the name.
|
# the root from its platforms/ directory instead of hard-coding the
|
||||||
|
# layout (the current one is sdk/android-sdk-linux).
|
||||||
sdk_dir=""
|
sdk_dir=""
|
||||||
for candidate in \
|
for candidate in \
|
||||||
|
"$GITHUB_WORKSPACE/android/buildscripts/sdk/android-sdk-linux" \
|
||||||
"$GITHUB_WORKSPACE/android/buildscripts/sdk/android-sdk" \
|
"$GITHUB_WORKSPACE/android/buildscripts/sdk/android-sdk" \
|
||||||
"$GITHUB_WORKSPACE/android/buildscripts/sdk"; do
|
"$GITHUB_WORKSPACE/android/buildscripts/sdk"; do
|
||||||
if [ -d "$candidate/platforms" ]; then sdk_dir="$candidate"; break; fi
|
if [ -d "$candidate/platforms" ]; then sdk_dir="$candidate"; break; fi
|
||||||
done
|
done
|
||||||
|
if [ -z "$sdk_dir" ]; then
|
||||||
|
platforms=$(find "$GITHUB_WORKSPACE/android/buildscripts/sdk" \
|
||||||
|
-maxdepth 2 -type d -name platforms -print -quit 2>/dev/null || true)
|
||||||
|
if [ -n "$platforms" ]; then sdk_dir=$(dirname "$platforms"); fi
|
||||||
|
fi
|
||||||
if [ -z "$sdk_dir" ]; then
|
if [ -z "$sdk_dir" ]; then
|
||||||
echo "::error::no Android SDK (no platforms/ directory) under android/buildscripts/sdk"
|
echo "::error::no Android SDK (no platforms/ directory) under android/buildscripts/sdk"
|
||||||
find "$GITHUB_WORKSPACE/android/buildscripts/sdk" -maxdepth 2 -type d | head -40
|
find "$GITHUB_WORKSPACE/android/buildscripts/sdk" -maxdepth 3 -type d | head -40
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
echo "Android SDK: $sdk_dir"
|
||||||
echo "ANDROID_SDK_ROOT=$sdk_dir" >> "$GITHUB_ENV"
|
echo "ANDROID_SDK_ROOT=$sdk_dir" >> "$GITHUB_ENV"
|
||||||
echo "ANDROID_HOME=$sdk_dir" >> "$GITHUB_ENV"
|
echo "ANDROID_HOME=$sdk_dir" >> "$GITHUB_ENV"
|
||||||
echo "sdk.dir=$sdk_dir" > "$GITHUB_WORKSPACE/android/local.properties"
|
echo "sdk.dir=$sdk_dir" > "$GITHUB_WORKSPACE/android/local.properties"
|
||||||
# Accept the SDK licences, so AGP may install whatever compileSdk or
|
# Accept the SDK licences, so AGP may install whatever compileSdk or
|
||||||
# build-tools the app asks for instead of failing on an unaccepted hash.
|
# build-tools the app asks for instead of failing on an unaccepted hash.
|
||||||
if [ -x "$sdk_dir/cmdline-tools/latest/bin/sdkmanager" ]; then
|
sdkmanager=$(find "$sdk_dir/cmdline-tools" -maxdepth 3 -type f -name sdkmanager -print -quit 2>/dev/null || true)
|
||||||
yes | "$sdk_dir/cmdline-tools/latest/bin/sdkmanager" \
|
if [ -n "$sdkmanager" ]; then
|
||||||
--sdk_root="$sdk_dir" --licenses >/dev/null 2>&1 || true
|
yes | "$sdkmanager" --sdk_root="$sdk_dir" --licenses >/dev/null 2>&1 || true
|
||||||
fi
|
fi
|
||||||
# The NDK is unpacked as android-ndk-<release>; AGP looks it up by the
|
# The NDK is unpacked as android-ndk-<release>; AGP looks it up by the
|
||||||
# source.properties revision under ndk/, so link it there too.
|
# source.properties revision under ndk/, so link it there too.
|
||||||
|
|||||||
Reference in new issue
Block a user