From 95e8ea539369a118365f8dfa6a865562c35f55ad Mon Sep 17 00:00:00 2001 From: Eric Johnson Date: Mon, 7 Oct 2024 23:40:04 -0500 Subject: [PATCH 1/5] WIP docker build container --- deploy/docker/Dockerfile-build-android | 111 ++++++++++++++++++ deploy/docker/run-docker-android.sh | 43 +++++++ .../GStreamer/gstqml6gl/CMakeLists.txt | 32 +++-- 3 files changed, 177 insertions(+), 9 deletions(-) create mode 100644 deploy/docker/Dockerfile-build-android create mode 100755 deploy/docker/run-docker-android.sh diff --git a/deploy/docker/Dockerfile-build-android b/deploy/docker/Dockerfile-build-android new file mode 100644 index 00000000000..7097b48e7a4 --- /dev/null +++ b/deploy/docker/Dockerfile-build-android @@ -0,0 +1,111 @@ +# Use an Ubuntu base image +FROM ubuntu:22.04 + +# Set environment variables for Android SDK, NDK, and paths +ENV ANDROID_SDK_ROOT=/opt/android-sdk +ENV ANDROID_NDK_ROOT=/opt/android-sdk/ndk-bundle +ENV ANDROID_HOME=$ANDROID_SDK_ROOT +ENV PATH=$PATH:$ANDROID_SDK_ROOT/tools:$ANDROID_SDK_ROOT/platform-tools:$ANDROID_SDK_ROOT/cmdline-tools/tools/bin:$ANDROID_NDK_ROOT + +# Set environment variables to make apt-get fully non-interactive +ENV DEBIAN_FRONTEND=noninteractive +ENV TZ=America/New_York + +# Preconfigure tzdata (time zone) before installing packages +RUN apt-get update && apt-get install -y tzdata && \ + ln -fs /usr/share/zoneinfo/$TZ /etc/localtime && \ + dpkg-reconfigure --frontend noninteractive tzdata + +# Install required packages +RUN apt-get update && apt-get install -y \ + build-essential \ + libgl1-mesa-dev \ + libgstreamer-gl1.0-0 \ + libpulse-dev \ + libxcb-glx0 \ + libxcb-icccm4 \ + libxcb-image0 \ + libxcb-keysyms1 \ + libxcb-randr0 \ + libxcb-render-util0 \ + libxcb-render0 \ + libxcb-shape0 \ + libxcb-shm0 \ + libxcb-sync1 \ + libxcb-util1 \ + libxcb-xfixes0 \ + libxcb-xinerama0 \ + libxcb1 \ + libxkbcommon-dev \ + libxkbcommon-x11-0 \ + libxcb-xkb-dev \ + python3 \ + python3-pip \ + wget \ + unzip \ + git \ + openjdk-11-jdk \ + curl \ + locales \ + ninja-build + +# Ensure UTF-8 locale +RUN locale-gen en_US.UTF-8 && dpkg-reconfigure --frontend noninteractive locales && \ + export LANG=en_US.UTF-8 && export LC_ALL=en_US.UTF-8 + +# Install Android SDK +RUN mkdir -p $ANDROID_SDK_ROOT/cmdline-tools && \ + wget https://dl.google.com/android/repository/commandlinetools-linux-6609375_latest.zip -O /opt/cmdline-tools.zip && \ + unzip /opt/cmdline-tools.zip -d /opt/android-sdk/cmdline-tools && \ + rm /opt/cmdline-tools.zip + +# Accept licenses and install Android SDK components +RUN yes | sdkmanager --licenses && \ + sdkmanager "platform-tools" "platforms;android-31" "build-tools;31.0.0" "ndk;23.1.7779620" + +COPY tools/setup/install-dependencies-debian.sh /tmp/qt/ +RUN /tmp/qt/install-dependencies-debian.sh + +# Install aqtinstall for downloading Qt +RUN python3 -m pip install aqtinstall + +RUN mkdir -p /opt/Qt + +# Install Qt for Desktop (host) version +RUN cd /opt/Qt && aqt install-qt linux desktop 6.6.3 gcc_64 + +# Install Qt for Desktop (host) version with required modules +RUN cd /opt/Qt && aqt install-qt linux desktop 6.6.3 gcc_64 --modules qtcharts qtlocation qtpositioning qtspeech qt5compat qtmultimedia qtserialport qtimageformats qtshadertools qtconnectivity qtquick3d qtsensors + +# Install Qt for Android with necessary modules +RUN cd /opt/Qt && aqt install-qt linux android 6.6.3 android_arm64_v8a --modules qtcharts qtlocation qtpositioning qtspeech qt5compat qtmultimedia qtserialport qtimageformats qtshadertools qtconnectivity qtquick3d qtsensors + +# Set Qt-related environment variables +ENV QT_ROOT_DIR=/opt/Qt/6.6.3/android_arm64_v8a +ENV PATH=$PATH:$QT_ROOT_DIR/bin +ENV LD_LIBRARY_PATH=$QT_ROOT_DIR/lib +ENV PKG_CONFIG_PATH=$QT_ROOT_DIR/lib/pkgconfig +ENV QT_PLUGIN_PATH=$QT_ROOT_DIR/plugins +ENV QML2_IMPORT_PATH=$QT_ROOT_DIR/qml + +# Install Gradle +RUN wget https://services.gradle.org/distributions/gradle-6.8.3-bin.zip -P /tmp && \ + unzip -d /opt/gradle /tmp/gradle-6.8.3-bin.zip && \ + rm /tmp/gradle-6.8.3-bin.zip +ENV GRADLE_HOME=/opt/gradle/gradle-6.8.3 +ENV PATH=$PATH:$GRADLE_HOME/bin + +# Set Git configuration +RUN git config --global --add safe.directory /workspace + + +ENV PATH=$PATH:/opt/android-sdk/build-tools/31.0.0 + +# Add safe directory to Git config for non-root ownership +RUN git config --global --add safe.directory /project/source + +# Set working directory +WORKDIR /workspace + +# Expose the Android SDK, NDK, and Qt to be used in the workspace +CMD ["/bin/bash"] diff --git a/deploy/docker/run-docker-android.sh b/deploy/docker/run-docker-android.sh new file mode 100755 index 00000000000..70d41d21267 --- /dev/null +++ b/deploy/docker/run-docker-android.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash + +set -e + +# Build the Docker image for Android +docker build --file ./deploy/docker/Dockerfile-build-android -t qgc-android-docker . + +# Add Git safe directory setting +docker run --rm qgc-android-docker git config --global --add safe.directory /project/source + +docker run --cap-add SYS_ADMIN --device /dev/fuse --security-opt apparmor:unconfined --rm \ + -v ${PWD}:/project/source \ + -v ${PWD}/build:/project/build \ + -e ANDROID_SDK_ROOT=/opt/android-sdk \ + -e ANDROID_SDK_BUILD_TOOLS=/opt/android-sdk/build-tools/31.0.0 \ + qgc-android-docker \ + cmake -S /project/source -B /project/build \ + -G Ninja \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_TOOLCHAIN_FILE=/opt/android-sdk/ndk/23.1.7779620/build/cmake/android.toolchain.cmake \ + -DANDROID_ABI=arm64-v8a \ + -DANDROID_PLATFORM=android-31 \ + -DANDROID_BUILD_TOOLS=/opt/android-sdk/build-tools/31.0.0 \ + -DCMAKE_CXX_STANDARD=17 \ + -DQT_HOST_PATH_CMAKE_DIR=/opt/Qt/6.6.3/gcc_64/lib/cmake \ + -DQT_HOST_PATH=/opt/Qt/6.6.3/gcc_64 \ + -DQt6_DIR=/opt/Qt/6.6.3/android_arm64_v8a/lib/cmake/Qt6 + + + + +# Build and install the project +docker run --cap-add SYS_ADMIN --device /dev/fuse --security-opt apparmor:unconfined --rm \ + -v ${PWD}:/project/source \ + -v ${PWD}/build:/project/build \ + qgc-android-docker \ + cmake --build /project/build --target all --config Release + +docker run --cap-add SYS_ADMIN --device /dev/fuse --security-opt apparmor:unconfined --rm \ + -v ${PWD}:/project/source \ + -v ${PWD}/build:/project/build \ + qgc-android-docker \ + cmake --install /project/build --config Release diff --git a/src/VideoManager/VideoReceiver/GStreamer/gstqml6gl/CMakeLists.txt b/src/VideoManager/VideoReceiver/GStreamer/gstqml6gl/CMakeLists.txt index f4e8fb30b53..8aa66306152 100644 --- a/src/VideoManager/VideoReceiver/GStreamer/gstqml6gl/CMakeLists.txt +++ b/src/VideoManager/VideoReceiver/GStreamer/gstqml6gl/CMakeLists.txt @@ -42,17 +42,31 @@ endif() ################################################################################ -# TODO: Don't Download & Build if gstreamer1.0-qt6 was found -if(GStreamer_VERSION VERSION_GREATER_EQUAL 1.22) - FetchContent_Declare(gstreamer_good_plugins - # URL https://gitlab.freedesktop.org/gstreamer/gstreamer/-/archive/${GStreamer_VERSION}/gstreamer-${GStreamer_VERSION}.zip?path=subprojects/gst-plugins-good/ext/qt6 - URL https://gstreamer.freedesktop.org/src/gst-plugins-good/gst-plugins-good-${GST_PLUGINS_VERSION}.tar.xz - DOWNLOAD_EXTRACT_TIMESTAMP true +# Check if GStreamer Qt6 plugin is already available on the system +find_package(GStreamer QUIET COMPONENTS Qt6) + +if(GStreamer_FOUND AND GStreamer_VERSION VERSION_GREATER_EQUAL 1.22) + # Use the found GStreamer version + message(STATUS "Found GStreamer Qt6 plugin: ${GStreamer_VERSION}") + set(QGC_GST_QT6_PLUGIN_PATH "${CMAKE_CURRENT_SOURCE_DIR}/qt6" CACHE PATH "Location of system GST plugin") +else() + if(NOT DEFINED GST_PLUGINS_VERSION) + set(GST_PLUGINS_VERSION "1.22.12") + endif() + + file(DOWNLOAD + "https://gstreamer.freedesktop.org/src/gst-plugins-good/gst-plugins-good-1.22.12.tar.xz" + "${CMAKE_BINARY_DIR}/gst-plugins-good-1.22.12.tar.xz" + STATUS download_status ) - FetchContent_MakeAvailable(gstreamer_good_plugins) + + list(GET download_status 0 status_code) + if(NOT status_code EQUAL 0) + message(FATAL_ERROR "Failed to download GStreamer plugin: ${download_status}") + endif() + + set(QGC_GST_QT6_PLUGIN_PATH "${gstreamer_good_plugins_SOURCE_DIR}/ext/qt6" CACHE PATH "Location of downloaded GST Qt6 plugin sources") -else() - set(QGC_GST_QT6_PLUGIN_PATH "${CMAKE_CURRENT_SOURCE_DIR}/qt6" CACHE PATH "Location of custom local GST plugin") endif() cmake_print_variables(QGC_GST_QT6_PLUGIN_PATH) From 28e163b5d5e09d28bf0d5cc8040187ef0f81b9c0 Mon Sep 17 00:00:00 2001 From: Eric Johnson Date: Fri, 11 Oct 2024 01:59:26 -0500 Subject: [PATCH 2/5] WIP: building more --- deploy/docker/Dockerfile-build-android | 113 +++++++++++++++++-------- deploy/docker/run-docker-android.sh | 72 ++++++++-------- 2 files changed, 114 insertions(+), 71 deletions(-) diff --git a/deploy/docker/Dockerfile-build-android b/deploy/docker/Dockerfile-build-android index 7097b48e7a4..e5c7527ab39 100644 --- a/deploy/docker/Dockerfile-build-android +++ b/deploy/docker/Dockerfile-build-android @@ -54,58 +54,99 @@ RUN locale-gen en_US.UTF-8 && dpkg-reconfigure --frontend noninteractive locales export LANG=en_US.UTF-8 && export LC_ALL=en_US.UTF-8 # Install Android SDK -RUN mkdir -p $ANDROID_SDK_ROOT/cmdline-tools && \ - wget https://dl.google.com/android/repository/commandlinetools-linux-6609375_latest.zip -O /opt/cmdline-tools.zip && \ +RUN mkdir -p $ANDROID_SDK_ROOT/cmdline-tools/latest && \ + wget https://dl.google.com/android/repository/commandlinetools-linux-8512546_latest.zip -O /opt/cmdline-tools.zip && \ unzip /opt/cmdline-tools.zip -d /opt/android-sdk/cmdline-tools && \ + mv /opt/android-sdk/cmdline-tools/cmdline-tools/* /opt/android-sdk/cmdline-tools/latest/ && \ + rm -rf /opt/android-sdk/cmdline-tools/cmdline-tools && \ rm /opt/cmdline-tools.zip # Accept licenses and install Android SDK components -RUN yes | sdkmanager --licenses && \ - sdkmanager "platform-tools" "platforms;android-31" "build-tools;31.0.0" "ndk;23.1.7779620" - -COPY tools/setup/install-dependencies-debian.sh /tmp/qt/ -RUN /tmp/qt/install-dependencies-debian.sh +RUN yes | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --sdk_root=$ANDROID_SDK_ROOT --licenses && \ + $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --sdk_root=$ANDROID_SDK_ROOT "platform-tools" "platforms;android-31" "build-tools;31.0.0" "ndk;25.2.9519653" + +# Copy dependency installation script and execute it +# COPY tools/setup/install-dependencies-debian.sh /tmp/qt/ +# RUN /tmp/qt/install-dependencies-debian.sh + +# Qt Setup +ENV QT_VERSION="6.6.3" +ENV QT_PATH="/opt/Qt" +ENV QT_HOST="linux" +ENV QT_HOST_ARCH="gcc_64" +ENV QT_TARGET="android" +ENV QT_TARGET_ARCH="android_armv7" +ENV QT_MODULES="${QT_MODULES:-qtcharts qtpositioning qtspeech qt5compat qtmultimedia qtserialport qtimageformats qtshadertools qtconnectivity qtquick3d qtsensors qtlocation}" # Install aqtinstall for downloading Qt -RUN python3 -m pip install aqtinstall +RUN python3 -m pip install setuptools wheel py7zr aqtinstall +# Create Qt installation directory RUN mkdir -p /opt/Qt -# Install Qt for Desktop (host) version -RUN cd /opt/Qt && aqt install-qt linux desktop 6.6.3 gcc_64 - -# Install Qt for Desktop (host) version with required modules -RUN cd /opt/Qt && aqt install-qt linux desktop 6.6.3 gcc_64 --modules qtcharts qtlocation qtpositioning qtspeech qt5compat qtmultimedia qtserialport qtimageformats qtshadertools qtconnectivity qtquick3d qtsensors - -# Install Qt for Android with necessary modules -RUN cd /opt/Qt && aqt install-qt linux android 6.6.3 android_arm64_v8a --modules qtcharts qtlocation qtpositioning qtspeech qt5compat qtmultimedia qtserialport qtimageformats qtshadertools qtconnectivity qtquick3d qtsensors +# Install Qt for both host and target +RUN aqt install-qt ${QT_HOST} desktop ${QT_VERSION} ${QT_HOST_ARCH} -O ${QT_PATH} -m ${QT_MODULES} +RUN aqt install-qt ${QT_HOST} ${QT_TARGET} ${QT_VERSION} ${QT_TARGET_ARCH} -O ${QT_PATH} -m ${QT_MODULES} --autodesktop # Set Qt-related environment variables -ENV QT_ROOT_DIR=/opt/Qt/6.6.3/android_arm64_v8a -ENV PATH=$PATH:$QT_ROOT_DIR/bin -ENV LD_LIBRARY_PATH=$QT_ROOT_DIR/lib -ENV PKG_CONFIG_PATH=$QT_ROOT_DIR/lib/pkgconfig -ENV QT_PLUGIN_PATH=$QT_ROOT_DIR/plugins -ENV QML2_IMPORT_PATH=$QT_ROOT_DIR/qml - -# Install Gradle -RUN wget https://services.gradle.org/distributions/gradle-6.8.3-bin.zip -P /tmp && \ - unzip -d /opt/gradle /tmp/gradle-6.8.3-bin.zip && \ - rm /tmp/gradle-6.8.3-bin.zip -ENV GRADLE_HOME=/opt/gradle/gradle-6.8.3 -ENV PATH=$PATH:$GRADLE_HOME/bin +ENV QT_ROOT_DIR=${QT_PATH}/${QT_VERSION}/${QT_TARGET_ARCH} +ENV QT_HOST_PATH=${QT_PATH}/${QT_VERSION}/${QT_HOST_ARCH} +ENV QT_PLUGIN_PATH=${QT_ROOT_DIR}/plugins +ENV QML2_IMPORT_PATH=${QT_ROOT_DIR}/qml +ENV PATH=${QT_ROOT_DIR}/bin/:$PATH +ENV PKG_CONFIG_PATH=${QT_ROOT_DIR}/lib/pkgconfig:$PKG_CONFIG_PATH +ENV LD_LIBRARY_PATH=${QT_ROOT_DIR}/lib:$LD_LIBRARY_PATH # Set Git configuration RUN git config --global --add safe.directory /workspace - - -ENV PATH=$PATH:/opt/android-sdk/build-tools/31.0.0 - -# Add safe directory to Git config for non-root ownership RUN git config --global --add safe.directory /project/source +RUN pip install cmake + # Set working directory WORKDIR /workspace +ENV PATH /usr/lib/ccache:$QT_ROOT_DIR/bin:$PATH +ENV PATH /opt/Qt/${QT_VERSION}/gcc_64/:$PATH -# Expose the Android SDK, NDK, and Qt to be used in the workspace -CMD ["/bin/bash"] + +ENV ANDROID_SDK_ROOT=/opt/android-sdk +ENV ANDROID_NDK_ROOT=/opt/android-sdk/ndk/25.2.9519653 +ENV ANDROID_HOME=$ANDROID_SDK_ROOT +ENV ANDROID_SDK=$ANDROID_SDK_ROOT +ENV ANDROID_NDK=$ANDROID_NDK_ROOT +ENV PATH=$PATH:$ANDROID_SDK_ROOT/tools:$ANDROID_SDK_ROOT/platform-tools:$ANDROID_SDK_ROOT/cmdline-tools/tools/bin:$ANDROID_NDK_ROOT + +RUN apt-get update && apt-get install -y \ + libgstreamer1.0-dev \ + libgstreamer-plugins-base1.0-dev \ + libgstreamer-plugins-good1.0-dev + +# Build the project +CMD cmake -S /project/source -B /workspace -G Ninja \ + -DCMAKE_BUILD_TYPE=Release \ + -DQT_HOST_PATH=$QT_HOST_PATH \ + -DQT_ANDROID_BUILD_ALL_ABIS=OFF \ + -DQT_ANDROID_ABIS="armeabi-v7a" \ + -DANDROID_PLATFORM=android-31 \ + -DANDROID_BUILD_TOOLS=$ANDROID_SDK_ROOT/build-tools/31.0.0 \ + -DQT_ANDROID_SIGN_APK=OFF \ + -DENABLE_GSTREAMER=OFF \ + -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_ROOT/build/cmake/android.toolchain.cmake \ + -DQt6_DIR=$QT_ROOT_DIR/lib/cmake/Qt6 \ + -DCMAKE_PREFIX_PATH=$QT_ROOT_DIR/lib/cmake \ + -DANDROID_SDK_ROOT=$ANDROID_SDK_ROOT && \ + cmake --build /workspace --target all --config Debug && \ + cmake --install /workspace --config Debug + + + # cmake -S /project/source -B /project/build \ +# -G Ninja \ +# -DCMAKE_BUILD_TYPE=Release \ +# -DCMAKE_TOOLCHAIN_FILE=/opt/android-sdk/ndk/23.1.7779620/build/cmake/android.toolchain.cmake \ +# -DANDROID_ABI=arm64-v8a \ +# -DANDROID_PLATFORM=android-31 \ +# -DANDROID_BUILD_TOOLS=/opt/android-sdk/build-tools/31.0.0 \ +# -DCMAKE_CXX_STANDARD=17 \ +# -DQT_HOST_PATH_CMAKE_DIR=/opt/Qt/6.6.3/gcc_64/lib/cmake \ +# -DQT_HOST_PATH=/opt/Qt/6.6.3/gcc_64 \ +# -DQt6_DIR=/opt/Qt/6.6.3/android_arm64_v8a/lib/cmake/Qt6 \ No newline at end of file diff --git a/deploy/docker/run-docker-android.sh b/deploy/docker/run-docker-android.sh index 70d41d21267..0ae216d8d4b 100755 --- a/deploy/docker/run-docker-android.sh +++ b/deploy/docker/run-docker-android.sh @@ -5,39 +5,41 @@ set -e # Build the Docker image for Android docker build --file ./deploy/docker/Dockerfile-build-android -t qgc-android-docker . +docker run --rm -v ${PWD}:/project/source -v ${PWD}/build:/project/build qgc-android-docker + # Add Git safe directory setting -docker run --rm qgc-android-docker git config --global --add safe.directory /project/source - -docker run --cap-add SYS_ADMIN --device /dev/fuse --security-opt apparmor:unconfined --rm \ - -v ${PWD}:/project/source \ - -v ${PWD}/build:/project/build \ - -e ANDROID_SDK_ROOT=/opt/android-sdk \ - -e ANDROID_SDK_BUILD_TOOLS=/opt/android-sdk/build-tools/31.0.0 \ - qgc-android-docker \ - cmake -S /project/source -B /project/build \ - -G Ninja \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_TOOLCHAIN_FILE=/opt/android-sdk/ndk/23.1.7779620/build/cmake/android.toolchain.cmake \ - -DANDROID_ABI=arm64-v8a \ - -DANDROID_PLATFORM=android-31 \ - -DANDROID_BUILD_TOOLS=/opt/android-sdk/build-tools/31.0.0 \ - -DCMAKE_CXX_STANDARD=17 \ - -DQT_HOST_PATH_CMAKE_DIR=/opt/Qt/6.6.3/gcc_64/lib/cmake \ - -DQT_HOST_PATH=/opt/Qt/6.6.3/gcc_64 \ - -DQt6_DIR=/opt/Qt/6.6.3/android_arm64_v8a/lib/cmake/Qt6 - - - - -# Build and install the project -docker run --cap-add SYS_ADMIN --device /dev/fuse --security-opt apparmor:unconfined --rm \ - -v ${PWD}:/project/source \ - -v ${PWD}/build:/project/build \ - qgc-android-docker \ - cmake --build /project/build --target all --config Release - -docker run --cap-add SYS_ADMIN --device /dev/fuse --security-opt apparmor:unconfined --rm \ - -v ${PWD}:/project/source \ - -v ${PWD}/build:/project/build \ - qgc-android-docker \ - cmake --install /project/build --config Release +# docker run --rm qgc-android-docker git config --global --add safe.directory /project/source + +# docker run --cap-add SYS_ADMIN --device /dev/fuse --security-opt apparmor:unconfined --rm \ +# -v ${PWD}:/project/source \ +# -v ${PWD}/build:/project/build \ +# -e ANDROID_SDK_ROOT=/opt/android-sdk \ +# -e ANDROID_SDK_BUILD_TOOLS=/opt/android-sdk/build-tools/31.0.0 \ +# qgc-android-docker \ +# cmake -S /project/source -B /project/build \ +# -G Ninja \ +# -DCMAKE_BUILD_TYPE=Release \ +# -DCMAKE_TOOLCHAIN_FILE=/opt/android-sdk/ndk/23.1.7779620/build/cmake/android.toolchain.cmake \ +# -DANDROID_ABI=arm64-v8a \ +# -DANDROID_PLATFORM=android-31 \ +# -DANDROID_BUILD_TOOLS=/opt/android-sdk/build-tools/31.0.0 \ +# -DCMAKE_CXX_STANDARD=17 \ +# -DQT_HOST_PATH_CMAKE_DIR=/opt/Qt/6.6.3/gcc_64/lib/cmake \ +# -DQT_HOST_PATH=/opt/Qt/6.6.3/gcc_64 \ +# -DQt6_DIR=/opt/Qt/6.6.3/android_arm64_v8a/lib/cmake/Qt6 + + + + +# # Build and install the project +# docker run --cap-add SYS_ADMIN --device /dev/fuse --security-opt apparmor:unconfined --rm \ +# -v ${PWD}:/project/source \ +# -v ${PWD}/build:/project/build \ +# qgc-android-docker \ +# cmake --build /project/build --target all --config Release + +# docker run --cap-add SYS_ADMIN --device /dev/fuse --security-opt apparmor:unconfined --rm \ +# -v ${PWD}:/project/source \ +# -v ${PWD}/build:/project/build \ +# qgc-android-docker \ +# cmake --install /project/build --config Release From f19b3d6069abd95ca02bb0128b6ae029907f5077 Mon Sep 17 00:00:00 2001 From: Eric Johnson Date: Fri, 11 Oct 2024 19:56:04 -0500 Subject: [PATCH 3/5] building minus gstreamer --- deploy/docker/Dockerfile-build-android | 28 +++++++--------- deploy/docker/run-docker-android.sh | 2 +- .../GStreamer/gstqml6gl/CMakeLists.txt | 32 ++++++------------- 3 files changed, 21 insertions(+), 41 deletions(-) diff --git a/deploy/docker/Dockerfile-build-android b/deploy/docker/Dockerfile-build-android index e5c7527ab39..032df49eb36 100644 --- a/deploy/docker/Dockerfile-build-android +++ b/deploy/docker/Dockerfile-build-android @@ -63,7 +63,7 @@ RUN mkdir -p $ANDROID_SDK_ROOT/cmdline-tools/latest && \ # Accept licenses and install Android SDK components RUN yes | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --sdk_root=$ANDROID_SDK_ROOT --licenses && \ - $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --sdk_root=$ANDROID_SDK_ROOT "platform-tools" "platforms;android-31" "build-tools;31.0.0" "ndk;25.2.9519653" + $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --sdk_root=$ANDROID_SDK_ROOT "platform-tools" "platforms;android-34" "build-tools;34.0.0" "ndk;25.2.9519653" # Copy dependency installation script and execute it # COPY tools/setup/install-dependencies-debian.sh /tmp/qt/ @@ -119,7 +119,11 @@ ENV PATH=$PATH:$ANDROID_SDK_ROOT/tools:$ANDROID_SDK_ROOT/platform-tools:$ANDROID RUN apt-get update && apt-get install -y \ libgstreamer1.0-dev \ libgstreamer-plugins-base1.0-dev \ - libgstreamer-plugins-good1.0-dev + libgstreamer-plugins-good1.0-dev \ + openjdk-17-jdk + +ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64 +ENV PATH=$JAVA_HOME/bin:$PATH # Build the project CMD cmake -S /project/source -B /workspace -G Ninja \ @@ -134,19 +138,9 @@ CMD cmake -S /project/source -B /workspace -G Ninja \ -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_ROOT/build/cmake/android.toolchain.cmake \ -DQt6_DIR=$QT_ROOT_DIR/lib/cmake/Qt6 \ -DCMAKE_PREFIX_PATH=$QT_ROOT_DIR/lib/cmake \ + # -DQGC_ENABLE_GST_VIDEOSTREAMING=OFF \ + -DQGC_GST_QT6_PLUGIN_PATH=${QT_ROOT_DIR}/include/QtQuick \ -DANDROID_SDK_ROOT=$ANDROID_SDK_ROOT && \ - cmake --build /workspace --target all --config Debug && \ - cmake --install /workspace --config Debug - - - # cmake -S /project/source -B /project/build \ -# -G Ninja \ -# -DCMAKE_BUILD_TYPE=Release \ -# -DCMAKE_TOOLCHAIN_FILE=/opt/android-sdk/ndk/23.1.7779620/build/cmake/android.toolchain.cmake \ -# -DANDROID_ABI=arm64-v8a \ -# -DANDROID_PLATFORM=android-31 \ -# -DANDROID_BUILD_TOOLS=/opt/android-sdk/build-tools/31.0.0 \ -# -DCMAKE_CXX_STANDARD=17 \ -# -DQT_HOST_PATH_CMAKE_DIR=/opt/Qt/6.6.3/gcc_64/lib/cmake \ -# -DQT_HOST_PATH=/opt/Qt/6.6.3/gcc_64 \ -# -DQt6_DIR=/opt/Qt/6.6.3/android_arm64_v8a/lib/cmake/Qt6 \ No newline at end of file + cmake --build /workspace --target all --config Debug + # cmake --install /workspace --config Debug + \ No newline at end of file diff --git a/deploy/docker/run-docker-android.sh b/deploy/docker/run-docker-android.sh index 0ae216d8d4b..676f7a884e2 100755 --- a/deploy/docker/run-docker-android.sh +++ b/deploy/docker/run-docker-android.sh @@ -5,7 +5,7 @@ set -e # Build the Docker image for Android docker build --file ./deploy/docker/Dockerfile-build-android -t qgc-android-docker . -docker run --rm -v ${PWD}:/project/source -v ${PWD}/build:/project/build qgc-android-docker +docker run --rm -v ${PWD}:/project/source -v ${PWD}/build:/workspace qgc-android-docker # Add Git safe directory setting # docker run --rm qgc-android-docker git config --global --add safe.directory /project/source diff --git a/src/VideoManager/VideoReceiver/GStreamer/gstqml6gl/CMakeLists.txt b/src/VideoManager/VideoReceiver/GStreamer/gstqml6gl/CMakeLists.txt index 8aa66306152..f4e8fb30b53 100644 --- a/src/VideoManager/VideoReceiver/GStreamer/gstqml6gl/CMakeLists.txt +++ b/src/VideoManager/VideoReceiver/GStreamer/gstqml6gl/CMakeLists.txt @@ -42,31 +42,17 @@ endif() ################################################################################ -# Check if GStreamer Qt6 plugin is already available on the system -find_package(GStreamer QUIET COMPONENTS Qt6) - -if(GStreamer_FOUND AND GStreamer_VERSION VERSION_GREATER_EQUAL 1.22) - # Use the found GStreamer version - message(STATUS "Found GStreamer Qt6 plugin: ${GStreamer_VERSION}") - set(QGC_GST_QT6_PLUGIN_PATH "${CMAKE_CURRENT_SOURCE_DIR}/qt6" CACHE PATH "Location of system GST plugin") -else() - if(NOT DEFINED GST_PLUGINS_VERSION) - set(GST_PLUGINS_VERSION "1.22.12") - endif() - - file(DOWNLOAD - "https://gstreamer.freedesktop.org/src/gst-plugins-good/gst-plugins-good-1.22.12.tar.xz" - "${CMAKE_BINARY_DIR}/gst-plugins-good-1.22.12.tar.xz" - STATUS download_status +# TODO: Don't Download & Build if gstreamer1.0-qt6 was found +if(GStreamer_VERSION VERSION_GREATER_EQUAL 1.22) + FetchContent_Declare(gstreamer_good_plugins + # URL https://gitlab.freedesktop.org/gstreamer/gstreamer/-/archive/${GStreamer_VERSION}/gstreamer-${GStreamer_VERSION}.zip?path=subprojects/gst-plugins-good/ext/qt6 + URL https://gstreamer.freedesktop.org/src/gst-plugins-good/gst-plugins-good-${GST_PLUGINS_VERSION}.tar.xz + DOWNLOAD_EXTRACT_TIMESTAMP true ) - - list(GET download_status 0 status_code) - if(NOT status_code EQUAL 0) - message(FATAL_ERROR "Failed to download GStreamer plugin: ${download_status}") - endif() - - + FetchContent_MakeAvailable(gstreamer_good_plugins) set(QGC_GST_QT6_PLUGIN_PATH "${gstreamer_good_plugins_SOURCE_DIR}/ext/qt6" CACHE PATH "Location of downloaded GST Qt6 plugin sources") +else() + set(QGC_GST_QT6_PLUGIN_PATH "${CMAKE_CURRENT_SOURCE_DIR}/qt6" CACHE PATH "Location of custom local GST plugin") endif() cmake_print_variables(QGC_GST_QT6_PLUGIN_PATH) From d9976344947f421d1fa862d40bcd1185185aa195 Mon Sep 17 00:00:00 2001 From: Eric Johnson Date: Sat, 12 Oct 2024 13:02:57 -0500 Subject: [PATCH 4/5] mostly working build --- deploy/docker/Dockerfile-build-android | 151 +++++++++++-------------- 1 file changed, 66 insertions(+), 85 deletions(-) diff --git a/deploy/docker/Dockerfile-build-android b/deploy/docker/Dockerfile-build-android index 032df49eb36..803a03d1dc1 100644 --- a/deploy/docker/Dockerfile-build-android +++ b/deploy/docker/Dockerfile-build-android @@ -1,26 +1,24 @@ -# Use an Ubuntu base image +# Use Ubuntu 22.04 as base image FROM ubuntu:22.04 # Set environment variables for Android SDK, NDK, and paths ENV ANDROID_SDK_ROOT=/opt/android-sdk ENV ANDROID_NDK_ROOT=/opt/android-sdk/ndk-bundle ENV ANDROID_HOME=$ANDROID_SDK_ROOT -ENV PATH=$PATH:$ANDROID_SDK_ROOT/tools:$ANDROID_SDK_ROOT/platform-tools:$ANDROID_SDK_ROOT/cmdline-tools/tools/bin:$ANDROID_NDK_ROOT +ENV ANDROID_BUILD_TOOLS=$ANDROID_SDK_ROOT/build-tools/34.0.0 +ENV PATH=$PATH:$ANDROID_SDK_ROOT/tools:$ANDROID_SDK_ROOT/platform-tools:$ANDROID_SDK_ROOT/cmdline-tools/latest/bin:$ANDROID_BUILD_TOOLS:$ANDROID_NDK_ROOT -# Set environment variables to make apt-get fully non-interactive +# Set apt-get to non-interactive and configure time zone ENV DEBIAN_FRONTEND=noninteractive ENV TZ=America/New_York -# Preconfigure tzdata (time zone) before installing packages -RUN apt-get update && apt-get install -y tzdata && \ +# Configure time zone and install dependencies +RUN apt-get update && \ + apt-get install -y tzdata && \ ln -fs /usr/share/zoneinfo/$TZ /etc/localtime && \ - dpkg-reconfigure --frontend noninteractive tzdata - -# Install required packages -RUN apt-get update && apt-get install -y \ + dpkg-reconfigure --frontend noninteractive tzdata && \ + apt-get install -y \ build-essential \ - libgl1-mesa-dev \ - libgstreamer-gl1.0-0 \ libpulse-dev \ libxcb-glx0 \ libxcb-icccm4 \ @@ -44,103 +42,86 @@ RUN apt-get update && apt-get install -y \ wget \ unzip \ git \ - openjdk-11-jdk \ + openjdk-17-jdk \ curl \ locales \ ninja-build +# Set JAVA_HOME and update PATH +ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64 +ENV PATH=$JAVA_HOME/bin:$PATH + # Ensure UTF-8 locale -RUN locale-gen en_US.UTF-8 && dpkg-reconfigure --frontend noninteractive locales && \ - export LANG=en_US.UTF-8 && export LC_ALL=en_US.UTF-8 +RUN locale-gen en_US.UTF-8 && \ + dpkg-reconfigure --frontend noninteractive locales && \ + export LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 -# Install Android SDK +# Install Android SDK and NDK RUN mkdir -p $ANDROID_SDK_ROOT/cmdline-tools/latest && \ wget https://dl.google.com/android/repository/commandlinetools-linux-8512546_latest.zip -O /opt/cmdline-tools.zip && \ - unzip /opt/cmdline-tools.zip -d /opt/android-sdk/cmdline-tools && \ - mv /opt/android-sdk/cmdline-tools/cmdline-tools/* /opt/android-sdk/cmdline-tools/latest/ && \ - rm -rf /opt/android-sdk/cmdline-tools/cmdline-tools && \ - rm /opt/cmdline-tools.zip - -# Accept licenses and install Android SDK components -RUN yes | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --sdk_root=$ANDROID_SDK_ROOT --licenses && \ + unzip /opt/cmdline-tools.zip -d $ANDROID_SDK_ROOT/cmdline-tools && \ + mv $ANDROID_SDK_ROOT/cmdline-tools/cmdline-tools/* $ANDROID_SDK_ROOT/cmdline-tools/latest/ && \ + rm -rf $ANDROID_SDK_ROOT/cmdline-tools/cmdline-tools && \ + rm /opt/cmdline-tools.zip && \ + yes | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --sdk_root=$ANDROID_SDK_ROOT --licenses && \ $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --sdk_root=$ANDROID_SDK_ROOT "platform-tools" "platforms;android-34" "build-tools;34.0.0" "ndk;25.2.9519653" -# Copy dependency installation script and execute it -# COPY tools/setup/install-dependencies-debian.sh /tmp/qt/ -# RUN /tmp/qt/install-dependencies-debian.sh - -# Qt Setup +# Qt setup and environment variables ENV QT_VERSION="6.6.3" ENV QT_PATH="/opt/Qt" ENV QT_HOST="linux" ENV QT_HOST_ARCH="gcc_64" ENV QT_TARGET="android" -ENV QT_TARGET_ARCH="android_armv7" -ENV QT_MODULES="${QT_MODULES:-qtcharts qtpositioning qtspeech qt5compat qtmultimedia qtserialport qtimageformats qtshadertools qtconnectivity qtquick3d qtsensors qtlocation}" - -# Install aqtinstall for downloading Qt -RUN python3 -m pip install setuptools wheel py7zr aqtinstall - -# Create Qt installation directory -RUN mkdir -p /opt/Qt - -# Install Qt for both host and target -RUN aqt install-qt ${QT_HOST} desktop ${QT_VERSION} ${QT_HOST_ARCH} -O ${QT_PATH} -m ${QT_MODULES} -RUN aqt install-qt ${QT_HOST} ${QT_TARGET} ${QT_VERSION} ${QT_TARGET_ARCH} -O ${QT_PATH} -m ${QT_MODULES} --autodesktop - -# Set Qt-related environment variables -ENV QT_ROOT_DIR=${QT_PATH}/${QT_VERSION}/${QT_TARGET_ARCH} +ENV QT_TARGET_ARCH_ARMV7="android_armv7" +ENV QT_TARGET_ARCH_ARM64="android_arm64_v8a" +ENV QT_MODULES="qtcharts qtpositioning qtspeech qt5compat qtmultimedia qtserialport qtimageformats qtshadertools qtconnectivity qtquick3d qtsensors qtlocation" + +# Install aqtinstall and download Qt for both host and target architectures +RUN python3 -m pip install setuptools wheel py7zr aqtinstall && \ + mkdir -p /opt/Qt && \ + aqt install-qt ${QT_HOST} desktop ${QT_VERSION} ${QT_HOST_ARCH} -O ${QT_PATH} -m ${QT_MODULES} && \ + aqt install-qt ${QT_HOST} ${QT_TARGET} ${QT_VERSION} ${QT_TARGET_ARCH_ARMV7} -O ${QT_PATH} -m ${QT_MODULES} --autodesktop && \ + aqt install-qt ${QT_HOST} ${QT_TARGET} ${QT_VERSION} ${QT_TARGET_ARCH_ARM64} -O ${QT_PATH} -m ${QT_MODULES} --autodesktop + +# Set Qt-related environment variables for ARMv7 and ARM64 architectures +ENV QT_ROOT_DIR_ARMV7=${QT_PATH}/${QT_VERSION}/${QT_TARGET_ARCH_ARMV7} +ENV QT_ROOT_DIR_ARM64=${QT_PATH}/${QT_VERSION}/${QT_TARGET_ARCH_ARM64} ENV QT_HOST_PATH=${QT_PATH}/${QT_VERSION}/${QT_HOST_ARCH} -ENV QT_PLUGIN_PATH=${QT_ROOT_DIR}/plugins -ENV QML2_IMPORT_PATH=${QT_ROOT_DIR}/qml -ENV PATH=${QT_ROOT_DIR}/bin/:$PATH -ENV PKG_CONFIG_PATH=${QT_ROOT_DIR}/lib/pkgconfig:$PKG_CONFIG_PATH -ENV LD_LIBRARY_PATH=${QT_ROOT_DIR}/lib:$LD_LIBRARY_PATH - -# Set Git configuration -RUN git config --global --add safe.directory /workspace -RUN git config --global --add safe.directory /project/source - -RUN pip install cmake - -# Set working directory +ENV QT_PLUGIN_PATH_ARMV7=${QT_ROOT_DIR_ARMV7}/plugins +ENV QT_PLUGIN_PATH_ARM64=${QT_ROOT_DIR_ARM64}/plugins +ENV QML2_IMPORT_PATH_ARMV7=${QT_ROOT_DIR_ARMV7}/qml +ENV QML2_IMPORT_PATH_ARM64=${QT_ROOT_DIR_ARM64}/qml +ENV PATH=${QT_ROOT_DIR_ARMV7}/bin:${QT_ROOT_DIR_ARM64}/bin:$PATH +ENV PKG_CONFIG_PATH_ARMV7=${QT_ROOT_DIR_ARMV7}/lib/pkgconfig:$PKG_CONFIG_PATH +ENV PKG_CONFIG_PATH_ARM64=${QT_ROOT_DIR_ARM64}/lib/pkgconfig:$PKG_CONFIG_PATH +ENV LD_LIBRARY_PATH_ARMV7=${QT_ROOT_DIR_ARMV7}/lib:$LD_LIBRARY_PATH +ENV LD_LIBRARY_PATH_ARM64=${QT_ROOT_DIR_ARM64}/lib:$LD_LIBRARY_PATH + +# Set Git safe directories and install CMake +RUN git config --global --add safe.directory /workspace && \ + git config --global --add safe.directory /project/source && \ + pip install cmake + +# Set working directory and PATH WORKDIR /workspace -ENV PATH /usr/lib/ccache:$QT_ROOT_DIR/bin:$PATH -ENV PATH /opt/Qt/${QT_VERSION}/gcc_64/:$PATH +ENV PATH=/usr/lib/ccache:$QT_ROOT_DIR_ARMV7/bin:$QT_ROOT_DIR_ARM64/bin:$PATH +ENV PATH=/opt/Qt/${QT_VERSION}/gcc_64:$PATH - -ENV ANDROID_SDK_ROOT=/opt/android-sdk +# Final environment variables for Android SDK and NDK ENV ANDROID_NDK_ROOT=/opt/android-sdk/ndk/25.2.9519653 -ENV ANDROID_HOME=$ANDROID_SDK_ROOT -ENV ANDROID_SDK=$ANDROID_SDK_ROOT -ENV ANDROID_NDK=$ANDROID_NDK_ROOT -ENV PATH=$PATH:$ANDROID_SDK_ROOT/tools:$ANDROID_SDK_ROOT/platform-tools:$ANDROID_SDK_ROOT/cmdline-tools/tools/bin:$ANDROID_NDK_ROOT - -RUN apt-get update && apt-get install -y \ - libgstreamer1.0-dev \ - libgstreamer-plugins-base1.0-dev \ - libgstreamer-plugins-good1.0-dev \ - openjdk-17-jdk - -ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64 -ENV PATH=$JAVA_HOME/bin:$PATH +ENV PATH=$PATH:$ANDROID_SDK_ROOT/tools:$ANDROID_SDK_ROOT/platform-tools:$ANDROID_SDK_ROOT/cmdline-tools/latest/bin:$ANDROID_BUILD_TOOLS:$ANDROID_NDK_ROOT -# Build the project +# Build the project for both ARMv7 and ARM64 CMD cmake -S /project/source -B /workspace -G Ninja \ -DCMAKE_BUILD_TYPE=Release \ -DQT_HOST_PATH=$QT_HOST_PATH \ -DQT_ANDROID_BUILD_ALL_ABIS=OFF \ - -DQT_ANDROID_ABIS="armeabi-v7a" \ - -DANDROID_PLATFORM=android-31 \ - -DANDROID_BUILD_TOOLS=$ANDROID_SDK_ROOT/build-tools/31.0.0 \ + -DQT_ANDROID_ABIS="armeabi-v7a;arm64-v8a" \ + -DANDROID_BUILD_TOOLS=$ANDROID_SDK_ROOT/build-tools/34.0.0 \ + -DANDROID_SDK_ROOT=$ANDROID_SDK_ROOT \ -DQT_ANDROID_SIGN_APK=OFF \ - -DENABLE_GSTREAMER=OFF \ -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_ROOT/build/cmake/android.toolchain.cmake \ - -DQt6_DIR=$QT_ROOT_DIR/lib/cmake/Qt6 \ - -DCMAKE_PREFIX_PATH=$QT_ROOT_DIR/lib/cmake \ - # -DQGC_ENABLE_GST_VIDEOSTREAMING=OFF \ - -DQGC_GST_QT6_PLUGIN_PATH=${QT_ROOT_DIR}/include/QtQuick \ - -DANDROID_SDK_ROOT=$ANDROID_SDK_ROOT && \ - cmake --build /workspace --target all --config Debug - # cmake --install /workspace --config Debug - \ No newline at end of file + -DQt6_DIR=$QT_ROOT_DIR_ARMV7/lib/cmake/Qt6 \ + -DQt6_DIR_ARM64=$QT_ROOT_DIR_ARM64/lib/cmake/Qt6 \ + -DCMAKE_PREFIX_PATH=$QT_ROOT_DIR_ARMV7/lib/cmake:$QT_ROOT_DIR_ARM64/lib/cmake && \ + cmake --build /workspace --target all --config Release From c4fea729caa596dad69a94f329caff87e89d2d56 Mon Sep 17 00:00:00 2001 From: Eric Johnson Date: Mon, 14 Oct 2024 01:37:53 -0500 Subject: [PATCH 5/5] WIP: more changes to make build more similar to CI --- deploy/docker/Dockerfile-build-android | 74 ++++++++++++-------------- deploy/docker/run-docker-android.sh | 3 +- 2 files changed, 36 insertions(+), 41 deletions(-) diff --git a/deploy/docker/Dockerfile-build-android b/deploy/docker/Dockerfile-build-android index 803a03d1dc1..bae5cc113d3 100644 --- a/deploy/docker/Dockerfile-build-android +++ b/deploy/docker/Dockerfile-build-android @@ -3,10 +3,9 @@ FROM ubuntu:22.04 # Set environment variables for Android SDK, NDK, and paths ENV ANDROID_SDK_ROOT=/opt/android-sdk -ENV ANDROID_NDK_ROOT=/opt/android-sdk/ndk-bundle +ENV ANDROID_NDK_ROOT=$ANDROID_SDK_ROOT/ndk/25.2.9519653 ENV ANDROID_HOME=$ANDROID_SDK_ROOT ENV ANDROID_BUILD_TOOLS=$ANDROID_SDK_ROOT/build-tools/34.0.0 -ENV PATH=$PATH:$ANDROID_SDK_ROOT/tools:$ANDROID_SDK_ROOT/platform-tools:$ANDROID_SDK_ROOT/cmdline-tools/latest/bin:$ANDROID_BUILD_TOOLS:$ANDROID_NDK_ROOT # Set apt-get to non-interactive and configure time zone ENV DEBIAN_FRONTEND=noninteractive @@ -49,7 +48,6 @@ RUN apt-get update && \ # Set JAVA_HOME and update PATH ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64 -ENV PATH=$JAVA_HOME/bin:$PATH # Ensure UTF-8 locale RUN locale-gen en_US.UTF-8 && \ @@ -78,50 +76,46 @@ ENV QT_MODULES="qtcharts qtpositioning qtspeech qt5compat qtmultimedia qtserialp # Install aqtinstall and download Qt for both host and target architectures RUN python3 -m pip install setuptools wheel py7zr aqtinstall && \ - mkdir -p /opt/Qt && \ - aqt install-qt ${QT_HOST} desktop ${QT_VERSION} ${QT_HOST_ARCH} -O ${QT_PATH} -m ${QT_MODULES} && \ - aqt install-qt ${QT_HOST} ${QT_TARGET} ${QT_VERSION} ${QT_TARGET_ARCH_ARMV7} -O ${QT_PATH} -m ${QT_MODULES} --autodesktop && \ - aqt install-qt ${QT_HOST} ${QT_TARGET} ${QT_VERSION} ${QT_TARGET_ARCH_ARM64} -O ${QT_PATH} -m ${QT_MODULES} --autodesktop + mkdir -p $QT_PATH && \ + aqt install-qt $QT_HOST desktop $QT_VERSION $QT_HOST_ARCH -O $QT_PATH -m $QT_MODULES && \ + aqt install-qt $QT_HOST $QT_TARGET $QT_VERSION $QT_TARGET_ARCH_ARMV7 -O $QT_PATH -m $QT_MODULES --autodesktop && \ + aqt install-qt $QT_HOST $QT_TARGET $QT_VERSION $QT_TARGET_ARCH_ARM64 -O $QT_PATH -m $QT_MODULES --autodesktop # Set Qt-related environment variables for ARMv7 and ARM64 architectures -ENV QT_ROOT_DIR_ARMV7=${QT_PATH}/${QT_VERSION}/${QT_TARGET_ARCH_ARMV7} -ENV QT_ROOT_DIR_ARM64=${QT_PATH}/${QT_VERSION}/${QT_TARGET_ARCH_ARM64} -ENV QT_HOST_PATH=${QT_PATH}/${QT_VERSION}/${QT_HOST_ARCH} -ENV QT_PLUGIN_PATH_ARMV7=${QT_ROOT_DIR_ARMV7}/plugins -ENV QT_PLUGIN_PATH_ARM64=${QT_ROOT_DIR_ARM64}/plugins -ENV QML2_IMPORT_PATH_ARMV7=${QT_ROOT_DIR_ARMV7}/qml -ENV QML2_IMPORT_PATH_ARM64=${QT_ROOT_DIR_ARM64}/qml -ENV PATH=${QT_ROOT_DIR_ARMV7}/bin:${QT_ROOT_DIR_ARM64}/bin:$PATH -ENV PKG_CONFIG_PATH_ARMV7=${QT_ROOT_DIR_ARMV7}/lib/pkgconfig:$PKG_CONFIG_PATH -ENV PKG_CONFIG_PATH_ARM64=${QT_ROOT_DIR_ARM64}/lib/pkgconfig:$PKG_CONFIG_PATH -ENV LD_LIBRARY_PATH_ARMV7=${QT_ROOT_DIR_ARMV7}/lib:$LD_LIBRARY_PATH -ENV LD_LIBRARY_PATH_ARM64=${QT_ROOT_DIR_ARM64}/lib:$LD_LIBRARY_PATH +ENV QT_ROOT_DIR_ARMV7=$QT_PATH/$QT_VERSION/$QT_TARGET_ARCH_ARMV7 +ENV QT_ROOT_DIR_ARM64=$QT_PATH/$QT_VERSION/$QT_TARGET_ARCH_ARM64 +ENV QT_HOST_PATH=$QT_PATH/$QT_VERSION/$QT_HOST_ARCH +ENV QT_PLUGIN_PATH_ARMV7=$QT_ROOT_DIR_ARMV7/plugins +ENV QT_PLUGIN_PATH_ARM64=$QT_ROOT_DIR_ARM64/plugins +ENV QML2_IMPORT_PATH_ARMV7=$QT_ROOT_DIR_ARMV7/qml +ENV QML2_IMPORT_PATH_ARM64=$QT_ROOT_DIR_ARM64/qml +ENV PKG_CONFIG_PATH_ARMV7=$QT_ROOT_DIR_ARMV7/lib/pkgconfig:$PKG_CONFIG_PATH +ENV PKG_CONFIG_PATH_ARM64=$QT_ROOT_DIR_ARM64/lib/pkgconfig:$PKG_CONFIG_PATH +ENV LD_LIBRARY_PATH_ARMV7=$QT_ROOT_DIR_ARMV7/lib:$LD_LIBRARY_PATH +ENV LD_LIBRARY_PATH_ARM64=$QT_ROOT_DIR_ARM64/lib:$LD_LIBRARY_PATH + +# Consolidate PATH settings +ENV PATH=$JAVA_HOME/bin:/usr/lib/ccache:$QT_HOST_PATH/bin:$QT_ROOT_DIR_ARMV7/bin:$QT_ROOT_DIR_ARM64/bin:$PATH:$ANDROID_SDK_ROOT/tools:$ANDROID_SDK_ROOT/platform-tools:$ANDROID_SDK_ROOT/cmdline-tools/latest/bin:$ANDROID_BUILD_TOOLS:$ANDROID_NDK_ROOT # Set Git safe directories and install CMake RUN git config --global --add safe.directory /workspace && \ git config --global --add safe.directory /project/source && \ pip install cmake -# Set working directory and PATH +# Set working directory WORKDIR /workspace -ENV PATH=/usr/lib/ccache:$QT_ROOT_DIR_ARMV7/bin:$QT_ROOT_DIR_ARM64/bin:$PATH -ENV PATH=/opt/Qt/${QT_VERSION}/gcc_64:$PATH - -# Final environment variables for Android SDK and NDK -ENV ANDROID_NDK_ROOT=/opt/android-sdk/ndk/25.2.9519653 -ENV PATH=$PATH:$ANDROID_SDK_ROOT/tools:$ANDROID_SDK_ROOT/platform-tools:$ANDROID_SDK_ROOT/cmdline-tools/latest/bin:$ANDROID_BUILD_TOOLS:$ANDROID_NDK_ROOT -# Build the project for both ARMv7 and ARM64 -CMD cmake -S /project/source -B /workspace -G Ninja \ - -DCMAKE_BUILD_TYPE=Release \ - -DQT_HOST_PATH=$QT_HOST_PATH \ - -DQT_ANDROID_BUILD_ALL_ABIS=OFF \ - -DQT_ANDROID_ABIS="armeabi-v7a;arm64-v8a" \ - -DANDROID_BUILD_TOOLS=$ANDROID_SDK_ROOT/build-tools/34.0.0 \ - -DANDROID_SDK_ROOT=$ANDROID_SDK_ROOT \ - -DQT_ANDROID_SIGN_APK=OFF \ - -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_ROOT/build/cmake/android.toolchain.cmake \ - -DQt6_DIR=$QT_ROOT_DIR_ARMV7/lib/cmake/Qt6 \ - -DQt6_DIR_ARM64=$QT_ROOT_DIR_ARM64/lib/cmake/Qt6 \ - -DCMAKE_PREFIX_PATH=$QT_ROOT_DIR_ARMV7/lib/cmake:$QT_ROOT_DIR_ARM64/lib/cmake && \ - cmake --build /workspace --target all --config Release +# Build the project +CMD mkdir -p /workspace/build/shadow_build_dir && \ + cd /workspace/build/shadow_build_dir && \ + qt-cmake -S /project/source -G Ninja \ + -DCMAKE_BUILD_TYPE=Release \ + -DQT_HOST_PATH=$QT_HOST_PATH \ + -DQT_ANDROID_BUILD_ALL_ABIS=OFF \ + -DQT_ANDROID_ABIS="armeabi-v7a;arm64-v8a" \ + -DQT_DEBUG_FIND_PACKAGE=ON \ + -DANDROID_BUILD_TOOLS=$ANDROID_SDK_ROOT/build-tools/34.0.0 \ + -DANDROID_SDK_ROOT=$ANDROID_SDK_ROOT \ + -DQT_ANDROID_SIGN_APK=OFF \ + -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_ROOT/build/cmake/android.toolchain.cmake && \ + cmake --build . --target all --config Release diff --git a/deploy/docker/run-docker-android.sh b/deploy/docker/run-docker-android.sh index 676f7a884e2..a886acff9c7 100755 --- a/deploy/docker/run-docker-android.sh +++ b/deploy/docker/run-docker-android.sh @@ -5,7 +5,8 @@ set -e # Build the Docker image for Android docker build --file ./deploy/docker/Dockerfile-build-android -t qgc-android-docker . -docker run --rm -v ${PWD}:/project/source -v ${PWD}/build:/workspace qgc-android-docker +# Run the Docker container with adjusted mount points +docker run --rm -v ${PWD}:/project/source -v ${PWD}/build:/workspace/build qgc-android-docker # Add Git safe directory setting # docker run --rm qgc-android-docker git config --global --add safe.directory /project/source