Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add x86_64 to the Android plugin build script #952

Merged
merged 6 commits into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
45 changes: 24 additions & 21 deletions BuildScripts~/build_plugin_android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,36 @@
export LIBWEBRTC_DOWNLOAD_URL=https://github.com/Unity-Technologies/com.unity.webrtc/releases/download/M112/webrtc-android.zip
export SOLUTION_DIR=$(pwd)/Plugin~
export PLUGIN_DIR=$(pwd)/Runtime/Plugins/Android
export ARCH_ABI=arm64-v8a

# Download LibWebRTC
curl -L $LIBWEBRTC_DOWNLOAD_URL > webrtc.zip
unzip -d $SOLUTION_DIR/webrtc webrtc.zip
cp -f $SOLUTION_DIR/webrtc/lib/libwebrtc.aar $PLUGIN_DIR

# Build UnityRenderStreaming Plugin
cd "$SOLUTION_DIR"
cmake . \
-B build \
-D CMAKE_SYSTEM_NAME=Android \
-D CMAKE_ANDROID_API_MIN=24 \
-D CMAKE_ANDROID_API=24 \
-D CMAKE_ANDROID_ARCH_ABI=$ARCH_ABI \
-D CMAKE_ANDROID_NDK=$ANDROID_NDK \
-D CMAKE_BUILD_TYPE=Release \
-D CMAKE_ANDROID_STL_TYPE=c++_static
for ARCH_ABI in "arm64-v8a" "x86_64"
do
cmake . \
-B build \
-D CMAKE_SYSTEM_NAME=Android \
-D CMAKE_ANDROID_API_MIN=24 \
-D CMAKE_ANDROID_API=24 \
-D CMAKE_ANDROID_ARCH_ABI=$ARCH_ABI \
-D CMAKE_ANDROID_NDK=$ANDROID_NDK \
-D CMAKE_BUILD_TYPE=Release \
-D CMAKE_ANDROID_STL_TYPE=c++_static

cmake \
--build build \
--target WebRTCPlugin
cmake \
--build build \
--target WebRTCPlugin

# libwebrtc.so move into libwebrtc.aar
cp -f $SOLUTION_DIR/webrtc/lib/libwebrtc.aar $PLUGIN_DIR
pushd $PLUGIN_DIR
mkdir -p jni/$ARCH_ABI
mv libwebrtc.so jni/$ARCH_ABI
zip -g libwebrtc.aar jni/$ARCH_ABI/libwebrtc.so
rm -r jni
popd
# libwebrtc.so move into libwebrtc.aar
pushd $PLUGIN_DIR
mkdir -p jni/$ARCH_ABI
mv libwebrtc.so jni/$ARCH_ABI
zip -g libwebrtc.aar jni/$ARCH_ABI/libwebrtc.so
rm -r jni
popd
rm -rf build
done
5 changes: 4 additions & 1 deletion Plugin~/cmake/FindWebRTC.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ if(Windows OR Linux)
set(WEBRTC_LIBRARY_DIR ${WEBRTC_LIBRARY_DIR}/${SYSTEM_PROCESSOR})
endif()
if(Android)
if(CMAKE_ANDROID_ARCH_ABI STREQUAL "x86_64")
set(CMAKE_ANDROID_ARCH "x64")
endif()
set(WEBRTC_LIBRARY_DIR ${WEBRTC_LIBRARY_DIR}/${CMAKE_ANDROID_ARCH})
endif()

Expand Down Expand Up @@ -54,4 +57,4 @@ find_package_handle_standard_args(WebRTC
WEBRTC_LIBRARY_DEBUG
WEBRTC_LIBRARY_RELEASE
WEBRTC_INCLUDE_DIR
)
)