Skip to content

Commit

Permalink
ci/ubuntu: refactor files
Browse files Browse the repository at this point in the history
Signed-off-by: Adrian Stanea <[email protected]>
  • Loading branch information
Adrian-Stanea committed Oct 17, 2024
1 parent 374192a commit 4fdeea1
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 44 deletions.
122 changes: 87 additions & 35 deletions CI/ubuntu/install_deps
Original file line number Diff line number Diff line change
@@ -1,58 +1,110 @@
#!/bin/sh -e
#!/bin/bash -e

TOP_DIR=$(pwd)
WORKDIR=$(pwd)

set -x
set -ex

install_deps() {
echo "# INSTALLING DEPENDENCIES"
echo "# Installing dependencies"

# Update package lists
sudo apt-get -qq update
echo "libm2k packages"
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y cmake doxygen graphviz \
libaio-dev libavahi-client-dev libavahi-common-dev libusb-1.0-0-dev \
libxml2-dev rpm tar bzip2 gzip flex bison git curl \
python3-dev python3-setuptools python3-pip python3-all \
debhelper devscripts fakeroot libserialport-dev swig dh-python \
libunwind-dev libunwind8

# libiio dependencies
echo "libiio packages"
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y \
libxml2-dev bison flex libcdk5-dev cmake \
libaio-dev libusb-1.0-0-dev \
libserialport-dev libavahi-client-dev man2html \

install_packages() {
local packages=("$@")
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y "${packages[@]}"
}

libm2k_packages=(
bison
bzip2
cmake
curl
debhelper
devscripts
dh-python
doxygen
fakeroot
flex
git
graphviz
gzip
libaio-dev
libavahi-client-dev
libavahi-common-dev
libserialport-dev
libunwind-dev
libunwind8
libusb-1.0-0-dev
libxml2-dev
python3-all
python3-dev
python3-pip
python3-setuptools
rpm
swig
tar
)

libiio_packages=(
bison
cmake
flex
libaio-dev
libavahi-client-dev
libcdk5-dev
libserialport-dev
libusb-1.0-0-dev
libxml2-dev
man2html
python3-sphinx
}
)

echo "## Installing libm2k dependencies"
install_packages "${libm2k_packages[@]}"

install_glog() {
echo "## Building glog"
echo "## Installing libiio dependencies"
install_packages "${libiio_packages[@]}"
}

cd ${TOP_DIR}
git clone --branch v0.4.0 --depth 1 https://github.com/google/glog
mkdir -p glog/build_0_4_0 && cd glog/build_0_4_0
cmake -DCMAKE_PREFIX_PATH=/usr ..
build_glog() {
echo "### Building glog - version $GLOG_VERSION"
git clone https://github.com/google/glog --branch "$GLOG_VERSION" --depth 1 "${WORKDIR}"/glog

cd "${WORKDIR}"/glog
mkdir -p build_"${GLOG_VERSION}" && cd build_"${GLOG_VERSION}"
cmake "${WORKDIR}"/glog \
-DCMAKE_PREFIX_PATH=/usr
make
sudo make install
sudo pip3 install --upgrade pip stdeb argparse
}

