Skip to content

Commit

Permalink
ci/armhf: same changes as in commits from main
Browse files Browse the repository at this point in the history
 - 1882b7e (ci/kuiper: implement excludelist list for what libraries to be bundled in the appimage, 2024-06-06)
 - 7f4ada1 (ci/kuiper: improve script usability for local execution outside CI runs  - added helper functions  - the ability to run the scripts from anywhere  - a way to easily generate artifacts locally, 2024-06-10)
 - 3eafb97 (ci/kuiper: added a way to differentiate between the Python Interpreter used by the Host and the one used by the Targer        - also make sure the Python found by cmake is the same version as the one bundled in the Appimage, 2024-06-03)
 - e001609 (ci/kuiper: set the QT_QPA_PLATFORM to xcb  - without this the app wouldn't start on RaspbianOS, 2024-06-10)
 - e9cf5b3 (ci/kuiper: change opengl from es2 to desktop, 2024-06-06)

Signed-off-by: Bindea Cristian <cristian.bindea@analog.com>
  • Loading branch information
bindea-cristian committed Jun 17, 2024
1 parent 62c38b6 commit 22b5ef7
Show file tree
Hide file tree
Showing 11 changed files with 142 additions and 59 deletions.
8 changes: 7 additions & 1 deletion ci/armhf/AppRun
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ 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

exec $HERE/usr/bin/scopy
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
6 changes: 6 additions & 0 deletions ci/armhf/armhf_build_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ QWT_BRANCH=qwt-multiaxes-updated
LIBTINYIIOD_BRANCH=master
IIOEMU_BRANCH=main

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
Expand Down
125 changes: 89 additions & 36 deletions ci/armhf/armhf_build_process.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

set -ex
git config --global --add safe.directory $HOME/scopy
SRC_DIR=$(git rev-parse --show-toplevel)
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:
Expand Down Expand Up @@ -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
}
Expand All @@ -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
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(){
Expand All @@ -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
Expand All @@ -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
5 changes: 3 additions & 2 deletions ci/armhf/build_qt.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/bin/bash

set -ex
SRC_DIR=$(git rev-parse --show-toplevel)
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/kuiper/kuiper_build_config.sh

install_packages(){
Expand Down Expand Up @@ -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 \
Expand Down
25 changes: 14 additions & 11 deletions ci/armhf/copy-deps.sh
Original file line number Diff line number Diff line change
@@ -1,32 +1,35 @@
#!/bin/bash

set -e
SRC_DIR=$(git rev-parse --show-toplevel)
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"
LIBS_ARRAY=()
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
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}"
# 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
run_ldd "${library}"
fi
done
}
Expand Down
3 changes: 2 additions & 1 deletion ci/armhf/create_docker_image.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/bin/bash

set -ex
SRC_DIR=$(git rev-parse --show-toplevel)
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
Expand Down
5 changes: 3 additions & 2 deletions ci/armhf/create_sysroot.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#!/bin/bash

set -ex
SRC_DIR=$(git rev-parse --show-toplevel)
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(){
Expand Down
4 changes: 2 additions & 2 deletions common/src/scopyconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
16 changes: 14 additions & 2 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion core/src/scopymainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,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";
Expand Down
2 changes: 1 addition & 1 deletion plugins/regmap/src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 22b5ef7

Please sign in to comment.