diff --git a/.github/workflows/kuiperbuild.yml b/.github/workflows/kuiperbuild.yml new file mode 100644 index 0000000000..0bb648fb3b --- /dev/null +++ b/.github/workflows/kuiperbuild.yml @@ -0,0 +1,37 @@ +name: Kuiper Scopy Build + +on: [push, pull_request] + +env: + BUILD_HOST: ubuntu-22.04 + USERNAME: github-actions + +jobs: + + build_scopy_on_ubuntu22: + runs-on: ubuntu-22.04 + container: + image: cristianbindea/scopy2-kuiper:latest + options: --user root + steps: + - uses: actions/checkout@v4 + + - name: Build Scopy + shell: bash + run: | + cd $GITHUB_WORKSPACE + ./ci/kuiper/kuiper_build_process.sh install_packages download_cmake download_crosscompiler move_sysroot build_scopy create_appdir create_appimage move_appimage + + - name: Set short git commit SHA + shell: bash + run: echo "commit_sha=$(git rev-parse --short ${{ github.sha }})" >> "$GITHUB_ENV" + + - name: Upload binaries to release + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: ${{ github.workspace }}\Scopy.appimage + asset_name: scopy-linux-armhf-${{ env.commit_sha }} + tag: ${{ github.ref }} + overwrite: true + body: "Scopy armhf" \ No newline at end of file diff --git a/.gitignore b/.gitignore index 7e72fec662..a64be503e1 100644 --- a/.gitignore +++ b/.gitignore @@ -36,6 +36,8 @@ build/* .vscode/* ci/ubuntu/staging ci/macOS/staging +ci/kuiper/staging +ci/kuiper/docker/sysroot windows/* core/include/scopy-core_config.h core/include/scopy-core_export.h diff --git a/ci/kuiper/AppRun b/ci/kuiper/AppRun new file mode 100755 index 0000000000..b73d926f23 --- /dev/null +++ b/ci/kuiper/AppRun @@ -0,0 +1,13 @@ +#!/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 + +echo LD_LIBRARY_PATH: $LD_LIBRARY_PATH +echo PATH: $PATH +ldd $HERE/usr/bin/scopy +exec $HERE/usr/bin/scopy diff --git a/ci/kuiper/AppRun-armhf b/ci/kuiper/AppRun-armhf new file mode 100644 index 0000000000..dc56706aad Binary files /dev/null and b/ci/kuiper/AppRun-armhf differ diff --git a/ci/kuiper/cmake_toolchain.cmake b/ci/kuiper/cmake_toolchain.cmake index 8122187471..2f53210307 100644 --- a/ci/kuiper/cmake_toolchain.cmake +++ b/ci/kuiper/cmake_toolchain.cmake @@ -7,7 +7,7 @@ set(CMAKE_LIBRARY_ARCHITECTURE arm-linux-gnueabihf) # In this case the variables CMAKE_SYSROOT and STAGING_AREA are defined as parameters to the cmake command set(TOOLCHAIN_FILE ${STAGING_AREA}/cross-pi-gcc) set(TOOLCHAIN_BIN ${TOOLCHAIN_FILE}/bin) -set(CMAKE_PREFIX_PATH "${CMAKE_SYSROOT}/usr/local/qt5.15") +set(CMAKE_PREFIX_PATH ${QT_LOCATION}) list(APPEND CMAKE_PREFIX_PATH "${CMAKE_SYSROOT}/usr/lib/arm-linux-gnueabihf") list(APPEND CMAKE_PREFIX_PATH "${CMAKE_SYSROOT}/lib") set(CMAKE_VERBOSE ON) @@ -45,6 +45,8 @@ set(CMAKE_CXX_FLAGS_RELEASE "-Os -DNDEBUG" ) set(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,-O1 -Wl,--hash-style=gnu -mthumb -lpthread -pthread") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L${CMAKE_SYSROOT}/usr/lib/arm-linux-gnueabihf") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L${CMAKE_SYSROOT}/usr/lib") +set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L${CMAKE_SYSROOT}/usr/local/lib") +set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L${QT_LOCATION}/lib") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L${TOOLCHAIN_FILE}/arm-linux-gnueabihf/lib") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L${TOOLCHAIN_FILE}/arm-linux-gnueabihf/libc/lib") set(CMAKE_SHARED_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS}) @@ -56,7 +58,7 @@ set(CMAKE_SHARED_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS}) set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) # Perform compiler test with static library set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) -set(CMAKE_INSTALL_RPATH "$ORIGIN" "$ORIGIN/../lib" "/lib/arm-linux-gnueabihf" "/lib") +set(CMAKE_INSTALL_RPATH "$ORIGIN" "$ORIGIN/../lib" "/lib/arm-linux-gnueabihf" "/lib" "/usr/local/qt5.15/lib") set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) diff --git a/ci/kuiper/copy-deps.sh b/ci/kuiper/copy-deps.sh new file mode 100755 index 0000000000..8d235bc017 --- /dev/null +++ b/ci/kuiper/copy-deps.sh @@ -0,0 +1,43 @@ +#!/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(){ + + if [ ! -z "$(${SRC_DIR}/ci/kuiper/ldd-mod $1 | grep "not found")" ]; then + echo "--- LIB NOT FOUND" + ${SRC_DIR}/ci/kuiper/ldd-mod $1 + exit 1 + fi + + 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/kuiper/create_docker_image.sh b/ci/kuiper/create_docker_image.sh new file mode 100755 index 0000000000..4cf3dc52bd --- /dev/null +++ b/ci/kuiper/create_docker_image.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +set -ex +SRC_DIR=$(git rev-parse --show-toplevel) +source $SRC_DIR/ci/kuiper/kuiper_build_config.sh + +install_packages(){ + sudo apt install docker ... +} + +create_sysroot(){ + $SRC_DIR/ci/kuiper/create_sysroot.sh \ + install_packages \ + download_kuiper \ + install_qemu \ + extract_sysroot \ + configure_sysroot +} + +move_sysroot(){ + sudo mv $SYSROOT $SYSROOT_DOCKER +} + +create_image(){ + pushd ${SRC_DIR}/ci/kuiper/docker + sudo DOCKER_BUILDKIT=0 docker build --tag cristianbindea/scopy2-kuiper . + popd +} + +# install_packages +# create_sysroot +# move_sysroot +create_image diff --git a/ci/kuiper/create_sysroot.sh b/ci/kuiper/create_sysroot.sh index 7bbe4452f1..cb7be3da5b 100755 --- a/ci/kuiper/create_sysroot.sh +++ b/ci/kuiper/create_sysroot.sh @@ -34,14 +34,17 @@ extract_sysroot(){ sudo cp /etc/resolv.conf ${SYSROOT}/etc/resolv.conf sudo umount /mnt/kuiper sudo rm -rf /mnt/kuiper - rm -rf ${STAGING_AREA:?}/${IMAGE_FILE} - rm ${STAGING_AREA}/image*.zip + # rm -rf ${STAGING_AREA:?}/${IMAGE_FILE} + rm -rf ${STAGING_AREA}/image*.zip } configure_sysroot(){ cat << EOF | sudo chroot ${SYSROOT} export DEBIAN_FRONTEND=noninteractive ln -snf /usr/share/zoneinfo/Europe/Bucharest /etc/localtime && echo "Europe/Bucharest" > /etc/timezone +echo "LC_ALL=en_US.UTF-8" | tee -a /etc/environment +echo "LANG=en_US.UTF-8" | tee -a /etc/locale.conf +locale-gen en_US.UTF-8 sed -i 's/#deb-src/deb-src/' /etc/apt/sources.list @@ -73,15 +76,15 @@ rm -rf /usr/lib/arm-linux-gnueabihf/libad9361.so* \ /usr/lib/libad9166.so* \ /usr/lib/pkgconfig/libad9166.pc -apt -y build-dep qt5-qmake libqt5gui5 libqt5webengine-data libqt5webkit5 +apt -y build-dep qtbase5-dev || true apt -y install build-essential gcc g++ gdb-multiarch cmake autoconf automake bison flex git wget pkg-config figlet gawk unzip libsndfile1-dev \ - libudev-dev libinput-dev libts-dev libxcb-xinerama0-dev libxcb-xinerama0 gdbserver \ + libudev-dev libinput-dev libts-dev libxcb-xinerama0-dev libxcb-xinerama0 gdbserver libspeechd-dev perl \ libgl1-mesa-dev libxcb-composite0-dev libxcb-cursor-dev libxcb-damage0-dev libxcb-xv0-dev \ libxcb-dpms0-dev libxcb-dri2-0-dev libxcb-ewmh-dev libxcb-imdkit-dev libxcb-xvmc0-dev \ libxcb-present-dev libxcb-record0-dev libxcb-res0-dev libxcb-xrm-dev libx11-xcb-dev libxcb-glx0-dev libxcb-icccm4 libxcb-icccm4-dev libxcb-xkb-dev libxkbcommon-x11-dev \ libxcb-screensaver0-dev libxcb-util0-dev libxcb-xf86dri0-dev libxcb-xtest0-dev -apt -y install libunwind-dev libsndfile1-dev mesa-utils* mesa-common-dev libglu1-mesa-dev freeglut3-dev mesa-common-dev python libopenal-dev -apt install '^libxcb.*-dev' libx11-xcb-dev libglu1-mesa-dev libxrender-dev libxi-dev libxkbcommon-dev libxkbcommon-x11-dev +apt -y install libunwind-dev libsndfile1-dev mesa-utils* mesa-common-dev libglu1-mesa-dev freeglut3-dev mesa-common-dev python libopenal-dev || true +apt -y install '^libxcb.*-dev' libx11-xcb-dev libglu1-mesa-dev libxrender-dev libxi-dev libxkbcommon-dev libxkbcommon-x11-dev || true wget https://raw.githubusercontent.com/abhiTronix/raspberry-pi-cross-compilers/master/utils/SSymlinker sed -i 's/sudo//g' SSymlinker @@ -94,7 +97,16 @@ chmod +x SSymlinker ./SSymlinker -s /usr/lib/arm-linux-gnueabihf/crt1.o -d /usr/lib/crt1.o ./SSymlinker -s /usr/lib/arm-linux-gnueabihf/crti.o -d /usr/lib/crti.o EOF +} + +move_sysroot(){ + if [ -d $HOME/sysroot ]; then + mkdir -p $STAGING_AREA + sudo mv $HOME/sysroot $SYSROOT + fi +} +fix_relativelinks(){ pushd ${STAGING_AREA} wget $SYSROOT_RELATIVE_LINKS chmod +x sysroot-relativelinks.py diff --git a/ci/kuiper/docker/Dockerfile b/ci/kuiper/docker/Dockerfile new file mode 100644 index 0000000000..8f8ebc3f42 --- /dev/null +++ b/ci/kuiper/docker/Dockerfile @@ -0,0 +1,34 @@ +# docker build -t cristianbindea/scopy-kuiper:latest + + +FROM --platform=linux/amd64 ubuntu:20.04 +SHELL ["/bin/bash", "-c"] + +ARG USER=runner +ENV 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 wget flex bison pkg-config make python3 pip vim + +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 +ENV SYSROOT_LOCATION=/home/${USER}/sysroot +RUN mkdir -p ${SYSROOT_LOCATION} +COPY sysroot/bin ${SYSROOT_LOCATION}/bin +COPY sysroot/lib ${SYSROOT_LOCATION}/lib +COPY sysroot/usr ${SYSROOT_LOCATION}/usr +COPY scopy2 scopy +WORKDIR /home/${USER}/scopy diff --git a/ci/kuiper/kuiper_build_config.sh b/ci/kuiper/kuiper_build_config.sh index dcc49eade6..7b73862b85 100644 --- a/ci/kuiper/kuiper_build_config.sh +++ b/ci/kuiper/kuiper_build_config.sh @@ -36,6 +36,7 @@ RUNTIME_ARMHF=$SRC_DIR/ci/kuiper/runtime-armhf CMAKE_OPTS=(\ -DCMAKE_SYSROOT="$SYSROOT" \ + -DQT_LOCATION="$QT_LOCATION" -DSTAGING_AREA="$STAGING_AREA" \ -DCMAKE_INSTALL_PREFIX="$SYSROOT" \ -DCMAKE_TOOLCHAIN_FILE="$TOOLCHAIN_FILE" \ @@ -45,7 +46,7 @@ CMAKE_OPTS=(\ CMAKE="$CMAKE_BIN ${CMAKE_OPTS[*]}" -QT_BUILD_LOCATION=$SYSROOT/usr/local/qt5.15 +QT_BUILD_LOCATION=$QT_LOCATION QT_SYSTEM_LOCATION=/usr/local/qt5.15 CROSS_COMPILER=$STAGING_AREA/cross-pi-gcc diff --git a/ci/kuiper/kuiper_build_process.sh b/ci/kuiper/kuiper_build_process.sh index 45ea02c1cb..89bd1b9992 100755 --- a/ci/kuiper/kuiper_build_process.sh +++ b/ci/kuiper/kuiper_build_process.sh @@ -278,13 +278,7 @@ create_appdir(){ EMU_BUILD_FOLDER=$STAGING_AREA/iio-emu/build - PLUGINBASE_DLL=$BUILD_FOLDER/pluginbase - CORE_DLL=$BUILD_FOLDER/core - GUI_DLL=$BUILD_FOLDER/gui - GR_UTIL_DLL=$BUILD_FOLDER/gr-util - IIOUTIL_DLL=$BUILD_FOLDER/iioutil - IIOWIDGETS_DLL=$BUILD_FOLDER/iio-widgets - COMMON_DLL=$BUILD_FOLDER/common + SCOPY_DLL=$(find $BUILD_FOLDER -maxdepth 2 -type f -name "libscopy*") PLUGINS=$BUILD_FOLDER/plugins/plugins REGMAP_XMLS=$BUILD_FOLDER/plugins/regmap/xmls @@ -306,15 +300,7 @@ create_appdir(){ cp $EMU_BUILD_FOLDER/iio-emu $APP_DIR/usr/bin cp $BUILD_FOLDER/scopy $APP_DIR/usr/bin - cp $PLUGINBASE_DLL/libscopy-pluginbase.so $APP_DIR/usr/lib - cp $CORE_DLL/libscopy-core.so $APP_DIR/usr/lib - cp $IIOUTIL_DLL/libscopy-iioutil.so $APP_DIR/usr/lib - cp $IIOWIDGETS_DLL/libscopy-iio-widgets.so $APP_DIR/usr/lib - cp $GUI_DLL/libscopy-gui.so $APP_DIR/usr/lib - cp $GUI_DLL/libscopy-gr-gui.so $APP_DIR/usr/lib - cp $GUI_DLL/libscopy-sigrok-gui.so $APP_DIR/usr/lib - cp $GR_UTIL_DLL/libscopy-gr-util.so $APP_DIR/usr/lib - cp $COMMON_DLL/libscopy-common.so $APP_DIR/usr/lib + cp $SCOPY_DLL $APP_DIR/usr/lib cp -r $PLUGINS $APP_DIR/usr/share mkdir $APP_DIR/usr/share/translations @@ -428,6 +414,9 @@ create_appimage(){ chmod a+x $APP_IMAGE } +move_appimage(){ + mv $APP_IMAGE $SRC_DIR/ +} for arg in $@; do $arg diff --git a/ci/kuiper/runtime-armhf b/ci/kuiper/runtime-armhf new file mode 100644 index 0000000000..d094f36552 Binary files /dev/null and b/ci/kuiper/runtime-armhf differ diff --git a/ci/kuiper/scopy.desktop b/ci/kuiper/scopy.desktop new file mode 100644 index 0000000000..705923d28c --- /dev/null +++ b/ci/kuiper/scopy.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Version=1.0 +Icon=scopy +Exec=scopy +Terminal=false +Type=Application +Categories=Science +Name=Scopy +GenericName=Oscilloscope +Comment=A software oscilloscope diff --git a/common/src/scopyconfig.cpp b/common/src/scopyconfig.cpp index bd058a0c66..321e30313a 100644 --- a/common/src/scopyconfig.cpp +++ b/common/src/scopyconfig.cpp @@ -26,8 +26,9 @@ QString scopy::config::localPluginFolderPath() #if defined __APPLE__ return QCoreApplication::applicationDirPath() + "/plugins/plugins"; #endif - - return SCOPY_PLUGIN_BUILD_PATH; + // TODO: a check for ARM + // Quickfix for testing purposes + return QCoreApplication::applicationDirPath() + "/../share/plugins"; } QString scopy::config::defaultTranslationFolderPath() { return SCOPY_TRANSLATION_INSTALL_PATH; } @@ -38,7 +39,9 @@ QString scopy::config::localTranslationFolderPath() return QCoreApplication::applicationDirPath() + "/translations"; #endif - return SCOPY_TRANSLATION_BUILD_PATH; + // TODO: a check for ARM + // Quickfix for testing purposes + return QCoreApplication::applicationDirPath() + "/../share/translations"; } QString scopy::config::preferencesFolderPath() diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 61a83be183..0bfc9ea582 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -34,7 +34,11 @@ endif() option(WITH_PYTHON "Enable Python" ON) if(${WITH_PYTHON}) set(Python_ADDITIONAL_VERSIONS 3) - find_package(Python3 REQUIRED COMPONENTS Interpreter Development) + if(CMAKE_SYSTEM_PROCESSOR MATCHES arm) + find_package(Python3 REQUIRED COMPONENTS Interpreter) + else() + find_package(Python3 REQUIRED COMPONENTS Interpreter Development) + endif() set(PYTHON_VERSION python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}) set(PYTHON_VERSION ${PYTHON_VERSION} PARENT_SCOPE) if(NOT Python3_FOUND) diff --git a/core/src/scopymainwindow.cpp b/core/src/scopymainwindow.cpp index 6404832a38..5d31b807c2 100644 --- a/core/src/scopymainwindow.cpp +++ b/core/src/scopymainwindow.cpp @@ -386,7 +386,9 @@ void ScopyMainWindow::loadDecoders() #if defined __APPLE__ QString path = QCoreApplication::applicationDirPath() + "/decoders"; #else - QString path = "decoders"; + // TODO: a check for ARM + // Quickfix for testing purposes + QString path = QCoreApplication::applicationDirPath() + "/../lib/decoders"; #endif bool success = true; diff --git a/gui/res/scopy.png b/gui/res/scopy.png new file mode 100644 index 0000000000..e1fdb0e4e8 Binary files /dev/null and b/gui/res/scopy.png differ