diff --git a/CI/ubuntu/install_deps b/CI/ubuntu/install_deps index e52d602c..e4d8ec1f 100755 --- a/CI/ubuntu/install_deps +++ b/CI/ubuntu/install_deps @@ -1,49 +1,101 @@ -#!/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 @@ -51,8 +103,8 @@ install_libiio() { handle_default() { install_deps - install_glog - install_libiio + build_glog + build_libiio } handle_ubuntu_docker() { @@ -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 diff --git a/CI/ubuntu/make_linux b/CI/ubuntu/make_linux index f5daf76e..f50615f9 100755 --- a/CI/ubuntu/make_linux +++ b/CI/ubuntu/make_linux @@ -1,26 +1,41 @@ #!/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 } @@ -28,7 +43,10 @@ handle_default() { 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 ..