-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release/v7.3.0' into 'master'
Release 7.3.0 See merge request megachat/MEGAchat!2038
- Loading branch information
Showing
22 changed files
with
575 additions
and
100 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
find_package(Java REQUIRED) | ||
find_package(SWIG REQUIRED) | ||
include(UseSWIG) | ||
|
||
# Set the output directory for generated Java files | ||
set(JAVA_OUTPUT_DIR ${CMAKE_BINARY_DIR}/bindings/java/nz/mega/sdk) | ||
|
||
# Define the interface file and its properties | ||
set(SWIG_INTERFACE_FILE ${CMAKE_CURRENT_LIST_DIR}/../megachatapi.i) | ||
set_source_files_properties(${SWIG_INTERFACE_FILE} PROPERTIES | ||
CPLUSPLUS ON | ||
) | ||
|
||
# Set SWIG flags for generating Java code | ||
if(ENABLE_SYNC) | ||
list(APPEND ADDITIONAL_SWIG_DEFINES -DENABLE_SYNC) | ||
endif() | ||
|
||
if(USE_LIBUV) | ||
list(APPEND ADDITIONAL_SWIG_DEFINES -DHAVE_LIBUV) | ||
endif() | ||
|
||
if(NOT USE_WEBRTC) | ||
list(APPEND ADDITIONAL_SWIG_DEFINES -DKARERE_DISABLE_WEBRTC) | ||
endif() | ||
|
||
set(CMAKE_SWIG_FLAGS -c++ -package "nz.mega.sdk" ${ADDITIONAL_SWIG_DEFINES} -I${CMAKE_CURRENT_LIST_DIR}/../../src -I${CMAKE_CURRENT_LIST_DIR}/../../third-party/mega/include) | ||
|
||
# Generate java binding files | ||
swig_add_library(MEGAchatJavaBindings | ||
TYPE STATIC | ||
LANGUAGE java | ||
SOURCES ${SWIG_INTERFACE_FILE} | ||
OUTPUT_DIR ${JAVA_OUTPUT_DIR} | ||
) | ||
|
||
# For Android we do not need JNI | ||
if(ANDROID) | ||
set(JNI_INCLUDE_DIRS | ||
${ANDROID_NDK_HOME}/sysroot/usr/include | ||
${ANDROID_NDK_HOME}/sysroot/usr/include/${ANDROID_ABI} | ||
) | ||
else() | ||
find_package(JNI REQUIRED) | ||
endif() | ||
|
||
target_include_directories(MEGAchatJavaBindings | ||
PRIVATE | ||
${Java_INCLUDE_DIRS} | ||
${JNI_INCLUDE_DIRS} | ||
${JAVA_OUTPUT_DIR} | ||
) | ||
|
||
target_link_libraries(MEGAchatJavaBindings | ||
PRIVATE | ||
MEGA::CHATlib | ||
SDKJavaBindings | ||
) | ||
|
||
# Compile Java code | ||
add_custom_command(TARGET MEGAchatJavaBindings POST_BUILD | ||
COMMAND ${Java_JAVAC_EXECUTABLE} -d ${JAVA_OUTPUT_DIR} -cp ${JAVA_OUTPUT_DIR} ${JAVA_OUTPUT_DIR}/*.java | ||
COMMENT "Compiling Java classes..." | ||
) |
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,123 @@ | ||
# Dockerfile for cross-compiling for Android and its different architectures. | ||
# | ||
# Build the Docker image: | ||
# docker build -t megachat-android-cross-build -f /path/to/your/megachat/dockerfile/android-cross-build.dockerfile . | ||
# -t : Tags the built container with a name | ||
# -f : Specify dockerfile to be build, replace /path/to/your/megachat with your local path to it | ||
# | ||
# Run the Docker container and build the project for a specific architecture: | ||
# docker run -v /path/to/your/megachat:/mega/megachat -v /path/to/your/vcpkg:/mega/vcpkg -e ARCH=[arm, arm64, x86, x64] -it megachat-android-cross-build | ||
# -v : Mounts a local directory into the container, replace /path/to/your/megachat and /path/to/your/vcpkg with your local paths | ||
# -e : Sets an environment variable, `ARCH` environment variable is used to specify the target architecture | ||
# -it : Starts an interactive terminal session inside the container after the cmake project is configured and build | ||
|
||
|
||
# Manual test run for this file: | ||
# | ||
# docker build -t megachat-android-cross-build -f android-cross-build.dockerfile . | ||
# docker run -v /c/_dev/mega/MEGAchat:/mega/megachat -v /c/_dev/mega/vcpkg:/mega/vcpkg -it megachat-android-cross-build /bin/bash | ||
# | ||
# #Build for arm64: export ARCH=arm64 && export VCPKG_TRIPLET='arm64-android-mega' && export ANDROID_ARCH='arm64-v8a' | ||
# #Build for arm: export ARCH=arm && export VCPKG_TRIPLET='arm-android-mega' && export ANDROID_ARCH='armeabi-v7a' | ||
# #Build for x64: export ARCH=x64 && export VCPKG_TRIPLET='x64-android-mega' && export ANDROID_ARCH='x86_64' | ||
# #Build for x86: export ARCH=x86 && export VCPKG_TRIPLET='x86-android-mega' && export ANDROID_ARCH='x86' | ||
# | ||
# cmake -B buildAndroid_${ARCH} -S megachat -DVCPKG_ROOT=/mega/vcpkg -DCMAKE_BUILD_TYPE=Debug -DUSE_FREEIMAGE=OFF -DUSE_FFMPEG=OFF -DUSE_PDFIUM=OFF -DUSE_READLINE=OFF -DVCPKG_TARGET_TRIPLET=${VCPKG_TRIPLET} -DENABLE_JAVA_BINDINGS=ON -DENABLE_CHATLIB_MEGACLC=OFF -DENABLE_CHATLIB_TESTS=OFF -DENABLE_CHATLIB_QTAPP=OFF -DCMAKE_SYSTEM_NAME=Android -DCMAKE_ANDROID_API=26 -DCMAKE_ANDROID_ARCH_ABI=${ANDROID_ARCH} -DCMAKE_ANDROID_NDK=${ANDROID_NDK_HOME} -DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON -DENABLE_CHATLIB_WERROR=OFF -DUSE_WEBRTC=OFF | ||
# | ||
# cmake --build buildAndroid_${ARCH} -j10 | ||
|
||
|
||
# Base image | ||
FROM ubuntu:22.04 | ||
|
||
# Install dependencies | ||
RUN apt-get update && apt-get install -y \ | ||
autoconf \ | ||
autoconf-archive \ | ||
build-essential \ | ||
cmake \ | ||
curl \ | ||
git \ | ||
libasound2-dev \ | ||
libglib2.0-dev \ | ||
libgtk-3-dev \ | ||
libpulse-dev \ | ||
nasm \ | ||
openjdk-21-jdk \ | ||
pkg-config \ | ||
python3 \ | ||
python3-pip \ | ||
python3-pkg-resources \ | ||
swig \ | ||
unzip \ | ||
wget \ | ||
zip \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
WORKDIR /mega | ||
|
||
RUN git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git | ||
ENV PATH=$PATH:/mega/depot_tools | ||
|
||
# Download, extract and set the Android NDK | ||
ARG MEGA_NDK_RELEASE=27b | ||
ARG MEGA_NDK_ZIP=android-ndk-r${MEGA_NDK_RELEASE}-linux.zip | ||
RUN mkdir -p /mega/android-ndk && \ | ||
chmod 777 /mega && \ | ||
cd /mega/android-ndk && \ | ||
wget https://dl.google.com/android/repository/${MEGA_NDK_ZIP} && \ | ||
unzip ${MEGA_NDK_ZIP} && \ | ||
rm ${MEGA_NDK_ZIP} | ||
ENV ANDROID_NDK_HOME=/mega/android-ndk/android-ndk-r${MEGA_NDK_RELEASE} | ||
ENV PATH=$PATH:$ANDROID_NDK_HOME | ||
ENV JAVA_HOME=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64 | ||
ENV PATH=$PATH:$JAVA_HOME | ||
|
||
# Set default architecture | ||
ARG ARCH=x64 | ||
|
||
# Configure and build CMake command, this will be executed when running the container | ||
CMD ["sh", "-c", "\ | ||
owner_uid=$(stat -c '%u' /mega/megachat) && \ | ||
owner_gid=$(stat -c '%g' /mega/megachat) && \ | ||
groupadd -g $owner_gid me && \ | ||
echo 'Adding \"me\" user...' && \ | ||
useradd -r -M -u $owner_uid -g $owner_gid -d /mega -s /bin/bash me && \ | ||
case ${ARCH} in \ | ||
arm) \ | ||
export VCPKG_TRIPLET='arm-android-mega' && \ | ||
export ANDROID_ARCH='armeabi-v7a';; \ | ||
arm64) \ | ||
export VCPKG_TRIPLET='arm64-android-mega' && \ | ||
export ANDROID_ARCH='arm64-v8a';; \ | ||
x86) \ | ||
export VCPKG_TRIPLET='x86-android-mega' && \ | ||
export ANDROID_ARCH='x86';; \ | ||
x64) \ | ||
export VCPKG_TRIPLET='x64-android-mega' && \ | ||
export ANDROID_ARCH='x86_64';; \ | ||
*) \ | ||
echo 'Unsupported architecture: ${ARCH}' && exit 1;; \ | ||
esac && \ | ||
su - me -w 'ANDROID_NDK_HOME,PATH,JAVA_HOME,VCPKG_TRIPLET,ANDROID_ARCH' -c ' \ | ||
cmake -B buildAndroid_${ANDROID_ARCH} -S megachat \ | ||
-DVCPKG_ROOT=/mega/vcpkg \ | ||
-DCMAKE_BUILD_TYPE=RelWithDebInfo \ | ||
-DVCPKG_TARGET_TRIPLET=${VCPKG_TRIPLET} \ | ||
-DENABLE_JAVA_BINDINGS=ON \ | ||
-DENABLE_CHATLIB_MEGACLC=OFF \ | ||
-DENABLE_CHATLIB_TESTS=OFF \ | ||
-DENABLE_CHATLIB_QTAPP=OFF \ | ||
-DUSE_FREEIMAGE=OFF \ | ||
-DUSE_FFMPEG=OFF \ | ||
-DUSE_PDFIUM=OFF \ | ||
-DUSE_READLINE=OFF \ | ||
-DCMAKE_SYSTEM_NAME=Android \ | ||
-DCMAKE_ANDROID_API=26 \ | ||
-DCMAKE_ANDROID_ARCH_ABI=${ANDROID_ARCH} \ | ||
-DCMAKE_ANDROID_NDK=${ANDROID_NDK_HOME} \ | ||
-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON \ | ||
-DENABLE_CHATLIB_WERROR=OFF \ | ||
-DUSE_WEBRTC=OFF && \ | ||
cmake --build buildAndroid_${ANDROID_ARCH}' && \ | ||
exec /bin/bash"] |
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
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
Oops, something went wrong.