install_libiio() {
echo "## Building libiio - version $LIBIIO_VERSION"
build_libiio() {
echo "### Building libiio - version $LIBIIO_VERSION"
git clone https://github.com/analogdevicesinc/libiio.git --branch $LIBIIO_VERSION "${WORKDIR}"/libiio

cd ${TOP_DIR}
git clone https://github.com/analogdevicesinc/libiio.git -b $LIBIIO_VERSION libiio
mkdir ./libiio/build && cd ./libiio/build
cmake .. -Werror=dev -DCOMPILE_WARNING_AS_ERROR=ON -DENABLE_PACKAGING=ON -DPYTHON_BINDINGS=ON -DWITH_DOC=ON -DWITH_SERIAL_BACKEND=ON -DWITH_MAN=ON -DCPACK_SYSTEM_NAME=${ARTIFACTNAME}
cd "${WORKDIR}"/libiio
mkdir -p build && cd build
cmake "${WORKDIR}"/libiio \
-Werror=dev \
-DCOMPILE_WARNING_AS_ERROR=ON \
-DCPACK_SYSTEM_NAME=${ARTIFACTNAME} \
-DENABLE_PACKAGING=ON \
-DPYTHON_BINDINGS=ON \
-DPYTHON_EXECUTABLE:FILEPATH=$(python -c "import os, sys; print(os.path.dirname(sys.executable) + '/python')") \
-DWITH_DOC=ON \
-DWITH_MAN=ON \
-DWITH_SERIAL_BACKEND=ON
make
make package
sudo apt install ./libiio-*.deb
}

handle_default() {
install_deps
install_glog
install_libiio
build_glog
build_libiio
}

handle_ubuntu_docker() {
Expand All @@ -74,14 +126,14 @@ handle_doxygen() {
cd ..
cd ..

cd ${TOP_DIR}/doc
cd ${WORKDIR}/doc
mkdir -p build && cd build
cmake ..
cd ..
cd ..

handle_default
cd ${TOP_DIR}
cd ${WORKDIR}
#Also install Sphinx for Python bindings
sudo apt-get install python3-sphinx
sudo pip3 install --upgrade sphinx_rtd_theme
Expand Down
36 changes: 27 additions & 9 deletions CI/ubuntu/make_linux
Original file line number Diff line number Diff line change
@@ -1,34 +1,52 @@
#!/bin/sh -e

TOP_DIR=$(pwd)
WORKDIR=$(pwd)

set -x
set -ex

handle_default() {
mkdir -p build
cd build

#create deb for bindings
cmake -DENABLE_PYTHON=ON -DENABLE_TOOLS=ON -DENABLE_CSHARP=OFF -DENABLE_LOG=ON -DBUILD_EXAMPLES=ON .. && make
echo "Creating .deb for bindings"
cmake "$WORKDIR" \
-DBUILD_EXAMPLES=ON \
-DENABLE_CSHARP=OFF \
-DENABLE_LOG=ON \
-DENABLE_PYTHON=ON \
-DENABLE_TOOLS=ON \
-DPYTHON_EXECUTABLE:FILEPATH=$(python -c "import os, sys; print(os.path.dirname(sys.executable) + '/python')") \
make
sudo python3 setup.py --command-packages=stdeb.command sdist_dsc
cd "$(find . -type d -name "debian" | head -n 1)"
sudo env DEB_BUILD_OPTIONS=nocheck debuild -us -uc
cp ../../*.deb ${TOP_DIR}/build/
cd ${TOP_DIR}/build/
cp ../../*.deb ${WORKDIR}/build/
cd ${WORKDIR}/build/
#remove the tar.gz for bindings
sudo rm *.tar.gz
ls

#create simple .deb without Python bindings
cmake -DENABLE_PACKAGING=ON -DDEB_DETECT_DEPENDENCIES=ON -DENABLE_PYTHON=OFF -DENABLE_CSHARP=ON -DENABLE_TOOLS=ON -DENABLE_LOG=ON -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_EXAMPLES=ON ..
echo "Create .deb without Python bingings"
cmake "$WORKDIR" \
-DBUILD_EXAMPLES=ON \
-DCMAKE_INSTALL_PREFIX=/usr \
-DDEB_DETECT_DEPENDENCIES=ON \
-DENABLE_CSHARP=ON -DENABLE_TOOLS=ON \
-DENABLE_LOG=ON \
-DENABLE_PACKAGING=ON \
-DENABLE_PYTHON=OFF \
-DPYTHON_EXECUTABLE:FILEPATH=$(python -c "import os, sys; print(os.path.dirname(sys.executable) + '/python')") \
make && make package
ls
}

handle_doxygen() {
mkdir -p build
cd build
cmake -DENABLE_PYTHON=ON -DENABLE_CSHARP=OFF -DENABLE_DOC=ON ..
cmake "$WORKDIR" \
-DENABLE_PYTHON=ON \
-DENABLE_CSHARP=OFF \
-DENABLE_DOC=ON
make && sudo make install
make doc
cd ..
Expand Down

0 comments on commit 4fdeea1

Please sign in to comment.