Skip to content

Commit

Permalink
ci/kuiper: improve script usability for local execution outside CI runs
Browse files Browse the repository at this point in the history
 - added helper functions
 - the ability to run the scripts from anywhere
 - a way to easily generate artifacts locally

Signed-off-by: Bindea Cristian <[email protected]>
  • Loading branch information
bindea-cristian committed Jun 10, 2024
1 parent e9cf5b3 commit 7f4ada1
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/kuiperbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
/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/kuiper/kuiper_build_process.sh run_workflow
'
- name: Set short git commit SHA
shell: bash
Expand Down
3 changes: 2 additions & 1 deletion CI/kuiper/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
3 changes: 2 additions & 1 deletion CI/kuiper/copy-deps.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/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/kuiper/kuiper_build_config.sh

BINARY=$1
Expand Down
3 changes: 2 additions & 1 deletion CI/kuiper/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/kuiper/kuiper_build_config.sh

# install docker
Expand Down
3 changes: 2 additions & 1 deletion CI/kuiper/create_sysroot.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

IMAGE_FILE=2023-12-13-ADI-Kuiper-full.img
Expand Down
98 changes: 79 additions & 19 deletions CI/kuiper/kuiper_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/kuiper/kuiper_build_config.sh

echo -- USING CMAKE COMMAND:
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 @@ -262,20 +267,6 @@ build_scopy() {
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 @@ -330,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
}

#
# 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-kuiper:latest
docker run -it \
--mount type=bind,source="$SRC_DIR",target=/home/runner/scopy \
cristianbindea/scopy1-kuiper:latest
# now this repository folder it shared with the docker container

# to compile the application use "scopy/CI/kuiper/kuiper_build_process.sh get_tools generate_appimage"
# after the first compilation just use "scopy/CI/kuiper/kuiper_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-kuiper:latest"

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


for arg in $@; do
$arg
done

0 comments on commit 7f4ada1

Please sign in to comment.