diff --git a/.github/workflows/kuiperbuild.yml b/.github/workflows/appimage-armhf.yml similarity index 68% rename from .github/workflows/kuiperbuild.yml rename to .github/workflows/appimage-armhf.yml index 761178e9c7..60aa9d41ad 100644 --- a/.github/workflows/kuiperbuild.yml +++ b/.github/workflows/appimage-armhf.yml @@ -1,4 +1,4 @@ -name: Kuiper Scopy Build +name: Scopy armhf AppImage Build on: [push, pull_request] @@ -8,7 +8,7 @@ env: jobs: - build_scopy_for_kuiper: + build_scopy_armhf_appimage: runs-on: ubuntu-20.04 steps: @@ -17,24 +17,24 @@ jobs: set-safe-directory: 'true' - name: Pull the Docker Image - run: docker pull cristianbindea/scopy2-kuiper:latest + run: docker pull cristianbindea/scopy2-armhf-appimage:latest - name: Create Scopy AppImage shell: bash run: | cd $GITHUB_WORKSPACE sudo apt update - ./ci/kuiper/create_sysroot.sh install_packages install_qemu - ./ci/kuiper/kuiper_build_process.sh generate_ci_envs + ./ci/armhf/create_sysroot.sh install_packages install_qemu + ./ci/armhf/armhf_build_process.sh generate_ci_envs docker run \ --mount type=bind,source="$GITHUB_WORKSPACE",target=/home/runner/scopy \ --env-file $GITHUB_WORKSPACE/ci/general/gh-actions.envs \ - cristianbindea/scopy2-kuiper:latest \ + cristianbindea/scopy2-armhf-appimage:latest \ /bin/bash -c 'cd $HOME && \ sudo chown -R runner:runner scopy && \ cd $HOME/scopy && \ - ./ci/kuiper/kuiper_build_process.sh install_packages download_cmake download_crosscompiler move_sysroot build_scopy build_iio-emu create_appdir create_appimage move_appimage + ./ci/armhf/armhf_build_process.sh install_packages download_cmake download_crosscompiler move_sysroot build_scopy build_iio-emu create_appdir create_appimage move_appimage ' - name: Set short git commit SHA shell: bash diff --git a/.github/workflows/appimage-x86_64.yml b/.github/workflows/appimage-x86_64.yml new file mode 100644 index 0000000000..8896727b5e --- /dev/null +++ b/.github/workflows/appimage-x86_64.yml @@ -0,0 +1,45 @@ +name: Scopy x86_64 AppImage Build + +on: [push, pull_request] + +env: + BUILD_HOST: ubuntu-20.04 + USERNAME: github-actions + +jobs: + + build_scopy_x86-64_appimage: + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v4 + with: + set-safe-directory: 'true' + + - name: Pull the Docker Image + run: docker pull cristianbindea/scopy2-x86_64-appimage:latest + + - name: Create Scopy AppImage + shell: bash + run: | + export CI_SCRIPT=ON + cd $GITHUB_WORKSPACE + ./ci/x86_64/x86-64_appimage_process.sh generate_ci_envs + + docker run \ + --mount type=bind,source="$GITHUB_WORKSPACE",target=/home/runner/scopy \ + --env-file $GITHUB_WORKSPACE/ci/x86_64/gh-actions.envs \ + cristianbindea/scopy2-x86_64-appimage:latest \ + /bin/bash -c 'cd $HOME && \ + sudo chown -R runner:runner scopy && \ + cd $HOME/scopy && \ + ./ci/x86_64/x86-64_appimage_process.sh run_workflow + ' + - name: Set short git commit SHA + shell: bash + run: echo "commit_sha=$(git rev-parse --short ${{ github.sha }})" >> "$GITHUB_ENV" + + - uses: actions/upload-artifact@v4 + with: + name: scopy-linux-x86_64-${{ env.commit_sha }} + path: ${{ github.workspace }}/Scopy-x86_64.AppImage diff --git a/.gitignore b/.gitignore index b137d8f7fe..b15d6705d5 100644 --- a/.gitignore +++ b/.gitignore @@ -36,9 +36,14 @@ build/* .vscode/* ci/ubuntu/staging ci/macOS/staging -ci/kuiper/staging -ci/kuiper/docker/sysroot* -ci/kuiper/scopy.AppDir +ci/armhf/staging +ci/armhf/docker/sysroot* +ci/armhf/scopy.AppDir +ci/armhf/staging +ci/armhf/scopy.AppDir +ci/armhf/scopy.squashfs +ci/x86_64/staging +ci/x86_64/scopy.AppDir windows/* core/include/scopy-core_config.h core/include/scopy-core_export.h diff --git a/CMakeLists.txt b/CMakeLists.txt index a743ad4fee..b2ef100280 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,6 +57,10 @@ if(ENABLE_TRANSLATION) qt_add_resources(SCOPY_RESOURCES ${CMAKE_BINARY_DIR}/translations.qrc) endif() +if(DEFINED ENV{APPIMAGE}) + add_compile_definitions(__appimage__) +endif() + qt_add_resources(SCOPY_RESOURCES ${SCOPY_RESOURCE_FILES}) if(WIN32) diff --git a/ci/armhf/AppRun b/ci/armhf/AppRun new file mode 100755 index 0000000000..e655f07926 --- /dev/null +++ b/ci/armhf/AppRun @@ -0,0 +1,16 @@ +#!/bin/bash +set -e +SELF=$(readlink -f "$0") +HERE=${SELF%/*} + +export QT_PLUGIN_PATH=$HERE/usr/plugins +export QT_QPA_PLATFORM_PLUGIN_PATH=$HERE/usr/plugins/platforms +export QT_QPA_PLATFORM=xcb +export LD_LIBRARY_PATH=$HERE/usr/lib + +python_dir=$(find "$HERE/usr/lib/" -maxdepth 1 -type d -name "python3.*") +export PYTHONHOME=$python_dir +export PYTHONPATH=$python_dir:$python_dir/lib-dynload:$python_dir/site-packages:$python_dir/encodings +echo "Starting Scopy" +ldd $HERE/usr/bin/scopy +exec $HERE/usr/bin/scopy \ No newline at end of file diff --git a/ci/kuiper/kuiper_build_config.sh b/ci/armhf/armhf_build_config.sh similarity index 75% rename from ci/kuiper/kuiper_build_config.sh rename to ci/armhf/armhf_build_config.sh index d139bf77eb..c035be0a13 100644 --- a/ci/kuiper/kuiper_build_config.sh +++ b/ci/armhf/armhf_build_config.sh @@ -14,26 +14,32 @@ QWT_BRANCH=qwt-multiaxes-updated LIBTINYIIOD_BRANCH=master IIOEMU_BRANCH=main -STAGING_AREA=$SRC_DIR/ci/kuiper/staging +export APPIMAGE=1 + +PYTHON_VERSION=python3.9 # default python version used in CI scripts, can be changed to match locally installed python + +STAGING_AREA=$SRC_DIR/CI/armhf/staging + +STAGING_AREA=$SRC_DIR/ci/armhf/staging SYSROOT=$STAGING_AREA/sysroot SYSROOT_TAR=$STAGING_AREA/sysroot.tar.gz -SYSROOT_DOCKER=$SRC_DIR/ci/kuiper/docker/sysroot.tar.gz +SYSROOT_DOCKER=$SRC_DIR/ci/armhf/docker/sysroot.tar.gz TOOLCHAIN=$STAGING_AREA/cross-pi-gcc TOOLCHAIN_BIN=$TOOLCHAIN/bin TOOLCHAIN_HOST="arm-linux-gnueabihf" -TOOLCHAIN_FILE=$SRC_DIR/ci/kuiper/cmake_toolchain.cmake +TOOLCHAIN_FILE=$SRC_DIR/ci/armhf/cmake_toolchain.cmake QT_LOCATION=$SYSROOT/usr/local/qt5.15 CMAKE_BIN=$STAGING_AREA/cmake/bin/cmake QMAKE_BIN=$QT_LOCATION/bin/qmake JOBS=-j14 -APP_DIR=$SRC_DIR/ci/kuiper/scopy.AppDir -APP_IMAGE=$SRC_DIR/ci/kuiper/Scopy.AppImage -APP_RUN=$SRC_DIR/ci/kuiper/AppRun -APP_DESKTOP=$SRC_DIR/ci/kuiper/scopy.desktop -APP_SQUASHFS=$SRC_DIR/ci/kuiper/scopy.squashfs -RUNTIME_ARMHF=$SRC_DIR/ci/kuiper/runtime-armhf +APP_DIR=$SRC_DIR/ci/armhf/scopy.AppDir +APP_IMAGE=$SRC_DIR/ci/armhf/Scopy.AppImage +APP_RUN=$SRC_DIR/ci/armhf/AppRun +APP_DESKTOP=$SRC_DIR/ci/armhf/scopy.desktop +APP_SQUASHFS=$SRC_DIR/ci/armhf/scopy.squashfs +RUNTIME_ARMHF=$SRC_DIR/ci/armhf/runtime-armhf CMAKE_OPTS=(\ -DCMAKE_SYSROOT="$SYSROOT" \ diff --git a/ci/kuiper/kuiper_build_process.sh b/ci/armhf/armhf_build_process.sh similarity index 80% rename from ci/kuiper/kuiper_build_process.sh rename to ci/armhf/armhf_build_process.sh index b79c8bc48a..f359aaee5d 100755 --- a/ci/kuiper/kuiper_build_process.sh +++ b/ci/armhf/armhf_build_process.sh @@ -2,8 +2,9 @@ set -ex git config --global --add safe.directory $HOME/scopy -SRC_DIR=$(git rev-parse --show-toplevel) -source $SRC_DIR/ci/kuiper/kuiper_build_config.sh +SRC_DIR=$(git rev-parse --show-toplevel 2>/dev/null ) || \ +SRC_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && cd ../../ && pwd ) +source $SRC_DIR/ci/armhf/armhf_build_config.sh echo -- USING CMAKE COMMAND: echo $CMAKE @@ -60,7 +61,7 @@ set_config_opts() { install_packages() { sudo apt update sudo apt install -y build-essential cmake unzip gfortran gcc git bison libtool \ - python3 pip gperf pkg-config gdb-multiarch g++ flex texinfo gawk openssl \ + ${PYTHON_VERSION}-full pip gperf pkg-config gdb-multiarch g++ flex texinfo gawk openssl \ pigz libncurses-dev autoconf automake tar figlet liborc-0.4-dev* patchelf libc6-dev-armhf-cross squashfs-tools pip install mako } @@ -71,7 +72,7 @@ download_cmake() { if [ ! -d cmake ];then wget ${CMAKE_DOWNLOAD_LINK} # unzip and rename - tar -xvf cmake*.tar.gz && rm cmake*.tar.gz && mv cmake* cmake + tar -xf cmake*.tar.gz && rm cmake*.tar.gz && mv cmake* cmake else echo "Cmake already downloaded" fi @@ -123,8 +124,12 @@ build_libiio() { -DENABLE_IPV6:BOOL=OFF \ -DINSTALL_UDEV_RULE:BOOL=OFF " - build_with_cmake - sudo make install + if [ -d 'build' ];then + echo "### IIO-EMU already built --- skipping" + else + build_with_cmake + sudo make install + fi popd } @@ -257,26 +262,13 @@ build_scopy() { pushd $SRC_DIR CURRENT_BUILD_CMAKE_OPTS="\ -DENABLE_PLUGIN_TEST=ON \ - -DENABLE_TESTING=ON + -DENABLE_TESTING=ON \ + -DPYTHON_EXECUTABLE=/usr/bin/python3.9 " build_with_cmake popd } -build_deps(){ - build_libiio - build_libad9361 - build_spdlog - build_libm2k - build_volk - build_gnuradio - build_grscopy - build_grm2k - build_qwt - build_libsigrokdecode - build_libtinyiiod -} - create_appdir(){ BUILD_FOLDER=$SRC_DIR/build @@ -285,7 +277,7 @@ create_appdir(){ PLUGINS=$BUILD_FOLDER/plugins/plugins REGMAP_XMLS=$BUILD_FOLDER/plugins/regmap/xmls TRANSLATIONS_QM=$(find $BUILD_FOLDER/translations -type f -name "*.qm") - COPY_DEPS=$SRC_DIR/ci/kuiper/copy-deps.sh + COPY_DEPS=$SRC_DIR/ci/armhf/copy-deps.sh rm -rf $APP_DIR mkdir $APP_DIR @@ -317,31 +309,23 @@ create_appdir(){ $COPY_DEPS $APP_DIR/usr/bin/iio-emu $APP_DIR/usr/lib $COPY_DEPS $APP_DIR/usr/bin/scopy $APP_DIR/usr/lib $COPY_DEPS "$APP_DIR/usr/share/plugins/*.so" $APP_DIR/usr/lib - cp -r $QT_LOCATION/plugins $APP_DIR/usr - cp -r $SYSROOT/lib/python3.9 $APP_DIR/usr/lib + + # search for the python version linked by cmake and copy inside the appimage the same version + FOUND_PYTHON_VERSION=$(grep 'PYTHON_VERSION' $SRC_DIR/build/CMakeCache.txt | awk -F= '{print $2}' | grep -o 'python[0-9]\+\.[0-9]\+') + python_path=${SYSROOT}/usr/lib/$FOUND_PYTHON_VERSION + cp -r $python_path $APP_DIR/usr/lib + cp -r $SYSROOT/share/libsigrokdecode/decoders $APP_DIR/usr/lib cp $QT_LOCATION/lib/libQt5XcbQpa.so* $APP_DIR/usr/lib cp $QT_LOCATION/lib/libQt5EglFSDeviceIntegration.so* $APP_DIR/usr/lib cp $QT_LOCATION/lib/libQt5DBus.so* $APP_DIR/usr/lib - - cp $SYSROOT/lib/arm-linux-gnueabihf/libstdc++.so* $APP_DIR/usr/lib - cp $SYSROOT/lib/arm-linux-gnueabihf/libc.so* $APP_DIR/usr/lib - cp $SYSROOT/lib/arm-linux-gnueabihf/libdl.so* $APP_DIR/usr/lib - cp $SYSROOT/lib/arm-linux-gnueabihf/libpthread.so* $APP_DIR/usr/lib cp $SYSROOT/lib/arm-linux-gnueabihf/libGLESv2.so* $APP_DIR/usr/lib - - cp $SYSROOT/usr/lib/arm-linux-gnueabihf/ld-linux-armhf.so* $APP_DIR/usr/lib - cp $SYSROOT/usr/lib/arm-linux-gnueabihf/libarmmem-v7l.so* $APP_DIR/usr/lib - cp $SYSROOT/usr/lib/arm-linux-gnueabihf/libm.so* $APP_DIR/usr/lib - cp $SYSROOT/usr/lib/arm-linux-gnueabihf/libgcc_s.so* $APP_DIR/usr/lib - cp $SYSROOT/usr/lib/arm-linux-gnueabihf/libdl.so* $APP_DIR/usr/lib - cp $SYSROOT/usr/lib/arm-linux-gnueabihf/libmd.so* $APP_DIR/usr/lib cp $SYSROOT/lib/arm-linux-gnueabihf/libbsd.so* $APP_DIR/usr/lib cp $SYSROOT/lib/arm-linux-gnueabihf/libXdmcp.so* $APP_DIR/usr/lib cp $SYSROOT/usr/lib/arm-linux-gnueabihf/libXau.so* $APP_DIR/usr/lib - cp $SYSROOT/usr/lib/arm-linux-gnueabihf/libxcb.so* $APP_DIR/usr/lib + cp $SYSROOT/usr/lib/arm-linux-gnueabihf/libffi.so* $APP_DIR/usr/lib } create_appimage(){ @@ -355,7 +339,11 @@ create_appimage(){ # move the sysroot from the home of the docker container to the known location move_sysroot(){ mkdir -p $STAGING_AREA - [ -d /home/runner/sysroot ] && sudo mv /home/runner/sysroot $SYSROOT + [ -d /home/runner/sysroot ] && sudo mv /home/runner/sysroot $SYSROOT || echo "Sysroot not found or already moved" + if [ ! -d $SYSROOT ];then + echo "Missing SYSROOT" + exit 1 + fi } # move and rename the AppImage artifact @@ -368,6 +356,71 @@ generate_ci_envs() $SRC_DIR/ci/general/gen_ci_envs.sh > $SRC_DIR/ci/general/gh-actions.envs } + +# +# Helper functions +# +build_deps(){ + build_libiio + build_libad9361 + build_spdlog + build_libm2k + build_volk + build_gnuradio + build_grscopy + build_grm2k + build_qwt + build_libsigrokdecode + build_libtinyiiod +} + +run_workflow(){ + install_packages + download_cmake + download_crosscompiler + move_sysroot + build_iio-emu + build_scopy + create_appdir + create_appimage + move_appimage +} + +get_tools(){ + install_packages + download_cmake + download_crosscompiler + move_sysroot +} + +generate_appimage(){ + build_iio-emu + build_scopy + create_appdir + create_appimage +} + +dev_setup(){ + # for the local development of Scopy armhf the easyest method is to download the docker image + # a temporary docker volume is created to bridge the local environment and the docker container + # the compiling is done inside the container unsing the already prepared filesystem + docker pull cristianbindea/scopy2-armhf-appimage:latest + docker run -it \ + --mount type=bind,source="$SRC_DIR",target=/home/runner/scopy \ + cristianbindea/scopy2-armhf-appimage:latest + # now this repository folder it shared with the docker container + + # to compile the application use "scopy/ci/armhf/armhf_build_process.sh get_tools generate_appimage" + # after the first compilation just use "scopy/ci/armhf/armhf_build_process.sh generate_appimage" + # to continue using the same docker container use docker start (container id) and "docker attach (container id)" + + # finally after the development is done use this to clean the system + # "docker container rm -v (container id)" + # "docker image rm cristianbindea/scopy2-armhf-appimage:latest" + + # to get the container id use "docker container ls -a" +} + for arg in $@; do $arg done diff --git a/ci/kuiper/build_qt.sh b/ci/armhf/build_qt.sh similarity index 86% rename from ci/kuiper/build_qt.sh rename to ci/armhf/build_qt.sh index 0e43bf4618..e2a32d244a 100755 --- a/ci/kuiper/build_qt.sh +++ b/ci/armhf/build_qt.sh @@ -1,8 +1,9 @@ #!/bin/bash set -ex -SRC_DIR=$(git rev-parse --show-toplevel) -source $SRC_DIR/ci/kuiper/kuiper_build_config.sh +SRC_DIR=$(git rev-parse --show-toplevel 2>/dev/null ) || \ +SRC_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && cd ../../ && pwd ) +source $SRC_DIR/ci/armhf/armhf_build_config.sh install_packages(){ sudo apt install -y build-essential cmake unzip gfortran gcc git bison \ @@ -18,7 +19,7 @@ download_qt(){ wget --progress=dot:giga ${QT_DOWNLOAD_LINK} tar -xf qt-everywhere-src-*.tar.xz && rm qt-everywhere-src-*.tar.xz && mv qt-everywhere-src-* qt-everywhere-src # unzip and rename cd qt-everywhere-src - patch -p1 < $SRC_DIR/ci/kuiper/qt_patch.patch # Patch QT Source + patch -p1 < $SRC_DIR/ci/armhf/qt_patch.patch # Patch QT Source else echo "QT already downloaded" fi @@ -48,7 +49,7 @@ build_qt5.15.2(){ -prefix $QT_SYSTEM_LOCATION \ -extprefix $QT_BUILD_LOCATION \ -eglfs \ - -opengl es2 \ + -opengl desktop \ -device linux-rasp-pi4-v3d-g++ \ -device-option CROSS_COMPILE=$CROSS_COMPILER/bin/arm-linux-gnueabihf- \ -skip qtscript \ diff --git a/ci/kuiper/cmake_toolchain.cmake b/ci/armhf/cmake_toolchain.cmake similarity index 100% rename from ci/kuiper/cmake_toolchain.cmake rename to ci/armhf/cmake_toolchain.cmake diff --git a/ci/armhf/copy-deps.sh b/ci/armhf/copy-deps.sh new file mode 100755 index 0000000000..cae9d95065 --- /dev/null +++ b/ci/armhf/copy-deps.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +set -e +SRC_DIR=$(git rev-parse --show-toplevel 2>/dev/null ) || \ +SRC_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && cd ../../ && pwd ) +source $SRC_DIR/ci/armhf/armhf_build_config.sh + +BINARY=$1 +LOCATION=$2 +LIBS_ARRAY=() +BLACKLISTED=($(wget --quiet https://raw.githubusercontent.com/probonopd/AppImages/master/excludelist -O - | sort | uniq | cut -d '#' -f 1 | grep -v "^#.*" | grep "[^-\s]")) + +if [ ! -f "${SRC_DIR}"/ci/armhf/ldd-mod ]; then + sed 's|.*RTLDLIST=.*|RTLDLIST="/usr/arm-linux-gnueabihf/lib/ld-2.31.so /usr/arm-linux-gnueabihf/lib/ld-linux-armhf.so.3"|' /usr/bin/ldd | tee "${SRC_DIR}"/ci/armhf/ldd-mod + chmod +x "${SRC_DIR}"/ci/armhf/ldd-mod +fi + +export LD_LIBRARY_PATH="${APP_DIR}/usr/lib:${SYSROOT}/lib:${SYSROOT}/lib/arm-linux-gnueabihf:${SYSROOT}/usr/arm-linux-gnueabihf/lib:${SYSROOT}/usr/local/qt5.15/lib:${SYSROOT}/usr/local/lib:${SRC_DIR}/build" +run_ldd(){ + for library in $("${SRC_DIR}"/ci/armhf/ldd-mod "$1" | cut -d '>' -f 2 | awk '{print $1}') + do + # check if the library exists at that path and if it was processed already or blacklisted + if ! [[ "${BLACKLISTED[*]}" =~ "${library##*/}" ]]; then + if [ -f "${library}" ] && ! [[ "${LIBS_ARRAY[*]}" =~ "${library}" ]]; then + LIBS_ARRAY+=("${library}") + echo "---Added new lib: ${library}" + if [ ! -f "${LOCATION}"/"${library##*/}" ]; then + cp "${library}" "${LOCATION}" + [ -L "${library}" ] && cp "$(realpath "${library}")" "${LOCATION}" + fi + run_ldd "${library}" + fi + fi + done +} + +for arg in $BINARY; do + run_ldd "${arg}" +done diff --git a/ci/kuiper/create_docker_image.sh b/ci/armhf/create_docker_image.sh similarity index 71% rename from ci/kuiper/create_docker_image.sh rename to ci/armhf/create_docker_image.sh index 76a387492e..4c0d247af6 100755 --- a/ci/kuiper/create_docker_image.sh +++ b/ci/armhf/create_docker_image.sh @@ -1,8 +1,9 @@ #!/bin/bash set -ex -SRC_DIR=$(git rev-parse --show-toplevel) -source $SRC_DIR/ci/kuiper/kuiper_build_config.sh +SRC_DIR=$(git rev-parse --show-toplevel 2>/dev/null ) || \ +SRC_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && cd ../../ && pwd ) +source $SRC_DIR/ci/armhf/armhf_build_config.sh # install docker install_packages(){ @@ -15,7 +16,7 @@ install_packages(){ } create_sysroot(){ - $SRC_DIR/ci/kuiper/create_sysroot.sh \ + $SRC_DIR/ci/armhf/create_sysroot.sh \ install_packages \ download_kuiper \ install_qemu \ @@ -32,9 +33,9 @@ tar_and_move_sysroot(){ } create_image(){ - pushd ${SRC_DIR}/ci/kuiper/docker - sudo docker build --load --tag cristianbindea/scopy2-kuiper . - # sudo DOCKER_BUILDKIT=0 docker build --tag cristianbindea/scopy2-kuiper . # build the image using old backend + pushd ${SRC_DIR}/ci/armhf/docker + sudo docker build --load --tag cristianbindea/scopy2-armhf-appimage . + # sudo DOCKER_BUILDKIT=0 docker build --tag cristianbindea/scopy2-armhf-appimage . # build the image using old backend popd } diff --git a/ci/kuiper/create_sysroot.sh b/ci/armhf/create_sysroot.sh similarity index 82% rename from ci/kuiper/create_sysroot.sh rename to ci/armhf/create_sysroot.sh index 98f2d9331b..108ab2d7dd 100755 --- a/ci/kuiper/create_sysroot.sh +++ b/ci/armhf/create_sysroot.sh @@ -1,14 +1,15 @@ #!/bin/bash set -ex -SRC_DIR=$(git rev-parse --show-toplevel) -source $SRC_DIR/ci/kuiper/kuiper_build_config.sh +SRC_DIR=$(git rev-parse --show-toplevel 2>/dev/null ) || \ +SRC_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && cd ../../ && pwd ) +source $SRC_DIR/ci/armhf/armhf_build_config.sh IMAGE_FILE=2023-12-13-ADI-Kuiper-full.img install_packages(){ sudo apt update - sudo apt -y install git wget unzip python3 python2 + sudo apt -y install git wget unzip python3 python2 python } download_kuiper(){ @@ -44,7 +45,7 @@ extract_sysroot(){ # execute chroot inside the sysroot folder and install/remove packages using apt configure_sysroot(){ - cat $SRC_DIR/ci/kuiper/inside_chroot.sh | sudo chroot ${SYSROOT} + cat $SRC_DIR/ci/armhf/inside_chroot.sh | sudo chroot ${SYSROOT} } move_and_extract_sysroot(){ diff --git a/ci/kuiper/docker/Dockerfile b/ci/armhf/docker/Dockerfile similarity index 71% rename from ci/kuiper/docker/Dockerfile rename to ci/armhf/docker/Dockerfile index 748bbed5d9..6d88c76fbe 100644 --- a/ci/kuiper/docker/Dockerfile +++ b/ci/armhf/docker/Dockerfile @@ -27,18 +27,18 @@ FROM start AS sysroot_builder ARG USER=runner ENV DEBIAN_FRONTEND=noninteractive COPY sysroot.tar.gz /home/${USER} -RUN git clone https://github.com/analogdevicesinc/scopy -b kuiper-worflow +RUN git clone https://github.com/analogdevicesinc/scopy -b dev WORKDIR /home/${USER}/scopy -RUN ./ci/kuiper/create_sysroot.sh \ +RUN ./ci/armhf/create_sysroot.sh \ install_packages \ move_and_extract_sysroot \ fix_relativelinks -RUN ./ci/kuiper/build_qt.sh \ +RUN ./ci/armhf/build_qt.sh \ install_packages \ download_qt \ download_crosscompiler \ build_qt5.15.2 -RUN ./ci/kuiper/kuiper_build_process.sh \ +RUN ./ci/armhf/armhf_build_process.sh \ install_packages \ download_cmake \ download_crosscompiler \ @@ -51,9 +51,9 @@ FROM start ARG USER=runner ENV DEBIAN_FRONTEND=noninteractive RUN mkdir -p /home/${USER}/sysroot -COPY --from=sysroot_builder /home/${USER}/scopy/ci/kuiper/staging/sysroot/usr /home/${USER}/sysroot/usr -COPY --from=sysroot_builder /home/${USER}/scopy/ci/kuiper/staging/sysroot/share /home/${USER}/sysroot/share -COPY --from=sysroot_builder /home/${USER}/scopy/ci/kuiper/staging/sysroot/include /home/${USER}/sysroot/include +COPY --from=sysroot_builder /home/${USER}/scopy/ci/armhf/staging/sysroot/usr /home/${USER}/sysroot/usr +COPY --from=sysroot_builder /home/${USER}/scopy/ci/armhf/staging/sysroot/share /home/${USER}/sysroot/share +COPY --from=sysroot_builder /home/${USER}/scopy/ci/armhf/staging/sysroot/include /home/${USER}/sysroot/include WORKDIR /home/${USER}/sysroot RUN ln -s usr/bin bin && ln -s usr/lib lib && ln -s usr/sbin sbin WORKDIR /home/${USER} \ No newline at end of file diff --git a/ci/kuiper/inside_chroot.sh b/ci/armhf/inside_chroot.sh similarity index 100% rename from ci/kuiper/inside_chroot.sh rename to ci/armhf/inside_chroot.sh diff --git a/ci/kuiper/build_scopy_kuiper.sh b/ci/armhf/local_build_scopy_for_kuiper.sh similarity index 100% rename from ci/kuiper/build_scopy_kuiper.sh rename to ci/armhf/local_build_scopy_for_kuiper.sh diff --git a/ci/kuiper/qt_patch.patch b/ci/armhf/qt_patch.patch similarity index 100% rename from ci/kuiper/qt_patch.patch rename to ci/armhf/qt_patch.patch diff --git a/ci/kuiper/runtime-armhf b/ci/armhf/runtime-armhf similarity index 100% rename from ci/kuiper/runtime-armhf rename to ci/armhf/runtime-armhf diff --git a/ci/kuiper/scopy.desktop b/ci/armhf/scopy.desktop similarity index 100% rename from ci/kuiper/scopy.desktop rename to ci/armhf/scopy.desktop diff --git a/ci/kuiper/AppRun b/ci/kuiper/AppRun deleted file mode 100755 index 9a575a5c17..0000000000 --- a/ci/kuiper/AppRun +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -set -e -SELF=$(readlink -f "$0") -HERE=${SELF%/*} - -export QT_PLUGIN_PATH=$HERE/usr/plugins -export QT_QPA_PLATFORM_PLUGIN_PATH=$HERE/usr/plugins/platforms -export LD_LIBRARY_PATH=$HERE/usr/lib - -exec $HERE/usr/bin/scopy diff --git a/ci/kuiper/copy-deps.sh b/ci/kuiper/copy-deps.sh deleted file mode 100755 index dfdd0e22e3..0000000000 --- a/ci/kuiper/copy-deps.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash - -set -e -SRC_DIR=$(git rev-parse --show-toplevel) -source $SRC_DIR/ci/kuiper/kuiper_build_config.sh - -BINARY=$1 -LOCATION=$2 - - -if [ ! -f "${SRC_DIR}"/ci/kuiper/ldd-mod ]; then - sed 's|.*RTLDLIST=.*|RTLDLIST="/usr/arm-linux-gnueabihf/lib/ld-2.31.so /usr/arm-linux-gnueabihf/lib/ld-linux-armhf.so.3"|' /usr/bin/ldd | tee "${SRC_DIR}"/ci/kuiper/ldd-mod - chmod +x "${SRC_DIR}"/ci/kuiper/ldd-mod -fi - -export LD_LIBRARY_PATH="${APP_DIR}/usr/lib:${SYSROOT}/lib:${SYSROOT}/lib/arm-linux-gnueabihf:${SYSROOT}/usr/arm-linux-gnueabihf/lib:${SYSROOT}/usr/local/qt5.15/lib:${SYSROOT}/usr/local/lib:${SRC_DIR}/build" -LIBS_ARRAY=() -run_ldd(){ - for library in $("${SRC_DIR}"/ci/kuiper/ldd-mod "$1" | cut -d '>' -f 2 | awk '{print $1}') - do - # check if the library exists at that path and if it was processed already - if [ -f "${library}" ] && ! [[ "${LIBS_ARRAY[*]}" =~ "${library}" ]]; then - LIBS_ARRAY+=("${library}") - echo "---NEW: ${library}" - if [ ! -f "${LOCATION}"/"${library##*/}" ]; then - cp --verbose "${library}" "${LOCATION}" - [ -L "${library}" ] && cp --verbose "$(realpath "${library}")" "${LOCATION}" - fi - run_ldd "${library}" - fi - done -} - -for arg in $BINARY; do - run_ldd "${arg}" -done diff --git a/ci/x86_64/AppRun b/ci/x86_64/AppRun new file mode 100755 index 0000000000..f66a8dcf19 --- /dev/null +++ b/ci/x86_64/AppRun @@ -0,0 +1,15 @@ +#!/bin/bash +set -e +SELF=$(readlink -f "$0") +HERE=${SELF%/*} + +export QT_PLUGIN_PATH=$HERE/usr/plugins +export QT_QPA_PLATFORM_PLUGIN_PATH=$HERE/usr/plugins/platforms +export LD_LIBRARY_PATH=$HERE/usr/lib + +python_dir=$(find "$HERE/usr/lib/" -maxdepth 1 -type d -name "python3.*") +export PYTHONHOME=$python_dir +export PYTHONPATH=$python_dir:$python_dir/lib-dynload:$python_dir/site-packages:$python_dir/encodings +echo "Starting Scopy" +ldd $HERE/usr/bin/scopy +exec $HERE/usr/bin/scopy diff --git a/ci/x86_64/copy-deps.sh b/ci/x86_64/copy-deps.sh new file mode 100755 index 0000000000..35d3ecbe6f --- /dev/null +++ b/ci/x86_64/copy-deps.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +set -e +SRC_DIR=$(git rev-parse --show-toplevel 2>/dev/null ) || \ +SRC_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && cd ../../ && pwd ) +source $SRC_DIR/ci/armhf/armhf_build_config.sh + +BINARY=$1 +LOCATION=$2 +LIBS_ARRAY=() +BLACKLISTED=($(wget --quiet https://raw.githubusercontent.com/probonopd/AppImages/master/excludelist -O - | sort | uniq | cut -d '#' -f 1 | grep -v "^#.*" | grep "[^-\s]")) + +export LD_LIBRARY_PATH="${APP_DIR}/usr/lib:${SYSROOT}/lib:${SYSROOT}/lib/arm-linux-gnueabihf:${SYSROOT}/usr/arm-linux-gnueabihf/lib:${SYSROOT}/usr/local/qt5.15/lib:${SYSROOT}/usr/local/lib:${SRC_DIR}/build" +run_ldd(){ + for library in $(ldd "$1" | cut -d '>' -f 2 | awk '{print $1}') + do + # check if the library exists at that path and if it was processed already or blacklisted + if ! [[ "${BLACKLISTED[*]}" =~ "${library##*/}" ]]; then + if [ -f "${library}" ] && ! [[ "${LIBS_ARRAY[*]}" =~ "${library}" ]]; then + LIBS_ARRAY+=("${library}") + echo "---Added new lib: ${library}" + if [ ! -f "${LOCATION}"/"${library##*/}" ]; then + cp "${library}" "${LOCATION}" + [ -L "${library}" ] && cp "$(realpath "${library}")" "${LOCATION}" + strip --strip-unneeded "${LOCATION}"/"${library##*/}" + fi + run_ldd "${library}" + fi + fi + done +} + +for arg in $BINARY; do + run_ldd "${arg}" +done diff --git a/ci/x86_64/docker/Dockerfile b/ci/x86_64/docker/Dockerfile new file mode 100644 index 0000000000..c758c53f88 --- /dev/null +++ b/ci/x86_64/docker/Dockerfile @@ -0,0 +1,35 @@ +#docker build -t cristianbindea/scopy2-x86_64-appimage . +#DOCKER_BUILDKIT=0 +FROM ubuntu:20.04 +SHELL ["/bin/bash", "-c"] + +ARG USER=runner +ARG DEBIAN_FRONTEND=noninteractive + +ENV TZ=Europe/Bucharest +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone +RUN apt-get update && apt-get -y upgrade && apt-get install -y apt-utils sudo git tzdata keyboard-configuration + +RUN groupadd -g 1000 -r $USER && \ + useradd -u 1000 -g 1000 --create-home -r $USER + +#Change password +RUN echo "$USER:$USER" | chpasswd + +#Make sudo passwordless +RUN echo "${USER} ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-$USER && \ + usermod -aG sudo $USER && \ + usermod -aG plugdev $USER + +USER $USER +WORKDIR /home/${USER} +RUN git clone https://github.com/analogdevicesinc/scopy --branch dev +WORKDIR /home/${USER}/scopy + +ENV CI_SCRIPT=ON +RUN ./ci/x86_64/x86-64_appimage_process.sh install_packages +RUN sudo pip3 install aqtinstall && sudo python3 -m aqt install-qt --outputdir /opt/Qt linux desktop 5.15.2 +RUN ./ci/x86_64/x86-64_appimage_process.sh clone download_tools build_deps + +WORKDIR /home/${USER} +# RUN rm -rf scopy diff --git a/ci/x86_64/scopy.desktop b/ci/x86_64/scopy.desktop new file mode 100644 index 0000000000..ee6591769f --- /dev/null +++ b/ci/x86_64/scopy.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Icon=scopy +Exec=scopy +Terminal=false +Type=Application +Categories=Science +Name=Scopy +GenericName=Oscilloscope +Comment=A software oscilloscope diff --git a/ci/x86_64/x86-64_appimage_process.sh b/ci/x86_64/x86-64_appimage_process.sh new file mode 100755 index 0000000000..e8eda2e393 --- /dev/null +++ b/ci/x86_64/x86-64_appimage_process.sh @@ -0,0 +1,473 @@ +#!/bin/bash +set -ex + +## Set STAGING +USE_STAGING=ON +## + +if [ "$CI_SCRIPT" == "ON" ] + then + SRC_DIR=/home/runner/scopy + git config --global --add safe.directory '*' + USE_STAGING=OFF + else + SRC_DIR=$(git rev-parse --show-toplevel) +fi + +export APPIMAGE=1 + +LIBIIO_VERSION=v0.25 +LIBAD9361_BRANCH=main +LIBM2K_BRANCH=main +SPDLOG_BRANCH=v1.x +VOLK_BRANCH=main +GNURADIO_BRANCH=maint-3.10 +GRSCOPY_BRANCH=3.10 +GRM2K_BRANCH=main +LIBSIGROKDECODE_BRANCH=master +QWT_BRANCH=qwt-multiaxes-updated +LIBTINYIIOD_BRANCH=master +IIOEMU_BRANCH=master + +# default python version used in CI scripts, can be changed to match locally installed python +PYTHON_VERSION=python3.8 + +QT_LOCATION=/opt/Qt/5.15.2/gcc_64 + +STAGING_AREA=$SRC_DIR/ci/x86_64/staging +QMAKE_BIN=$QT_LOCATION/bin/qmake +CMAKE_BIN=${STAGING_AREA}/cmake/bin/cmake +JOBS=-j14 + +APP_DIR_NAME=scopy.AppDir +APP_DIR=$SRC_DIR/ci/x86_64/$APP_DIR_NAME +APP_IMAGE=$SRC_DIR/ci/x86_64/Scopy-x86_64.AppImage + +if [ "$USE_STAGING" == "ON" ] + then + echo -- USING STAGING FOLDER: $STAGING_AREA_DEPS + STAGING_AREA_DEPS=$STAGING_AREA/dependencies + export LD_LIBRARY_PATH=$STAGING_AREA_DEPS/lib:$QT_LOCATION/lib:$LD_LIBRARY_PATH + CMAKE_OPTS=(\ + -DCMAKE_LIBRARY_PATH=$STAGING_AREA_DEPS \ + -DCMAKE_INSTALL_PREFIX=$STAGING_AREA_DEPS \ + -DCMAKE_PREFIX_PATH=$QT_LOCATION\;$STAGING_AREA_DEPS \ + -DCMAKE_EXE_LINKER_FLAGS=-L$STAGING_AREA_DEPS\;-L$STAGING_AREA_DEPS/lib \ + -DCMAKE_SHARED_LINKER_FLAGS=-L$STAGING_AREA_DEPS\;-L$STAGING_AREA_DEPS/lib \ + -DCMAKE_BUILD_TYPE=RelWithDebInfo \ + -DCMAKE_VERBOSE_MAKEFILE=ON \ + ) + echo -- STAGING_DIR $STAGING_AREA_DEPS + else + echo -- NO STAGING: INSTALLING IN SYSTEM + STAGING_AREA_DEPS=/usr/local + export LD_LIBRARY_PATH=$QT_LOCATION/lib:$LD_LIBRARY_PATH: + CMAKE_OPTS=(\ + -DCMAKE_PREFIX_PATH=$QT_LOCATION \ + -DCMAKE_BUILD_TYPE=RelWithDebInfo \ + -DCMAKE_VERBOSE_MAKEFILE=ON \ + ) +fi + +CMAKE="$CMAKE_BIN ${CMAKE_OPTS[*]}" +echo -- USING CMAKE COMMAND: +echo $CMAKE +echo -- USING QT: $QT_LOCATION +echo -- USING QMAKE: $QMAKE_BIN + +clone() { + echo "#######CLONE#######" + mkdir -p $STAGING_AREA + pushd $STAGING_AREA + [ -d 'libiio' ] || git clone --recursive https://github.com/analogdevicesinc/libiio.git -b $LIBIIO_VERSION libiio + [ -d 'libad9361' ] || git clone --recursive https://github.com/analogdevicesinc/libad9361-iio.git -b $LIBAD9361_BRANCH libad9361 + [ -d 'libm2k' ] || git clone --recursive https://github.com/analogdevicesinc/libm2k.git -b $LIBM2K_BRANCH libm2k + [ -d 'spdlog' ] || git clone --recursive https://github.com/gabime/spdlog.git -b $SPDLOG_BRANCH spdlog + [ -d 'gr-scopy' ] || git clone --recursive https://github.com/analogdevicesinc/gr-scopy.git -b $GRSCOPY_BRANCH gr-scopy + [ -d 'gr-m2k' ] || git clone --recursive https://github.com/analogdevicesinc/gr-m2k.git -b $GRM2K_BRANCH gr-m2k + [ -d 'volk' ] || git clone --recursive https://github.com/gnuradio/volk.git -b $VOLK_BRANCH volk + [ -d 'gnuradio' ] || git clone --recursive https://github.com/gnuradio/gnuradio.git -b $GNURADIO_BRANCH gnuradio + [ -d 'qwt' ] || git clone --recursive https://github.com/cseci/qwt.git -b $QWT_BRANCH qwt + [ -d 'libsigrokdecode' ] || git clone --recursive https://github.com/sigrokproject/libsigrokdecode.git -b $LIBSIGROKDECODE_BRANCH libsigrokdecode + [ -d 'libtinyiiod' ] || git clone --recursive https://github.com/analogdevicesinc/libtinyiiod.git -b $LIBTINYIIOD_BRANCH libtinyiiod + popd +} + +download_tools() { + mkdir -p ${STAGING_AREA} + pushd ${STAGING_AREA} + + if [ ! -d cmake ];then + wget https://github.com/Kitware/CMake/releases/download/v3.29.0-rc2/cmake-3.29.0-rc2-linux-x86_64.tar.gz + tar -xf cmake*.tar.gz && rm cmake*.tar.gz && mv cmake* cmake # unzip and rename + fi + + # download tools for creating the AppDir and the AppImage + if [ ! -f linuxdeploy-x86_64.AppImage ];then + wget https://github.com/linuxdeploy/linuxdeploy/releases/download/1-alpha-20231026-1/linuxdeploy-x86_64.AppImage + chmod +x linuxdeploy-x86_64.AppImage + fi + + if [ ! -f linuxdeploy-plugin-qt-x86_64.AppImage ];then + wget https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage + chmod +x linuxdeploy-plugin-qt-x86_64.AppImage + fi + + if [ ! -f linuxdeploy-plugin-appimage-x86_64.AppImage ];then + wget https://github.com/linuxdeploy/linuxdeploy-plugin-appimage/releases/download/1-alpha-20230713-1/linuxdeploy-plugin-appimage-x86_64.AppImage + chmod +x linuxdeploy-plugin-appimage-x86_64.AppImage + fi + + popd +} + +build_with_cmake() { + INSTALL=$1 + [ -z $INSTALL ] && INSTALL=ON + BUILD_FOLDER=$PWD/build + rm -rf $BUILD_FOLDER + mkdir -p $BUILD_FOLDER + cd $BUILD_FOLDER + $CMAKE $CURRENT_BUILD_CMAKE_OPTS ../ + make $JOBS + if [ "$INSTALL" == "ON" ];then + if [ "$USE_STAGING" == "ON" ]; then make install; else sudo make install; fi + fi + CURRENT_BUILD_CMAKE_OPTS="" +} + +install_packages() { + sudo DEBIAN_FRONTEND=noninteractive apt-get -y install + + sudo apt-get update + sudo apt-get -y upgrade + sudo apt-get -y install \ + $PYTHON_VERSION-full python3-pip lib$PYTHON_VERSION-dev python3-numpy \ + keyboard-configuration vim git wget unzip\ + g++ build-essential cmake curl autogen autoconf autoconf-archive pkg-config flex bison swig \ + subversion mesa-common-dev graphviz xserver-xorg gettext texinfo mm-common doxygen \ + libboost-all-dev libfftw3-bin libfftw3-dev libfftw3-3 liblog4cpp5v5 liblog4cpp5-dev \ + libxcb-xinerama0 libgmp3-dev libzip-dev libglib2.0-dev libglibmm-2.4-dev libsigc++-2.0-dev \ + libclang1-9 libmatio-dev liborc-0.4-dev libgl1-mesa-dev libserialport0 libserialport-dev \ + libusb-1.0 libusb-1.0-0 libusb-1.0-0-dev libavahi-client-dev libsndfile1-dev \ + libxkbcommon-x11-0 libqt5gui5 libncurses5 libtool libaio-dev libzmq3-dev libxml2-dev + + pip3 install mako + pip3 install packaging +} + +build_libiio() { + echo "### Building libiio - version $LIBIIO_VERSION" + pushd $STAGING_AREA/libiio + CURRENT_BUILD_CMAKE_OPTS="\ + -DWITH_TESTS:BOOL=OFF \ + -DWITH_DOC:BOOL=OFF \ + -DHAVE_DNS_SD:BOOL=OFF\ + -DWITH_MATLAB_BINDINGS:BOOL=OFF \ + -DCSHARP_BINDINGS:BOOL=OFF \ + -DPYTHON_BINDINGS:BOOL=OFF \ + -DWITH_SERIAL_BACKEND:BOOL=ON \ + -DENABLE_IPV6:BOOL=OFF \ + -DINSTALL_UDEV_RULE:BOOL=OFF + " + build_with_cmake $1 + popd +} + +build_libad9361() { + echo "### Building libad9361 - branch $LIBAD9361_BRANCH" + pushd $STAGING_AREA/libad9361 + build_with_cmake $1 + popd +} + +build_spdlog() { + echo "### Building spdlog - branch $SPDLOG_BRANCH" + pushd $STAGING_AREA/spdlog + CURRENT_BUILD_CMAKE_OPTS="-DSPDLOG_BUILD_SHARED=ON" + build_with_cmake $1 + popd +} + +build_libm2k() { + echo "### Building libm2k - branch $LIBM2K_BRANCH" + pushd $STAGING_AREA/libm2k + CURRENT_BUILD_CMAKE_OPTS="\ + -DENABLE_PYTHON=OFF \ + -DENABLE_CSHARP=OFF \ + -DBUILD_EXAMPLES=OFF \ + -DENABLE_TOOLS=OFF \ + -DINSTALL_UDEV_RULES=OFF \ + " + build_with_cmake $1 + popd +} + +build_volk() { + echo "### Building volk - branch $VOLK_BRANCH" + pushd $STAGING_AREA/volk + CURRENT_BUILD_CMAKE_OPTS="-DPYTHON_EXECUTABLE=/usr/bin/python3" + build_with_cmake $1 + popd +} + +build_gnuradio() { + echo "### Building gnuradio - branch $GNURADIO_BRANCH" + pushd $STAGING_AREA/gnuradio + CURRENT_BUILD_CMAKE_OPTS="\ + -DPYTHON_EXECUTABLE=/usr/bin/python3 \ + -DENABLE_DEFAULT=OFF \ + -DENABLE_GNURADIO_RUNTIME=ON \ + -DENABLE_GR_ANALOG=ON \ + -DENABLE_GR_BLOCKS=ON \ + -DENABLE_GR_FFT=ON \ + -DENABLE_GR_FILTER=ON \ + -DENABLE_GR_IIO=ON \ + -DENABLE_POSTINSTALL=OFF + " + build_with_cmake $1 + popd +} + +build_grscopy() { + echo "### Building gr-scopy - branch $GRSCOPY_BRANCH" + pushd $STAGING_AREA/gr-scopy + build_with_cmake $1 + popd +} + +build_grm2k() { + echo "### Building gr-m2k - branch $GRM2K_BRANCH" + pushd $STAGING_AREA/gr-m2k + CURRENT_BUILD_CMAKE_OPTS="\ + -DENABLE_PYTHON=OFF \ + -DDIGITAL=OFF + " + build_with_cmake $1 + popd +} + +build_qwt() { + echo "### Building qwt - branch $QWT_BRANCH" + pushd $STAGING_AREA/qwt + git clean -xdf + sed -i 's|/usr/local/qwt-$$QWT_VERSION-ma|/usr/local|g' qwtconfig.pri + + INSTALL=$1 + [ -z $INSTALL ] && INSTALL=ON + + if [ "$USE_STAGING" == "ON" ] + then + $QMAKE_BIN INCLUDEPATH=$STAGING_AREA_DEPS/include LIBS=-L$STAGING_AREA_DEPS/lib qwt.pro + make $JOBS + if [ "$INSTALL" == "ON" ];then + make INSTALL_ROOT=$STAGING_AREA_DEPS install + fi + cp -r $STAGING_AREA_DEPS/usr/local/* $STAGING_AREA_DEPS/ + else + $QMAKE_BIN qwt.pro + make $JOBS + if [ "$INSTALL" == "ON" ];then + sudo make install + fi + fi + + popd +} + +build_libsigrokdecode() { + echo "### Building libsigrokdecode - branch $LIBSIGROKDECODE_BRANCH" + pushd $STAGING_AREA/libsigrokdecode + git clean -xdf + ./autogen.sh + + INSTALL=$1 + [ -z $INSTALL ] && INSTALL=ON + + if [ "$USE_STAGING" == "ON" ] + then + ./configure --prefix $STAGING_AREA_DEPS + LD_RUN_PATH=$STAGING_AREA_DEPS/lib make $JOBS + else + ./configure + make $JOBS + fi + + if [ "$INSTALL" == "ON" ];then + if [ "$USE_STAGING" == "ON" ]; then make install; else sudo make install; fi + fi + popd +} + +build_libtinyiiod() { + echo "### Building libtinyiiod - branch $LIBTINYIIOD_BRANCH" + pushd $STAGING_AREA/libtinyiiod + CURRENT_BUILD_CMAKE_OPTS="-DBUILD_EXAMPLES=OFF" + build_with_cmake $1 + popd +} + +build_iio-emu() { + echo "### Building iio-emu - branch $IIOEMU_BRANCH" + mkdir -p $STAGING_AREA + pushd $STAGING_AREA + [ -d 'iio-emu' ] || git clone --recursive https://github.com/analogdevicesinc/iio-emu -b $IIOEMU_BRANCH iio-emu + pushd $STAGING_AREA/iio-emu + build_with_cmake OFF + popd + popd +} + +build_scopy() { + echo "### Building scopy" + pushd $SRC_DIR + CURRENT_BUILD_CMAKE_OPTS="\ + -DCLONE_IIO_EMU=OFF \ + -DPYTOHN_EXECUTABLE=/usr/bin/$PYTHON_VERSION + " + build_with_cmake OFF + popd +} + +create_appdir(){ + pushd ${STAGING_AREA} + BUILD_FOLDER=$SRC_DIR/build + EMU_BUILD_FOLDER=$STAGING_AREA/iio-emu/build + SCOPY_DLL=$(find $BUILD_FOLDER -maxdepth 2 -type f -name "libscopy*") + PLUGINS=$BUILD_FOLDER/plugins/plugins + REGMAP_XMLS=$BUILD_FOLDER/plugins/regmap/xmls + TRANSLATIONS_QM=$(find $BUILD_FOLDER/translations -type f -name "*.qm") + LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$STAGING_AREA_DEPS/lib:$QT_LOCATION/lib + DLL_FOLDER=${STAGING_AREA}/dll_folder + COPY_DEPS=${SRC_DIR}/ci/x86_64/copy-deps.sh + export PATH=$QT_LOCATION:$PATH + sudo ldconfig + + rm -rf $APP_DIR + rm -rf $DLL_FOLDER + mkdir $DLL_FOLDER + cp $SCOPY_DLL $DLL_FOLDER + cp $PLUGINS/* $DLL_FOLDER + + export QMAKE=$QMAKE_BIN # this is needed for deploy-plugin-qt.AppImage + # inside a docker image you can't run an appimage executable without privileges + # so the solution is to extract the appimage first and only then to run it + export APPIMAGE_EXTRACT_AND_RUN=1 + ${STAGING_AREA}/linuxdeploy-x86_64.AppImage \ + --appdir $APP_DIR \ + --executable $SRC_DIR/build/scopy \ + --custom-apprun $SRC_DIR/ci/x86_64/AppRun \ + --desktop-file $SRC_DIR/ci/x86_64/scopy.desktop \ + --icon-file $SRC_DIR/gui/res/scopy.png \ + --deploy-deps-only $DLL_FOLDER \ + --plugin qt + + $COPY_DEPS "$DLL_FOLDER/*" $APP_DIR/usr/lib + rm -rf $DLL_FOLDER + cp $SCOPY_DLL $APP_DIR/usr/lib + cp -r $PLUGINS $APP_DIR/usr/share + + cp $EMU_BUILD_FOLDER/iio-emu $APP_DIR/usr/bin + cp ${STAGING_AREA_DEPS}/lib/tinyiiod.so* $APP_DIR/usr/lib + + # search for the python version linked by cmake and copy inside the appimage the same version + FOUND_PYTHON_VERSION=$(grep 'PYTHON_VERSION' $SRC_DIR/build/CMakeCache.txt | awk -F= '{print $2}' | grep -o 'python[0-9]\+\.[0-9]\+') + python_path=/usr/lib/$FOUND_PYTHON_VERSION + cp -r $python_path $APP_DIR/usr/lib + + if [ -d $STAGING_AREA_DEPS/share/libsigrokdecode/decoders ]; then + cp -r $STAGING_AREA_DEPS/share/libsigrokdecode/decoders $APP_DIR/usr/lib + elif [ -d $STAGING_AREA/libsigrokdecode/decoders ];then + cp -r $STAGING_AREA/libsigrokdecode/decoders $APP_DIR/usr/lib + else + echo "No decoders for libsigrokdecode found" + exit 1 + fi + + mkdir $APP_DIR/usr/share/translations + cp $TRANSLATIONS_QM $APP_DIR/usr/share/translations + + if [ -d $REGMAP_XMLS ]; then + cp -r $REGMAP_XMLS $APP_DIR/usr/share/plugins + fi + + cp $STAGING_AREA_DEPS/lib/libspdlog.so* $APP_DIR/usr/lib + cp -r $QT_LOCATION/plugins $APP_DIR/usr + cp $QT_LOCATION/lib/libQt5XcbQpa.so* $APP_DIR/usr/lib + cp $QT_LOCATION/lib/libQt5EglFSDeviceIntegration.so* $APP_DIR/usr/lib + cp $QT_LOCATION/lib/libQt5DBus.so* $APP_DIR/usr/lib + cp /usr/lib/x86_64-linux-gnu/libXdmcp.so* $APP_DIR/usr/lib + cp /usr/lib/x86_64-linux-gnu/libbsd.so* $APP_DIR/usr/lib + cp /usr/lib/x86_64-linux-gnu/libXau.so* $APP_DIR/usr/lib + cp /usr/lib/x86_64-linux-gnu/libffi.so* $APP_DIR/usr/lib + popd +} + +create_appimage(){ + rm -rf $APP_IMAGE + + pushd ${STAGING_AREA} + export APPIMAGE_EXTRACT_AND_RUN=1 + ${STAGING_AREA}/linuxdeploy-plugin-appimage-x86_64.AppImage --appdir $APP_DIR + mv Scopy*.AppImage $APP_IMAGE + chmod +x $APP_IMAGE + popd +} + +generate_ci_envs(){ + $GITHUB_WORKSPACE/ci/general/gen_ci_envs.sh > $GITHUB_WORKSPACE/ci/x86_64/gh-actions.envs +} + +move_appimage(){ + mv $APP_IMAGE $SRC_DIR +} + + +# +# Helper functions +# + +build_deps(){ + install_packages + clone + download_tools + build_libiio ON + build_libad9361 ON + build_spdlog ON + build_libm2k ON + build_volk ON + build_gnuradio ON + build_grscopy ON + build_grm2k ON + build_qwt ON + build_libsigrokdecode ON + build_libtinyiiod ON +} + +run_workflow(){ + install_packages + download_tools + build_iio-emu + build_scopy + create_appdir + create_appimage + move_appimage +} + +get_tools(){ + install_packages + download_tools +} + +generate_appimage(){ + download_tools + build_iio-emu + build_scopy + create_appdir + create_appimage +} + + +for arg in $@; do + $arg +done diff --git a/common/src/scopyconfig.cpp b/common/src/scopyconfig.cpp index 883c1dc496..4940e1ac25 100644 --- a/common/src/scopyconfig.cpp +++ b/common/src/scopyconfig.cpp @@ -25,7 +25,7 @@ QString scopy::config::localPluginFolderPath() #if defined __APPLE__ return QCoreApplication::applicationDirPath() + "/plugins/plugins"; -#elif defined(__arm__) +#elif defined(__appimage__) return QCoreApplication::applicationDirPath() + "/../share/plugins"; #endif @@ -38,7 +38,7 @@ QString scopy::config::localTranslationFolderPath() { #if defined __APPLE__ return QCoreApplication::applicationDirPath() + "/translations"; -#elif defined(__arm__) +#elif defined(__appimage__) return QCoreApplication::applicationDirPath() + "/../share/translations"; #endif diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 0bfc9ea582..9b5f7777de 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -34,12 +34,24 @@ endif() option(WITH_PYTHON "Enable Python" ON) if(${WITH_PYTHON}) set(Python_ADDITIONAL_VERSIONS 3) + if(PYTHON_EXECUTABLE) + message(STATUS "Using custom Python EXECUTABLE: ${PYTHON_EXECUTABLE}") + set(Python3_EXECUTABLE ${PYTHON_EXECUTABLE}) + else() + message(STATUS "Using default Python EXECUTABLE") + endif() + if(CMAKE_SYSTEM_PROCESSOR MATCHES arm) - find_package(Python3 REQUIRED COMPONENTS Interpreter) + find_package(Python3 3.9 EXACT REQUIRED COMPONENTS Interpreter) + message(STATUS "Host Python Interpreter " ${Python3_EXECUTABLE}) + set(Python3_EXECUTABLE ${CMAKE_SYSROOT}/bin/python3.9) + message(STATUS "Target Python Interpreter " ${Python3_EXECUTABLE}) else() find_package(Python3 REQUIRED COMPONENTS Interpreter Development) + message(STATUS "Python Interpreter " ${Python3_EXECUTABLE}) + message(STATUS "Python Libraries " ${Python3_LIBRARIES}) endif() - set(PYTHON_VERSION python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}) + set(PYTHON_VERSION python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR} CACHE STRING "PYTHON_USED") set(PYTHON_VERSION ${PYTHON_VERSION} PARENT_SCOPE) if(NOT Python3_FOUND) set(WITH_PYTHON OFF) diff --git a/core/src/scopymainwindow.cpp b/core/src/scopymainwindow.cpp index 925db52f10..1e9e6dc203 100644 --- a/core/src/scopymainwindow.cpp +++ b/core/src/scopymainwindow.cpp @@ -443,7 +443,7 @@ void ScopyMainWindow::loadDecoders() #if defined(WITH_SIGROK) && defined(WITH_PYTHON) #if defined __APPLE__ QString path = QCoreApplication::applicationDirPath() + "/decoders"; -#elif defined(__arm__) +#elif defined(__appimage__) QString path = QCoreApplication::applicationDirPath() + "/../lib/decoders"; #else QString path = "decoders"; diff --git a/plugins/regmap/src/utils.cpp b/plugins/regmap/src/utils.cpp index 4005f2e745..268166d6a6 100644 --- a/plugins/regmap/src/utils.cpp +++ b/plugins/regmap/src/utils.cpp @@ -58,7 +58,7 @@ QDir Utils::setXmlPath() xmlsPath.setPath(REGMAP_XML_PATH_LOCAL); #elif defined __APPLE__ xmlsPath.setPath(QCoreApplication::applicationDirPath() + "/plugins/plugins/xmls"); -#elif defined(__arm__) +#elif defined(__appimage__) xmlsPath.setPath(QCoreApplication::applicationDirPath() + "/../share/plugins/xmls"); #else xmlsPath.setPath(REGMAP_XML_SYSTEM_PATH);