Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scopy2 AppImage for armhf and x86_64 #1650

Merged
merged 4 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Kuiper Scopy Build
name: Scopy armhf AppImage Build

on: [push, pull_request]

Expand All @@ -8,7 +8,7 @@ env:

jobs:

build_scopy_for_kuiper:
build_scopy_armhf_appimage:
runs-on: ubuntu-20.04

steps:
Expand All @@ -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
Expand Down
45 changes: 45 additions & 0 deletions .github/workflows/appimage-x86_64.yml
Original file line number Diff line number Diff line change
@@ -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
11 changes: 8 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 16 additions & 0 deletions ci/armhf/AppRun
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
Expand Down
129 changes: 91 additions & 38 deletions ci/kuiper/kuiper_build_process.sh → ci/armhf/armhf_build_process.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
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 All @@ -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
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
Loading
Loading