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

Scopy1 Appimage #1619

Merged
merged 11 commits into from
Jun 12, 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 Scopy1 Build
name: Scopy1 armhf Build

on: [push, pull_request]

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

jobs:

build_scopy1_for_kuiper:
build_scopy1_armhf:
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/scopy1-kuiper:latest
run: docker pull cristianbindea/scopy1-armhf-appimage:latest

- name: Create Scopy AppImage
- name: Create Scopy armhf 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/kuiper/gh-actions.envs \
cristianbindea/scopy1-kuiper:latest \
--env-file $GITHUB_WORKSPACE/CI/armhf/gh-actions.envs \
cristianbindea/scopy1-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_iio-emu build_scopy create_appdir create_appimage move_appimage
./CI/armhf/armhf_build_process.sh run_workflow
'
- 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: Scopy1 x86_64 AppImage Build

on: [push, pull_request]

env:
BUILD_HOST: ubuntu-20.04
USERNAME: github-actions

jobs:

build_scopy1_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/scopy1-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/scopy1-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 download_tools build_iio-emu 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"

- uses: actions/upload-artifact@v4
with:
name: scopy-linux-x86_64-${{ env.commit_sha }}
path: ${{ github.workspace }}/Scopy1-x86_64.AppImage
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ android*.sh
*.apk
*.aab
!CI/android/*
CI/kuiper/staging
CI/kuiper/scopy.AppDir
CI/armhf/staging
CI/armhf/scopy.AppDir
CI/armhf/scopy.squashfs
CI/x86_64/staging
CI/x86_64/scopy.AppDir
html/
build_arm64-v8a/
1 change: 1 addition & 0 deletions CI/appveyor/gen_ci_envs.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash

echo CI_SCRIPT=${CI_SCRIPT}
echo GITHUB_WORKSPACE=$GITHUB_WORKSPACE
echo REPO_URL=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}
echo BUILD_HOST=${BUILD_HOST}
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,30 @@ QWT_BRANCH=qwt-multiaxes-updated
LIBTINYIIOD_BRANCH=master
IIOEMU_BRANCH=master

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
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/Scopy1-armhf.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/Scopy1-armhf.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
130 changes: 90 additions & 40 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 @@ -59,7 +60,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 Down Expand Up @@ -245,8 +246,12 @@ build_iio-emu(){
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
sudo make install
if [ -d 'build' ];then
echo "### IIO-EMU already built --- skipping"
else
build_with_cmake
sudo make install
fi
popd
popd
}
Expand All @@ -255,31 +260,18 @@ build_scopy() {
echo "### Building scopy"
pushd $SRC_DIR
CURRENT_BUILD_CMAKE_OPTS="\
-DCLONE_IIO_EMU=OFF
-DCLONE_IIO_EMU=OFF \
-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
EMU_BUILD_FOLDER=$STAGING_AREA/iio-emu/build
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 All @@ -300,35 +292,24 @@ create_appdir(){
$COPY_DEPS $APP_DIR/usr/bin/scopy $APP_DIR/usr/lib
$COPY_DEPS $APP_DIR/usr/bin/iio-emu $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(){
rm -rf $APP_IMAGE
mksquashfs $APP_DIR $APP_SQUASHFS -root-owned -noappend
Expand All @@ -340,18 +321,87 @@ 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
move_appimage(){
mv $APP_IMAGE $SRC_DIR/Scopy1-armhf.AppImage
[ -d $APP_IMAGE ] && mv $APP_IMAGE $SRC_DIR/Scopy1-armhf.AppImage || echo "Appimage not found"
}

generate_ci_envs(){
$SRC_DIR/CI/appveyor/gen_ci_envs.sh > $SRC_DIR/CI/kuiper/gh-actions.envs
$SRC_DIR/CI/appveyor/gen_ci_envs.sh > $SRC_DIR/CI/armhf/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/scopy1-armhf-appimage:latest
docker run -it \
--mount type=bind,source="$SRC_DIR",target=/home/runner/scopy \
cristianbindea/scopy1-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/scopy1-armhf-appimage:latest"

# to get the container id use "docker container ls -a"
}


for arg in $@; do
$arg
done
Loading
Loading