diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 243f3ddab..000000000 --- a/.travis.yml +++ /dev/null @@ -1,171 +0,0 @@ -language: c -sudo: required -python: "3.6" - -env: - global: - - EXTRA_SSH=-oHostKeyAlgorithms=+ssh-dss - # SSHHOST - - secure: "NEXUEA+ccm/I21ujCPuKYIHFb8Gogunr3nYysCRpTBNT40PsU9VFIy5vbmMxPAkCaMwk8XZ0rMHE3uaNGbBAGfoDL9v0Ban5wG/jA1JkmOAWUpFrUsbQeejXNRA04QcZ/4VeL6TgFegV2T6V0tLB4M6/X316dIPhS9Tat1ZUC8s=" - # SSHUSER - - secure: "bYHqhcYYuSbciQa5mBqMxs3CbJkrxxD7/G4zDW2war1IcMh8AC/KPeoYIuhd/L2Mg9+tP++xCznKUJzX85Hu+8EyrMGkC/6zWpGYgyO27DH7wl+9AJjR191WJKkg+S6OqZmb/5v0rdJMDnGOZHrRVB3Vec9dBT+jDTQbyxrckxE=" - # DEPLOY_TO directory - - secure: "PMp93w9HAYd0pR4aw2LT1sMIVmA06f01Xq2jaGW2iy74n3GrqBYe7H9aMR0WD1S6KH9sFydqFI11bCpwUQXPopl+8MPA34AS7V2gaxDUdE+UZnKKXpKV6KRPRp/txlryuEGspjFJM0bo5g1H5lPBSBFj8PB1Bf6BiloGl8TTuiY=" - -services: - - docker - -matrix: - include: - - stage: "Build & Deploy" - - compiler: "gcc" - dist: xenial - env: - - ARCH=arm - - OS_VERSION=jessie - - compiler: "gcc" - dist: xenial - env: - - ARCH=arm - - OS_VERSION=stretch - - compiler: "gcc" - os: linux - env: - - PLATFORM=linux BITS=64 HOST=x86_64 - # TODO do `check` or `check_hw` here too, not just `check_sw` (as part of `coverage`) - - CHECK_RULE=coverage GCOV=1 - - PKG_RULE=gzip - - PYPI=yes - - COVERITY_SCAN_PROJECT_NAME="$TRAVIS_REPO_SLUG" - - COVERITY_SCAN_BRANCH_PATTERN="master" - - COVERITY_SCAN_NOTIFICATION_EMAIL="robin.getz@analog.com" - - COVERITY_SCAN_BUILD_COMMAND_PREPEND="mkdir build && cd build && cmake -DWITH_EXAMPLES=ON .." - - COVERITY_SCAN_BUILD_COMMAND="make" - # The COVERITY_SCAN_TOKEN - - secure: "QQt2l9IVo0xXWLx7Xqgz/4Iezj7YroY3MKfmG+OhtzkMRx4prhx32/07JMNAcYx6mQrccyZkBNzpYuXlfIZjFL3xDxDj5+iKv5XXpJbRFQGhc5xZtAlzOIqHNMcFc0Aj8J2mZwKfSaDnBdf+nMgKcmn46pYbpJOmPe9iEfeLvvg=" - - compiler: "clang" - os: linux - env: LDIST=DO_NOT_DEPLOY - - compiler: "gcc" - os: linux - dist: xenial - env: - # GH_DOC_TOKEN used to deploy docs - - secure: "OrwnYeUITY2R7pn11WHqsO7c6F9fRY7G5fOh98GGXnw7dAIoSvUhjUE70ehaBzLH0CyO83KgaiyACP8eqRx9BYUd1McrqTFDmYJNVR+Wk01SSjJxaXzU4RMsJPhXH9l5U7BEH5dVk/IFLLaCwYnc35mlADHE2KCGNanvtnRU0gU=" - - os: linux - env: - - OS_TYPE=centos_docker - - OS_VERSION=6 - - os: linux - env: - - OS_TYPE=centos_docker - - OS_VERSION=7 - - os: linux - dist: bionic - - os: linux - env: - - OS_TYPE=centos_docker - - OS_VERSION=8 - - os: linux - env: - - OS_TYPE=ubuntu_docker - - OS_VERSION=focal - - compiler: "gcc" - os: osx - osx_image: xcode10.1 - - compiler: "gcc" - os: osx - osx_image: xcode11 - - compiler: "gcc" - os: osx - osx_image: xcode12 - - - stage: "Trigger Next In Pipeline" - env: - - TRIGGER_NEXT_BUILD=true - -addons: - ssh_known_hosts: - secure: "q0dQ9MrhnOCo031McxSdQIqw4N6tEyAZLq7mdbWkAJcXOh/CX58NjFvcdSfamleDUYRmg7KpCZPPgnbx2JtqVvWJv8aNnr67CE1GIjRP1Fxh2WaKS+VK+I6rro7GwCO2C9d+uffCt63LfZKqddF1T7vMI2IgHcu9irc5LCuw6Wo=" - -before_install: - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then - if [[ "$ARCH" == "arm" ]] ; then - ./CI/travis/setup_qemu_for_arm.sh ${OS_VERSION} ; - else - ./CI/travis/before_install_linux "$OS_TYPE" ; - fi - fi - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./CI/travis/before_install_darwin ; fi - - if [[ -n "$COVERITY_SCAN_PROJECT_NAME" ]] ; then echo -n | openssl s_client -connect scan.coverity.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca- ; fi - - if [ -n "$COVERITY_SCAN_PROJECT_NAME" -a "$TRAVIS_EVENT_TYPE" == "cron" ] ; then curl -s 'https://scan.coverity.com/scripts/travisci_build_coverity_scan.sh' | bash || true ; fi - - - mkdir -p $TRAVIS_BUILD_DIR/build - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then mkdir -p $TRAVIS_BUILD_DIR/build_tar ; fi - -script: - - if [[ "$ARCH" == "arm" && "$TRAVIS_OS_NAME" == "linux" ]]; then ${TRAVIS_BUILD_DIR}/CI/travis/make_linux_qemu ; fi - - if [[ -z "$ARCH" && "$TRAVIS_OS_NAME" == "linux" ]]; then ${TRAVIS_BUILD_DIR}/CI/travis/make_linux libiio "$OS_TYPE" ; fi - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ${TRAVIS_BUILD_DIR}/CI/travis/make_darwin; fi - - if [[ "$TRIGGER_NEXT_BUILD" == "true" ]]; then ${TRAVIS_BUILD_DIR}/CI/travis/after_deploy; fi - -notifications: - email: - on_success: change - on_failure: always - -before_deploy: - - . ${TRAVIS_BUILD_DIR}/CI/travis/before_deploy - - openssl aes-256-cbc -K $encrypted_48a720578612_key -iv $encrypted_48a720578612_iv -in ${TRAVIS_BUILD_DIR}/CI/travis/deploy.rsa.enc -out /tmp/deploy.rsa -d - - eval "$(ssh-agent -s)" - - chmod 600 /tmp/deploy.rsa - - ssh-add /tmp/deploy.rsa - - if [[ "$PYPI" == "yes" ]]; then cd "build/bindings/python"; fi -deploy: - - provider: releases - api_key: - secure: Bl7sfWp796+D7cF99+YdmbQjr5stXh4H/4hN2L5FNL0FEHL4XnIscSqySgy2NNmcqWF4Mz5WNXMZ9M8rYSNAiOndcaBYB+xvesAUbIdncwswgTNn2cj6yQbv0yR9qVUdoyczvZMK1vIc6GtKWWkh0AmgR04cAFffU3fr+78JHIw= - file: - - "${RELEASE_PKG_FILE_DEB}" - - "${RELEASE_PKG_FILE_RPM}" - - "${RELEASE_PKG_FILE_TGZ}" - skip_cleanup: true - on: - repo: analogdevicesinc/libiio - tags: true - condition: "($CC = gcc) && ($TRAVIS_OS_NAME = linux)" - - provider: releases - api_key: - secure: Bl7sfWp796+D7cF99+YdmbQjr5stXh4H/4hN2L5FNL0FEHL4XnIscSqySgy2NNmcqWF4Mz5WNXMZ9M8rYSNAiOndcaBYB+xvesAUbIdncwswgTNn2cj6yQbv0yR9qVUdoyczvZMK1vIc6GtKWWkh0AmgR04cAFffU3fr+78JHIw= - file: - - "${RELEASE_PKG_FILE_PKG}" - - "${RELEASE_PKG_FILE_TGZ}" - skip_cleanup: true - on: - repo: analogdevicesinc/libiio - tags: true - condition: "$TRAVIS_OS_NAME = osx" - - provider: script - skip_cleanup: true - script: - - ${TRAVIS_BUILD_DIR}/CI/travis/deploy - on: - condition: "($CC = gcc) && ($TRAVIS_OS_NAME = linux)" - all_branches: true - - provider: script - skip_cleanup: true - script: - - ${TRAVIS_BUILD_DIR}/CI/travis/deploy - on: - condition: "$TRAVIS_OS_NAME = osx" - all_branches: true - - provider: pypi - skip_cleanup: true - on: - tags: true - condition: "$PYPI = yes" - username: __token__ - password: - secure: KfORvnPyLlMANLpcwJjcO44Kt6meP614omJk2GloD+B51SuV64O6N31VDOTi2xqioEk9Cajq7tmNte5YoHVUjL9iWFsBblpzxZoXcy40dn4pFN0kMiE8scszxckbDwuBZhokUVZ2fhfLKf/8xORcwjS3vKqSj5HwQKKvVgukSbQ= - distributions: sdist diff --git a/CI/azure/ci-ubuntu.sh b/CI/azure/ci-ubuntu.sh new file mode 100644 index 000000000..5c322263d --- /dev/null +++ b/CI/azure/ci-ubuntu.sh @@ -0,0 +1,12 @@ +#!/bin/bash +set -x +uname -a +DEBIAN_FRONTEND=noninteractive apt update +DEBIAN_FRONTEND=noninteractive apt -y upgrade +DEBIAN_FRONTEND=noninteractive apt install -y bison flex cmake git build-essential libxml2-dev doxygen +DEBIAN_FRONTEND=noninteractive apt install -y python3 python3-sphinx python3-setuptools +echo "$PWD" +mkdir build && cd build +cmake .. -DPYTHON_BINDINGS=ON -DENABLE_PACKAGING=ON -DCPACK_SYSTEM_NAME="{ARTIFACTNAME}" +make +make package diff --git a/CI/travis/generateDocumentationAndDeploy.sh.in b/CI/azure/generateDocumentationAndDeploy.sh.in similarity index 100% rename from CI/travis/generateDocumentationAndDeploy.sh.in rename to CI/azure/generateDocumentationAndDeploy.sh.in diff --git a/CI/azure/prepare_assets.sh b/CI/azure/prepare_assets.sh new file mode 100755 index 000000000..c96c0be7b --- /dev/null +++ b/CI/azure/prepare_assets.sh @@ -0,0 +1,100 @@ +#!/bin/bash -e + +release_artifacts() { + local deb_linux_assets='Fedora-34 Ubuntu-18.04 Ubuntu-20.04' + cd "${BUILD_ARTIFACTSTAGINGDIRECTORY}" + for i in $deb_linux_assets; do + cd "Linux-${i}" + if [ "${i}" == "Fedora-34" ]; then + find . -name '*.rpm' -exec mv {} ../ ";" + fi + find . -name '*.deb' -exec mv {} ../ ";" + cd ../ + rm -r "Linux-${i}" + done + + local pkg_assets='macOS-10.15 macOS-11' + cd "${BUILD_ARTIFACTSTAGINGDIRECTORY}" + for i in $pkg_assets; do + cd "${i}" + + # change artifact name + old_name=$(find . -name '*.pkg' | cut -b 3-26) + name=$(echo "${old_name}" | cut -b 1-20) + new_name="${name}-${i}.pkg" + mv ./"${old_name}" ./"${new_name}" + + find . -name '*.pkg' -exec mv {} ../ ";" + find . -name '*.tar.gz' -exec mv {} ../ ";" + cd ../ + rm -r "${i}" + done + + local zip_assets='2019 2022' + cd "${BUILD_ARTIFACTSTAGINGDIRECTORY}" + for i in $zip_assets; do + zip -r "Windows-VS-${i}-x64".zip "Windows-VS-${i}-x64" + rm -r "Windows-VS-${i}-x64" + done + + local deb_arm_assets='arm32v7 arm64v8 ppc64le x390x' + cd "${BUILD_ARTIFACTSTAGINGDIRECTORY}" + for i in $deb_arm_assets; do + cd "Ubuntu-${i}" + find . -name '*.deb' -exec mv {} ../ ";" + cd ../ + rm -r "Ubuntu-${i}" + done + +} + +swdownloads_artifacts() { + local linux_dist='Fedora-34 Ubuntu-18.04 Ubuntu-20.04' + for distribution in $linux_dist; do + cd "${BUILD_ARTIFACTSTAGINGDIRECTORY}/Linux-${distribution}" + if [ "${distribution}" == "Fedora-34" ]; then + find . -name '*.rpm' -exec mv {} ../"${distribution}_latest_master_libiio.rpm" ";" + fi + find . -name '*.tar.gz' -exec mv {} ../"${distribution}_latest_master_libiio.tar.gz" ";" + find . -name '*.deb' -exec mv {} ../"${distribution}_latest_master_libiio.deb" ";" + rm -r ../Linux-"${distribution}" + done + + local macOS_dist='macOS-10.15 macOS-11' + for distribution in $macOS_dist; do + cd "${BUILD_ARTIFACTSTAGINGDIRECTORY}/${distribution}" + find . -name '*.pkg' -exec mv {} ../"${distribution}_latest_master_libiio.pkg" ";" + find . -name '*.tar.gz' -exec mv {} ../"${distribution}_latest_master_libiio.tar.gz" ";" + rm -r ../"${distribution}" + done + + local windows_dist='2019 2022' + for distribution in $windows_dist; do + cd "${BUILD_ARTIFACTSTAGINGDIRECTORY}" + zip -r "Windows-VS-${distribution}-x64-latest_master_libiio".zip "Windows-VS-${distribution}-x64" + rm -r "Windows-VS-${distribution}-x64" + done + + local arm_dist='arm32v7 arm64v8 ppc64le x390x' + for distribution in $arm_dist; do + cd "${BUILD_ARTIFACTSTAGINGDIRECTORY}/Ubuntu-${distribution}" + find . -name '*.tar.gz' -exec mv {} ../"Ubuntu-${distribution}_latest_master_libiio.tar.gz" ";" + find . -name '*.deb' -exec mv {} ../"Ubuntu-${distribution}_latest_master_libiio.deb" ";" + rm -r ../Ubuntu-"${distribution}" + done + + cd "${BUILD_ARTIFACTSTAGINGDIRECTORY}/Libiio-Setup-Exe" + mv libiio-setup.exe ../libiio-setup.exe + rm -r ../Libiio-Setup-Exe +} + +check_artifacts() { + cd build + while IFS= read -r line; do + if [ -z "${line}" ]; then continue + fi + test -f ./artifacts/"${line}" && echo "${line} exist." || echo "${line} does not exist." + done < "artifact_manifest.txt" +} + +"${1}"_artifacts diff --git a/CI/travis/zip.txt b/CI/azure/zip.txt similarity index 100% rename from CI/travis/zip.txt rename to CI/azure/zip.txt diff --git a/CI/build_win.ps1 b/CI/build_win.ps1 index 08048e226..97f7d1e1e 100644 --- a/CI/build_win.ps1 +++ b/CI/build_win.ps1 @@ -1,37 +1,24 @@ +# https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_preference_variables?view=powershell-7.2#erroractionpreference +$ErrorActionPreference = "Stop" +$ErrorView = "NormalView" $COMPILER=$Env:COMPILER -$ARCH=$Env:ARCH - $src_dir=$pwd -if ($ARCH -eq "Win32") { - echo "Running cmake for $COMPILER on 32 bit..." - mkdir build-win32 - cp .\libiio.iss.cmakein .\build-win32 - cd build-win32 - - cmake -G "$COMPILER" -A "$ARCH" -DCMAKE_SYSTEM_PREFIX_PATH="C:" -DENABLE_IPV6=OFF -DWITH_USB_BACKEND=ON -DWITH_SERIAL_BACKEND=ON -DPYTHON_BINDINGS=ON -DCSHARP_BINDINGS:BOOL=ON -DLIBXML2_LIBRARIES="C:\\libs\\32\\libxml2.lib" -DLIBUSB_LIBRARIES="C:\\libs\\32\\libusb-1.0.lib" -DLIBSERIALPORT_LIBRARIES="C:\\libs\\32\\libserialport.dll.a" -DLIBUSB_INCLUDE_DIR="C:\\include\\libusb-1.0" -DLIBXML2_INCLUDE_DIR="C:\\include\\libxml2" .. - cmake --build . --config Release - cp .\libiio.iss $env:BUILD_ARTIFACTSTAGINGDIRECTORY - - cd ../bindings/python - python.exe setup.py.cmakein sdist - Get-ChildItem dist\pylibiio-*.tar.gz | Rename-Item -NewName "libiio-py39-win32.tar.gz" - mv .\dist\*.gz . - rm .\dist\*.gz -}else { - echo "Running cmake for $COMPILER on 64 bit..." - mkdir build-x64 - cp .\libiio.iss.cmakein .\build-x64 - cd build-x64 +echo "Running cmake for $COMPILER on 64 bit..." +mkdir build-x64 +cp .\libiio.iss.cmakein .\build-x64 +cd build-x64 - cmake -G "$COMPILER" -A "$ARCH" -DCMAKE_SYSTEM_PREFIX_PATH="C:" -DENABLE_IPV6=OFF -DWITH_USB_BACKEND=ON -DWITH_SERIAL_BACKEND=ON -DPYTHON_BINDINGS=ON -DCSHARP_BINDINGS:BOOL=ON -DLIBXML2_LIBRARIES="C:\\libs\\64\\libxml2.lib" -DLIBUSB_LIBRARIES="C:\\libs\\64\\libusb-1.0.lib" -DLIBSERIALPORT_LIBRARIES="C:\\libs\\64\\libserialport.dll.a" -DLIBUSB_INCLUDE_DIR="C:\\include\\libusb-1.0" -DLIBXML2_INCLUDE_DIR="C:\\include\\libxml2" .. - cmake --build . --config Release - cp .\libiio.iss $env:BUILD_ARTIFACTSTAGINGDIRECTORY +cmake -G "$COMPILER" -DCMAKE_SYSTEM_PREFIX_PATH="C:" -DENABLE_IPV6=OFF -DWITH_USB_BACKEND=ON -DWITH_SERIAL_BACKEND=ON -DPYTHON_BINDINGS=ON -DCSHARP_BINDINGS:BOOL=ON -DLIBXML2_LIBRARIES="C:\\libs\\64\\libxml2.lib" -DLIBUSB_LIBRARIES="C:\\libs\\64\\libusb-1.0.lib" -DLIBSERIALPORT_LIBRARIES="C:\\libs\\64\\libserialport.dll.a" -DLIBUSB_INCLUDE_DIR="C:\\include\\libusb-1.0" -DLIBXML2_INCLUDE_DIR="C:\\include\\libxml2" .. +cmake --build . --config Release +if ( $LASTEXITCODE -ne 0 ) { + throw "[*] cmake build failure" + } +cp .\libiio.iss $env:BUILD_ARTIFACTSTAGINGDIRECTORY - cd ../bindings/python - python.exe setup.py.cmakein sdist - Get-ChildItem dist\pylibiio-*.tar.gz | Rename-Item -NewName "libiio-py39-amd64.tar.gz" - mv .\dist\*.gz . - rm .\dist\*.gz -} +cd bindings/python +python.exe setup.py sdist +Get-ChildItem dist\pylibiio-*.tar.gz | Rename-Item -NewName "libiio-py39-amd64.tar.gz" +mv .\dist\*.gz . +rm .\dist\*.gz diff --git a/CI/generate_exe.ps1 b/CI/generate_exe.ps1 index c68b2eba6..f6503f8e0 100644 --- a/CI/generate_exe.ps1 +++ b/CI/generate_exe.ps1 @@ -1,5 +1,8 @@ -SET PATH=packages\Tools.InnoSetup.5.6.1\tools -iscc $env:BUILD_ARTIFACTSTAGINGDIRECTORY\Windows-VS-16-2019-Win32\libiio.iss +# https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_preference_variables?view=powershell-7.2#erroractionpreference +$ErrorActionPreference = "Stop" +$ErrorView = "NormalView" + +iscc $env:BUILD_ARTIFACTSTAGINGDIRECTORY\Windows-VS-2019-x64\libiio.iss Get-ChildItem $env:BUILD_ARTIFACTSTAGINGDIRECTORY -Force -Recurse | Remove-Item -Force -Recurse cp C:\libiio-setup.exe $env:BUILD_ARTIFACTSTAGINGDIRECTORY diff --git a/CI/install_deps_win.ps1 b/CI/install_deps_win.ps1 deleted file mode 100644 index 53fd02b46..000000000 --- a/CI/install_deps_win.ps1 +++ /dev/null @@ -1,30 +0,0 @@ - -$ARCH=$Env:ARCH - -git submodule update --init - -if (!(Test-Path deps)) { - mkdir deps -} -cd deps - -mkdir libxml - -if ( "$ARCH" -eq "x64" ) { - wget https://www.zlatkovic.com/pub/libxml/64bit/libxml2-2.9.3-win32-x86_64.7z -OutFile "libxml.7z" -} else { - wget https://www.zlatkovic.com/pub/libxml/64bit/libxml2-2.9.3-win32-x86.7z -OutFile "libxml.7z" -} -7z x -y libxml.7z -rm libxml.7z - -echo "Downloading deps..." -cd C:\ -wget http://swdownloads.analog.com/cse/build/libiio-win-deps-libusb1.0.24.zip -OutFile "libiio-win-deps.zip" -7z x -y "C:\libiio-win-deps.zip" - -# Note: InnoSetup is already installed on Azure images; so don't run this step -# Running choco seems a bit slow; seems to save about 40-60 seconds here -#choco install InnoSetup - -set PATH=%PATH%;"C:\Program Files (x86)\Inno Setup 6" diff --git a/CI/publish_deps.ps1 b/CI/publish_deps.ps1 index dc0cd46a2..76ec7955a 100644 --- a/CI/publish_deps.ps1 +++ b/CI/publish_deps.ps1 @@ -1,13 +1,18 @@ +# https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_preference_variables?view=powershell-7.2#erroractionpreference +$ErrorActionPreference = "Stop" +$ErrorView = "NormalView" $src_dir=$pwd +$COMPILER=$Env:COMPILER -cd 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Redist\MSVC\14.29.30133' -if ($ARCH -eq "Win32") { - echo "$PWD" - mv .\x86\Microsoft.VC142.CRT\msvcp140.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY +if ($COMPILER -eq "Visual Studio 16 2019") { + cd 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Redist\MSVC\14.29.30133\x64\Microsoft.VC142.CRT' + cp .\msvcp140.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY + cp .\vcruntime140.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY }else { - echo "$PWD" - mv .\x64\Microsoft.VC142.CRT\msvcp140.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY + cd 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Redist\MSVC\14.29.30133\x64\Microsoft.VC142.CRT' + cp .\msvcp140.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY + cp .\vcruntime140.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY } cd $src_dir @@ -16,12 +21,6 @@ cd dependencies wget http://swdownloads.analog.com/cse/build/libiio-win-deps-libusb1.0.24.zip -OutFile "libiio-win-deps.zip" 7z x -y "libiio-win-deps.zip" -if ($ARCH -eq "Win32") { - mv .\libs\32\libxml2.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY - mv .\libs\32\libserialport-0.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY - mv .\libs\32\libusb-1.0.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY -}else { - mv .\libs\64\libxml2.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY - mv .\libs\64\libserialport-0.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY - mv .\libs\64\libusb-1.0.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY -} +cp .\libs\64\libxml2.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY +cp .\libs\64\libserialport-0.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY +cp .\libs\64\libusb-1.0.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY diff --git a/CI/travis/after_deploy b/CI/travis/after_deploy deleted file mode 100755 index 4acdeb4b9..000000000 --- a/CI/travis/after_deploy +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -e - -TRIGGERING_NEXT_BUILD=true - -. CI/travis/lib.sh - -should_trigger_next_builds "$TRAVIS_BRANCH" || exit 0 - -trigger_adi_build "libad9361-iio" "$TRAVIS_BRANCH" diff --git a/CI/travis/before_deploy b/CI/travis/before_deploy deleted file mode 100755 index 80bf03151..000000000 --- a/CI/travis/before_deploy +++ /dev/null @@ -1,179 +0,0 @@ -#!/bin/sh -e - -. CI/travis/lib.sh - -# Don't prepare a deploy on a Coverity build -if [ "x${COVERITY_SCAN_PROJECT_NAME}" != "x" ] ; then exit 0; fi - -deploy=0 -if [ -z "$TRAVIS_BUILD_DIR" ] ; then - t=$(find ./ -name CMakeCache.txt|head -1) - if [ -n "${t}" ] ; then - cd $(dirname $(dirname ${t})) - TRAVIS_BUILD_DIR=$(pwd) - else - echo "I am confused - can't find CMakeCache.txt" - exit - fi -else - cd $TRAVIS_BUILD_DIR -fi -pwd - -if [ -z "${LDIST}" -a -f "build/.LDIST" ] ; then - export LDIST="-$(cat build/.LDIST)" -fi -if [ -z "${LDIST}" ] ; then - export LDIST="-$(get_ldist)" -fi - -check_file() -{ -temp="" -for i in $(find ./ -name CMakeCache.txt) -do -hit=$(find $(dirname ${i}) -maxdepth 1 -name "libiio*.$1" -a ! -name "*${LDIST}*") -if [ "$(echo ${hit} | wc -w)" -gt "1" ] ; then - echo "I am confused - more than 2 $1 files!" - echo $hit - exit 1 -else - if [ "$(echo ${hit} | wc -w)" -eq "1" ] ; then - if [ -z "${temp}" ] ; then - temp=$hit - else - echo "I am confused - more than 2 $1 files" - echo $temp - echo $hit - exit 1 - fi - fi -fi -done -} - -check_file deb -if [ -n "${temp}" ] ; then - deploy=$(expr ${deploy} + 1) - if [ -z "${TARGET_DEB}" ] ; then - export TARGET_DEB=$(echo ${temp} | \ - sed -e 's:^./.*/::' -e 's:-Linux::' -e 's:.deb$::')${LDIST}.deb - fi - echo "deploying ${temp} to nightly $TARGET_DEB" - if [ -z "${RELEASE_PKG_FILE_DEB}" ] ; then - export RELEASE_PKG_FILE_DEB=$(dirname ${temp})/${TARGET_DEB} - cp ${temp} ${RELEASE_PKG_FILE_DEB} - fi - echo ${TARGET_DEB} - ls -lh ${temp} - echo ${RELEASE_PKG_FILE_DEB} - ls -lh ${RELEASE_PKG_FILE_DEB} -else - echo "Skipping deployment of debian package" -fi - -check_file rpm -if [ -n "${temp}" ] ; then - deploy=$(expr ${deploy} + 1) - if [ -z "${TARGET_RPM}" ] ; then - export TARGET_RPM=$(echo ${temp} | \ - sed -e 's:^./.*/::' -e 's:-Linux::' -e 's:.rpm$::')${LDIST}.rpm - fi - echo "deploying ${temp} to nightly $TARGET_RPM" - if [ -z "${RELEASE_PKG_FILE_RPM}" ] ; then - export RELEASE_PKG_FILE_RPM=$(dirname ${temp})/${TARGET_RPM} - cp ${temp} ${RELEASE_PKG_FILE_RPM} - fi - echo ${TARGET_RPM} - ls -lh ${temp} - echo ${RELEASE_PKG_FILE_RPM} - ls -lh ${RELEASE_PKG_FILE_RPM} -else - echo "Skipping deployment of rpm package" -fi - -check_file tar.gz -if [ -n "${temp}" ] ; then - deploy=$(expr ${deploy} + 1) - if [ -z "${TARGET_TGZ}" ] ; then - echo updating tar file - ( - cd $(dirname ${temp}) - if [ -d tarball_fixup ] ; then - rm -rf tarball_fixup - fi - mkdir tarball_fixup && cd tarball_fixup - - if [ "$TRAVIS_OS_NAME" = "osx" ] ; then - tar --strip-components=1 -xzf ${TRAVIS_BUILD_DIR}/${temp} - else - tar -xzf ${TRAVIS_BUILD_DIR}/${temp} - fi - - if [ "$TRAVIS_OS_NAME" = "osx" ] ; then - cd usr/lib - ln -fs ../../Library/Frameworks/iio.framework/iio libiio.dylib - install_name_tool -change /usr/local/opt/libusb/lib/libusb-1.0.0.dylib @rpath/libusb-1.0.dylib libiio.dylib - install_name_tool -add_rpath @loader_path/../../../../../usr/lib libiio.dylib - install_name_tool -add_rpath /usr/local/opt/libusb/lib libiio.dylib - - cd ../include - ln -s ../../Library/Frameworks/iio.framework/Headers/iio.h iio.h - - # Update references for tools - cd ../.. - TOOLS=Library/Frameworks/iio.framework/Tools/* - for tool in $TOOLS - do - install_name_tool -add_rpath @loader_path/../../ $tool - done - cp /usr/local/lib/libusb-1.0.dylib usr/lib/ - chmod +w usr/lib/libusb-1.0.dylib - install_name_tool -id @rpath/libusb-1.0.dylib usr/lib/libusb-1.0.dylib - - tar -czf ${TRAVIS_BUILD_DIR}/${temp} usr Library - else - tar -czf ${TRAVIS_BUILD_DIR}/${temp} usr lib - fi - ) - - export TARGET_TGZ=$(echo ${temp} | \ - sed -e 's:^./.*/::' -e 's:-Linux::' -e 's:-Darwin::' -e 's:.tar.gz$::')${LDIST}.tar.gz; - fi - echo "deploying ${temp} to $TARGET_TGZ" - if [ -z "${RELEASE_PKG_FILE_TGZ}" ] ; then - export RELEASE_PKG_FILE_TGZ=$(dirname ${temp})/${TARGET_TGZ} - cp ${temp} ${RELEASE_PKG_FILE_TGZ} - fi - echo ${TARGET_TGZ} - ls -lh ${temp} - echo ${RELEASE_PKG_FILE_TGZ} - ls -lh ${RELEASE_PKG_FILE_TGZ} -else - echo "Skipping deployment of tarball" -fi - -check_file pkg -if [ -n "${temp}" ] ; then - deploy=$(expr ${deploy} + 1) - if [ -z "${TARGET_PKG}" ] ; then - export TARGET_PKG=$(echo ${temp} | \ - sed -e 's:^./.*/::' -e 's:.pkg$::')${LDIST}.pkg - fi - echo "deploying ${temp} to nightly $TARGET_PKG" - if [ -z "${RELEASE_PKG_FILE_PKG}" ] ; then - export RELEASE_PKG_FILE_PKG=$(dirname ${temp})/${TARGET_PKG} - cp ${temp} ${RELEASE_PKG_FILE_PKG} - fi - echo ${TARGET_PKG} - ls -lh ${temp} - echo ${RELEASE_PKG_FILE_PKG} - ls -lh ${RELEASE_PKG_FILE_PKG} -else - echo "Skipping deployment of OS X package" -fi - -if [ "${deploy}" -eq "0" ] ; then - echo did not deploy any files - exit 1 -fi diff --git a/CI/travis/before_install_darwin b/CI/travis/before_install_darwin deleted file mode 100755 index bf6cfc25d..000000000 --- a/CI/travis/before_install_darwin +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -e - -. CI/travis/lib.sh - -brew_install_if_not_exists cmake doxygen libusb libxml2 ncurses cdk zstd diff --git a/CI/travis/before_install_linux b/CI/travis/before_install_linux deleted file mode 100755 index c6108fbb1..000000000 --- a/CI/travis/before_install_linux +++ /dev/null @@ -1,118 +0,0 @@ -#!/bin/sh -e - -. CI/travis/lib.sh - -install_sphinx() { - if [ "$CI_BUILD_SPHINX_DOCS" != "1" ] ; then - return - fi - - if ! is_python_at_least_ver "$PYTHON" "3.6" ; then - echo_red "Python version is too old no python interpreter installed" - return 1 - fi - - $PYTHON --version - command -v $PYTHON - $PYTHON -m pip install sphinx - $PYTHON -m pip install sphinx-rtd-theme -} - -handle_centos() { - # needed for man2html and a few other popular tools - yum search epel-release - yum info epel-release - yum -y install epel-release - - # FIXME: see about adding `libserialport-dev` from EPEL ; maybe libusb-1.0.0-devel... - yum -y groupinstall 'Development Tools' - - if [ "$(get_version | head -c 1)" = "7" ] ; then - yum -y install cmake libxml2-devel libusb1-devel libaio-devel \ - bzip2 gzip rpm rpm-build libzstd-devel - - # install Cmake3, and make it the default - yum -y install cmake3 - alternatives --install /usr/local/bin/cmake cmake /usr/bin/cmake 10 \ - --slave /usr/local/bin/ctest ctest /usr/bin/ctest \ - --slave /usr/local/bin/cpack cpack /usr/bin/cpack \ - --slave /usr/local/bin/ccmake ccmake /usr/bin/ccmake \ - --family cmake - alternatives --install /usr/local/bin/cmake cmake /usr/bin/cmake3 20 \ - --slave /usr/local/bin/ctest ctest /usr/bin/ctest3 \ - --slave /usr/local/bin/cpack cpack /usr/bin/cpack3 \ - --slave /usr/local/bin/ccmake ccmake /usr/bin/ccmake3 \ - --family cmake - fi - - if [ "$(get_version | head -c 1)" = "8" ] ; then - yum -y install wget - wget https://github.com/Kitware/CMake/releases/download/v3.15.2/cmake-3.15.2.tar.gz - tar -zxvf cmake-3.15.2.tar.gz - cd cmake-3.15.2 - ./bootstrap - make - make install - cd .. - yum -y install epel-release - yum -y install libzstd - - yum -y install dnf - dnf -y --enablerepo=powertools install doxygen - - yum -y install libxml2-devel libusb1-devel libaio-devel \ - bzip2 gzip rpm rpm-build libzstd-devel - fi - - if is_centos_at_least_ver "8" ; then - # On CentOS 8, avahi-devel & doxygen are in this repo; enable it - yum -y install yum-utils - yum config-manager --set-enabled powertools - # On CentOS 6 & 7, have issues building or packaging doc - yum -y install python3 doxygen man2html - install_sphinx - else - # On CentOS 8, cdk-devel (Curses Development Kit) does not exist yet - yum -y install ncurses-devel cdk-devel - fi - - yum -y install avahi-devel -} - -handle_generic_docker() { - prepare_docker_image -} - -handle_default() { - sudo apt-get -qq update - sudo DEBIAN_FRONTEND=noninteractive apt-get install -y cmake graphviz \ - libaio-dev libavahi-client-dev libserialport-dev libzstd-dev \ - libavahi-common-dev libusb-1.0-0-dev libxml2-dev rpm tar \ - bzip2 gzip flex bison git libncurses5-dev libcdk5-dev \ - doxygen man2html python3 python3-pip python3-setuptools - - install_sphinx -} - -handle_ubuntu() { - handle_default - - if [ "${OS_VERSION}" = xenial ] ; then - # Use Bionic's release of CMake on Xenial - sudo bash -c "echo 'deb http://archive.ubuntu.com/ubuntu bionic main' >> /etc/apt/sources.list" - sudo apt-get -qq update - sudo DEBIAN_FRONTEND=noninteractive apt-get install -t bionic -y cmake - fi -} - -handle_debian() { - handle_default -} - -handle_doxygen() { - handle_default -} - -setup_build_type_env_vars - -handle_${BUILD_TYPE} diff --git a/CI/travis/check_kernel.sh b/CI/travis/check_kernel.sh deleted file mode 100755 index ff2e82d8b..000000000 --- a/CI/travis/check_kernel.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/bash -set -e - -KERNEL_TYPES="/tmp/mainline_types.h" -IIOH="./iio.h" -CHANNELC="./channel.c" - -if [ ! -f ${IIOH} ] ; then - echo can not find ${IIOH} - exit 1 -fi - -if [ ! -f ${CHANNELC} ] ; then - echo can not find ${CHANNELC} - exit 1 -fi - -rm -f ${KERNEL_TYPES} -wget -O ${KERNEL_TYPES} https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/plain/include/uapi/linux/iio/types.h - -ret=0 - -for enum in iio_chan_type iio_modifier -do - echo looking for ${enum} - rm -f /tmp/kernel_${enum} /tmp/libiio_${enum} - sed "0,/${enum}/d" ${KERNEL_TYPES} | sed -n '/}/q;p' > /tmp/kernel_${enum} - sed "0,/^enum.*${enum}/d" ${IIOH} | sed -n '/}/q;p' | grep -v IIO_CHAN_TYPE_UNKNOWN > /tmp/libiio_${enum} - echo Differences in ${enum} - # diff exit status of 1 means a difference, not an error - set +e - diff -u /tmp/libiio_${enum} /tmp/kernel_${enum} - count=$(diff -u /tmp/libiio_${enum} /tmp/kernel_${enum} | wc -l) - set -e - if [ "$count" -ne "0" ] ; then - ret=1 - echo difference between upstream kernel types.h and iio.h in ${enum} - else - echo none - fi -done - -for enum in iio_chan_type_name_spec modifier_names -do - sed "0,/^static.*${enum}/d" ${CHANNELC} | sed -n '/}/q;p' | \ - grep -v IIO_CHAN_TYPE_UNKNOWN > /tmp/libiio_${enum} -done - -while IFS="" read -r p ; do - key=$(echo ${p//[[:space:],]/}) - count=$(grep "\[$key\]" /tmp/libiio_iio_chan_type_name_spec | wc -l) - if [ "$count" -eq "0" ] ; then - echo "$key missing from channel.c iio_chan_type_name_spec" - ret=1 - fi -done < /tmp/libiio_iio_chan_type - -echo -sed -i '/IIO_NO_MOD/d' /tmp/libiio_iio_modifier - -while IFS="" read -r p ; do - key=$(echo "${p//[[:space:],]/}") - count=$(grep "\[$key\]" /tmp/libiio_modifier_names | wc -l) - if [ "$count" -eq "0" ] ; then - echo "$key missing from channel.c modifier_names" - ret=1 - fi -done < /tmp/libiio_iio_modifier - -exit $ret diff --git a/CI/travis/deploy b/CI/travis/deploy deleted file mode 100755 index aa4d086ba..000000000 --- a/CI/travis/deploy +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -e - -. CI/travis/lib.sh - -# libname from to suffix -upload_file_to_swdownloads libiio ${RELEASE_PKG_FILE_DEB} ${TARGET_DEB} .deb -upload_file_to_swdownloads libiio ${RELEASE_PKG_FILE_RPM} ${TARGET_RPM} .rpm -upload_file_to_swdownloads libiio ${RELEASE_PKG_FILE_TGZ} ${TARGET_TGZ} .tar.gz -upload_file_to_swdownloads libiio ${RELEASE_PKG_FILE_PKG} ${TARGET_PKG} .pkg -remove_old_pkgs libiio diff --git a/CI/travis/deploy.rsa.enc b/CI/travis/deploy.rsa.enc deleted file mode 100644 index 78fe1ff05..000000000 Binary files a/CI/travis/deploy.rsa.enc and /dev/null differ diff --git a/CI/travis/inside_docker.sh b/CI/travis/inside_docker.sh old mode 100755 new mode 100644 diff --git a/CI/travis/lib.sh b/CI/travis/lib.sh index bfea28e5c..b605f6512 100644 --- a/CI/travis/lib.sh +++ b/CI/travis/lib.sh @@ -237,10 +237,8 @@ sftp_upload() { if [ -n "${LATE}" ] ; then sftp_cmd_pipe <<-EOF cd ${DEPLOY_TO} - put ${FROM} ${TO} ls -l ${TO} - symlink ${TO} ${LATE} ls -l ${LATE} bye @@ -248,7 +246,6 @@ sftp_upload() { else sftp_cmd_pipe <<-EOF cd ${DEPLOY_TO} - put ${FROM} ${TO} ls -l ${TO} bye @@ -423,7 +420,7 @@ __save_env_for_docker() { } run_docker_script() { - local DOCKER_SCRIPT="$(get_script_path $1)" + local DOCKER_SCRIPT="$(get_script_path "$1")" local MOUNTPOINT="${INSIDE_DOCKER_BUILD_DIR}" local DOCKER_IMAGE="${OS_TYPE}:${OS_VERSION}" diff --git a/CI/travis/make_darwin b/CI/travis/make_darwin deleted file mode 100755 index c27fd505e..000000000 --- a/CI/travis/make_darwin +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh -e - -LIBIIO_BUILD_CONF="-DWITH_SERIAL_BACKEND=OFF -DWITH_ZSTD=ON" - -if [ "x${COVERITY_SCAN_PROJECT_NAME}" != "x" ] ; then exit 0; fi - -build_osx() { - FLAGS=$1 - echo "### cmake ${FLAGS}" - cmake ${FLAGS} .. - - echo "### make" - make - - echo "### files are" - ls -} - -change_artefact_name() { - old_name=`find . -name '*.pkg' | cut -b 3-26` - name=`echo ${old_name} | cut -b 1-20` - new_name="${name}-${ARTIFACTNAME}.pkg" - mv ./${old_name} ./${new_name} -} - -mkdir -p build - -cd build -build_osx "-DOSX_PACKAGE=ON -DPYTHON_BINDINGS=ON -DWITH_EXAMPLES=ON ${LIBIIO_BUILD_CONF}" -change_artefact_name - -cd .. - -mkdir -p build_tar -cd build_tar -build_osx "-DOSX_PACKAGE=OFF -DENABLE_PACKAGING=ON -DPYTHON_BINDINGS=ON -DCPACK_SYSTEM_NAME=${ARTIFACTNAME} ${LIBIIO_BUILD_CONF}" -echo "### make package" -make package -echo "### files are" -ls diff --git a/CI/travis/make_linux b/CI/travis/make_linux deleted file mode 100755 index f5e89374a..000000000 --- a/CI/travis/make_linux +++ /dev/null @@ -1,144 +0,0 @@ -#!/bin/sh -e - -if [ "x${COVERITY_SCAN_PROJECT_NAME}" != "x" ] ; then exit 0; fi - -. CI/travis/lib.sh - -INSIDE_DOCKER_TRAVIS_CI_ENV="$INSIDE_DOCKER_TRAVIS_CI_ENV CHECK_AGAINST_KERNEL_HEADER CI_BUILD_SPHINX_DOCS" -CPACK_HELP="-DCPACK_SYSTEM_NAME=${ARTIFACTNAME}" - -handle_default() { - echo "### making build dir" - mkdir -p build - cd build - - if command_exists $PYTHON ; then - command -v $PYTHON - $PYTHON --version - - PYTHON_HELP="-DPYTHON_BINDINGS=ON \ - -DPYTHON_INCLUDE_DIR=$($PYTHON -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \ - -DPYTHON_LIBRARY=$($PYTHON -c "import distutils.sysconfig as sysconfig; print(sysconfig.get_config_var('LIBDIR'))") \ - -DPYTHON_EXECUTABLE=$(command -v $PYTHON)" - - # Add ~/.local dir to paths; this is where pip installs things (if no sudo) - export PATH="$PATH:$(readlink -f ~/.local/bin/)" - export PYTHONPATH="$(readlink -f ~/.local/lib/python*/site-packages/)" - - if command_exists sphinx-build ; then - DOC_HELP="-DWITH_DOC=ON" - fi - else - echo No Python - if command_exists doxygen ; then - DOC_HELP="-DWITH_DOC=ON" - fi - fi - if [ ! -n "${DOC_HELP}" ] ; then - if command_exists man2html ; then - echo doc and man - MAN_HELP="-DWITH_MAN=ON" - fi - else - MAN_HELP="-DWITH_MAN=ON" - fi - - FLAGS="-DENABLE_PACKAGING=ON -DDEB_DETECT_DEPENDENCIES=ON -DWITH_EXAMPLES=ON ${PYTHON_HELP} ${DOC_HELP} ${MAN_HELP} ${CPACK_HELP}" - - # Ubuntu Xenial's libserialport and libzstd are too old - if [ "${OS_VERSION}" = xenial ] ; then - FLAGS="${FLAGS} -DWITH_SERIAL_BACKEND=OFF" - else - FLAGS="${FLAGS} -DWITH_SERIAL_BACKEND=ON -DWITH_ZSTD=ON" - fi - - echo "### cmake ${FLAGS}" - cmake ${FLAGS} .. - - if [ -f CMakeFiles/CMakeError.log ] ; then - echo "### CMakeError.log" - cat CMakeFiles/CMakeError.log - exit 1 - fi - - echo "### make" - make - - # check the error output if either file is not empty - if [ -s ./Dox_output_libiio -o -s ./Dox_output_csharp -o -s ./Spx_output_python ] ; then - if [ -s ./Dox_output_libiio ] ; then - echo "### ERRORs in Dox_output_libiio" - cat ./Dox_output_libiio - fi - if [ -s ./Dox_output_csharp ] ; then - echo "### ERRORs in Dox_output_csharp" - cat ./Dox_output_csharp - fi - if [ -s ./Spx_output_python ] ; then - echo "### ERRRORs in Spx_output_python" - cat ./Spx_output_python - fi - exit 1 - else - echo "### No errors in Doc" - if [ -f Dox_output_csharp ] ; then - ls -l Dox_output_csharp - fi - if [ -f Dox_output_libiio ] ; then - ls -l Dox_output_libiio - fi - if [ -f Spx_output_python ] ; then - ls -l Spx_output_python - fi - fi - - echo "### make package" - make package - - if [ -f "./generateDocumentationAndDeploy.sh" ] ; then - sh generateDocumentationAndDeploy.sh - fi - cd .. - - # make sure we are up to date (once) - if [ "$CHECK_AGAINST_KERNEL_HEADER" = "1" ] ; then - ./CI/travis/check_kernel.sh - fi - echo "### All done building" -} - -handle_centos() { - echo "handle centos" - mkdir -p build - cd build - - FLAGS="-DENABLE_PACKAGING=ON -DPYTHON_BINDINGS=ON -DWITH_SERIAL_BACKEND=OFF -DWITH_ZSTD=ON ${CPACK_HELP}" - - # CentOS 7's kernel headers are too old for USB support in IIOD - [ "${OS_VERSION}" = centos7 ] && FLAGS="${FLAGS} -DWITH_IIOD_USBD=OFF" - - cmake ${FLAGS} .. - make - make package - cd .. -} - -handle_ubuntu() { - handle_default -} - -handle_debian() { - handle_default -} - -handle_generic_docker() { - run_docker_script inside_docker.sh -} - -handle_doxygen() { - handle_default -} - -setup_build_type_env_vars - -handle_${BUILD_TYPE} diff --git a/CI/travis/make_linux_qemu b/CI/travis/make_linux_qemu deleted file mode 100755 index b1d101db7..000000000 --- a/CI/travis/make_linux_qemu +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -set -ex - -CHROOT_DIR=/tmp/arm-chroot - -sudo chroot ${CHROOT_DIR} bash -c "cd ${TRAVIS_BUILD_DIR} && ./CI/travis/make_linux libiio" -sudo chroot ${CHROOT_DIR} bash -c ". ${TRAVIS_BUILD_DIR}/CI/travis/lib.sh && get_ldist > ${TRAVIS_BUILD_DIR}/build/.LDIST" - -#move the artifacts back to the non-qemu place -sudo rsync -av ${CHROOT_DIR}/${TRAVIS_BUILD_DIR}/ ${TRAVIS_BUILD_DIR}/ -#make sure the normal travis user can read them -sudo chown -R ${USER} ${TRAVIS_BUILD_DIR} - diff --git a/CI/travis/prepare_assets.sh b/CI/travis/prepare_assets.sh deleted file mode 100755 index 0fb116a68..000000000 --- a/CI/travis/prepare_assets.sh +++ /dev/null @@ -1,74 +0,0 @@ -#!/bin/bash -e - -release_artifacts() { - local rpm_assets='CentOS-7-x86_64 CentOS-8-x86_64' - cd "${BUILD_ARTIFACTSTAGINGDIRECTORY}" - for i in $rpm_assets; do - cd "${i}" - find . -name '*.rpm' -exec mv {} ../ ";" - cd ../ - rm -r "${i}" - done - - local deb_assets='Ubuntu-16.04-x86_64 Ubuntu-18.04-x86_64 - Ubuntu-20.04-x86_64 Debian-Buster-ARM - Debian-Buster-ARM64' - cd "${BUILD_ARTIFACTSTAGINGDIRECTORY}" - for i in $deb_assets; do - cd "${i}" - find . -name '*.deb' -exec mv {} ../ ";" - cd ../ - rm -r "${i}" - done - - local pkg_assets='macOS-10.15 macOS-11' - cd "${BUILD_ARTIFACTSTAGINGDIRECTORY}" - for i in $pkg_assets; do - cd "${i}" - find . -name '*.pkg' -exec mv {} ../ ";" - find . -name '*.gz' -exec mv {} ../ ";" - cd ../ - rm -r "${i}" - done - - local windows_dist='Win32 x64' - cd "${BUILD_ARTIFACTSTAGINGDIRECTORY}" - for distribution in $windows_dist; do - zip -r Windows-VS-16-2019-"${distribution}".zip Windows-VS-16-2019-"${distribution}" - rm -r Windows-VS-16-2019-"${distribution}" - done -} - -swdownloads_artifacts() { - local linux_dist='CentOS-7-x86_64 CentOS-8-x86_64 Ubuntu-16.04-x86_64 Ubuntu-18.04-x86_64 - Ubuntu-20.04-x86_64 Debian-Buster-ARM Debian-Buster-ARM64' - for distribution in $linux_dist; do - cd "${BUILD_ARTIFACTSTAGINGDIRECTORY}" - cd "Linux-${distribution}" - find . -name '*.rpm' -exec mv {} ../"${distribution}"_latest_master_libiio.rpm ";" - find . -name '*.deb' -exec mv {} ../"${distribution}"_latest_master_libiio.deb ";" - rm -r ../Linux-"${distribution}" - done - - local macOS_dist='macOS-10.15 macOS-11' - for distribution in $macOS_dist; do - cd "${BUILD_ARTIFACTSTAGINGDIRECTORY}" - cd "${distribution}" - find . -name '*.pkg' -exec mv {} ../"${distribution}"_latest_master_libiio.pkg ";" - find . -name '*.tar.gz' -exec mv {} ../"${distribution}"_latest_master_libiio.tar.gz ";" - rm -r ../"${distribution}" - done - - local windows_dist='Win32 x64' - for distribution in $windows_dist; do - cd "${BUILD_ARTIFACTSTAGINGDIRECTORY}" - zip -r Windows-VS-16-2019-"${distribution}".zip Windows-VS-16-2019-"${distribution}" - rm -r Windows-VS-16-2019-"${distribution}" - done - - cd "${BUILD_ARTIFACTSTAGINGDIRECTORY}/Libiio-Setup-Exe" - mv libiio-setup.exe ../libiio-setup.exe - rm -r ../Libiio-Setup-Exe -} - -"${1}"_artifacts diff --git a/CI/travis/setup_qemu_for_arm.sh b/CI/travis/setup_qemu_for_arm.sh deleted file mode 100755 index ab8b39d6f..000000000 --- a/CI/travis/setup_qemu_for_arm.sh +++ /dev/null @@ -1,87 +0,0 @@ -#!/bin/bash -# Based on a test script from avsm/ocaml repo https://github.com/avsm/ocaml -set -ex - -if [ $# -ne 1 ] ; then - echo Must include debian distribution ie wheezy, jessie, stretch, or buster - exit -1 -fi -if [[ ! $1 =~ ^wheezy|jessie|stretch|buster$ ]] ; then - echo Must include debian distribution ie wheezy, jessie, stretch, or buster - exit -1 -fi - -CHROOT_DIR=/tmp/arm-chroot -MIRROR=http://archive.raspbian.org/raspbian -# wheezy = 7 (2013-05-04); jessie = 8 (2015-04-26); stretch = 9 (2017-06-17); buster = 10 (2019-03-12) -VERSION=$1 -echo building for "${VERSION}" -CHROOT_ARCH=armhf - -# Host dependencies -sudo apt-get update -sudo apt-get install -qq -y qemu-user-static binfmt-support sbuild wget debian-archive-keyring ubuntu-keyring gnupg libudev1 libudev-dev liblzma-dev libglib2.0-dev libfdt-dev libpixman-1-dev zlib1g-dev -# need a newer version of qemu :( -QEMU_DIR=/tmp/qemu -sudo mkdir -p ${QEMU_DIR} -sudo chown "${USER}" /tmp/qemu -cd ${QEMU_DIR} -wget https://download.qemu.org/qemu-3.1.0.tar.xz -tar xf qemu-3.1.0.tar.xz -cd qemu-3.1.0 -mkdir build -mkdir install -cd build -../configure --prefix=${QEMU_DIR}/install --disable-bsd-user --disable-guest-agent --disable-strip --disable-werror --disable-gcrypt --disable-debug-info --disable-debug-tcg --disable-docs --disable-tcg-interpreter --enable-attr --disable-brlapi --disable-linux-aio --disable-bzip2 --disable-bluez --disable-cap-ng --disable-curl --disable-fdt --disable-glusterfs --disable-gnutls --disable-nettle --disable-gtk --disable-rdma --disable-libiscsi --disable-vnc-jpeg --disable-kvm --disable-lzo --disable-curses --disable-libnfs --disable-numa --disable-opengl --disable-vnc-png --disable-rbd --disable-vnc-sasl --disable-sdl --disable-seccomp --disable-smartcard --disable-snappy --disable-spice --disable-libssh2 --disable-libusb --disable-usb-redir --disable-vde --disable-vhost-net --disable-virglrenderer --disable-virtfs --disable-vnc --disable-vte --disable-xen --disable-xen-pci-passthrough --disable-xfsctl --enable-linux-user --disable-system --disable-blobs --disable-tools --target-list=arm-linux-user --static --disable-pie -make -j $(nproc) -make install -ls -lR ${QEMU_DIR}/install -cd /tmp - -# per https://wiki.ubuntu.com/DebootstrapChroot -if [[ "$VERSION" =~ ^wheezy|jessie$ ]] ; then - sudo apt-get install -qq -y debootstrap - -elif [[ "$VERSION" =~ ^stretch$ ]] ; then - sudo add-apt-repository -r "deb http://archive.ubuntu.com/ubuntu $(lsb_release -cs)-updates main restricted universe multiverse " - sudo apt-get install -qq -y -t $(lsb_release -cs)-updates debootstrap -elif [[ "$VERSION" =~ ^buster$ ]] ; then - wget http://http.us.debian.org/debian/pool/main/d/debootstrap/debootstrap_1.0.111_all.deb -O /tmp/debootstrap_1.0.111_all.deb - sudo dpkg --install /tmp/debootstrap_1.0.111_all.deb -fi - -# Create chrooted environment -sudo mkdir ${CHROOT_DIR} -sudo debootstrap --foreign --no-check-gpg --include=fakeroot,build-essential --arch="${CHROOT_ARCH}" "${VERSION}" "${CHROOT_DIR}" "${MIRROR}" -sudo cp ${QEMU_DIR}/install/bin/qemu-arm ${CHROOT_DIR}/usr/bin/qemu-arm-static -${CHROOT_DIR}/usr/bin/qemu-arm-static -version -sudo chroot ${CHROOT_DIR} ./debootstrap/debootstrap --second-stage -sudo sbuild-createchroot --arch="${CHROOT_ARCH}" --foreign --setup-only "${VERSION}" "${CHROOT_DIR}" "${MIRROR}" - -# Create file with environment variables which will be used inside chrooted -# environment -echo "export ARCH=${ARCH}" > envvars.sh -echo "export TRAVIS_BUILD_DIR=${TRAVIS_BUILD_DIR}" >> envvars.sh -chmod a+x envvars.sh - -# Install dependencies inside chroot -sudo chroot ${CHROOT_DIR} dpkg --add-architecture ${CHROOT_ARCH} -sudo chroot ${CHROOT_DIR} dpkg --remove-architecture amd64 -sudo chroot ${CHROOT_DIR} apt-get update -sudo chroot ${CHROOT_DIR} apt-get --allow-unauthenticated install -qq -y locales -sudo chroot ${CHROOT_DIR} locale -sudo chroot ${CHROOT_DIR} bash -c "echo en_US.UTF-8 UTF-8 > /etc/locale.gen" -sudo chroot ${CHROOT_DIR} locale-gen -#sudo chroot ${CHROOT_DIR} bash -c "echo -e 'LANG=\"en_US.UTF-8\"\\nLANGUAGE=\"en_US:en\"\\n' > /etc/default/locale" -sudo chroot ${CHROOT_DIR} apt-get --allow-unauthenticated install -qq -y build-essential git m4 sudo python cmake - -# Create build dir and copy travis build files to our chroot environment -sudo mkdir -p "${CHROOT_DIR}/${TRAVIS_BUILD_DIR}" -sudo rsync -av "${TRAVIS_BUILD_DIR}/" "${CHROOT_DIR}/${TRAVIS_BUILD_DIR}/" - -# Indicate chroot environment has been set up -sudo touch ${CHROOT_DIR}/.chroot_is_done - -# Call standard before_install_linux in chroot environment -sudo chroot ${CHROOT_DIR} bash -c "cd ${TRAVIS_BUILD_DIR} && pwd && ./CI/travis/before_install_linux" - diff --git a/CMakeLists.txt b/CMakeLists.txt index 5f4af4dc8..815135337 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -162,6 +162,7 @@ include(CheckSymbolExists) check_symbol_exists(strdup "string.h" HAS_STRDUP) check_symbol_exists(strndup "string.h" HAS_STRNDUP) check_symbol_exists(strerror_r "string.h" HAS_STRERROR_R) +check_symbol_exists(strtok_r "string.h" HAS_STRTOK_R) check_symbol_exists(newlocale "locale.h" HAS_NEWLOCALE) option(ENABLE_IPV6 "Define if you want to enable IPv6 support" ON) @@ -181,6 +182,7 @@ if (WITH_USB_BACKEND) message(SEND_ERROR "Unable to find libusb-1.0 dependency.\n" "If you want to disable the USB backend, set WITH_USB_BACKEND=OFF.") else() + list(APPEND LIBIIO_SCAN_BACKENDS usb) set(IIOD_CLIENT 1) set(NEED_LIBXML2 1) set(NEED_THREADS 1) @@ -218,8 +220,12 @@ endif() # make sure all check_symbol_exists are before this point, otherwise they fail # on some versions of compilers if (MSVC) - if(DEFINED ENV{CI} AND DEFINED ENV{APPVEYOR}) - message(STATUS "Running in an AppVeyor environment, setting -Werror") + # why can't different CIs use the same flags? + # Travis CI : CI=True & TRAVIS=True + # Appveyor : CI=True & APPVEYOR=True + # Azure Pipelines: TF_BUILD=True + if(DEFINED ENV{TF_BUILD} OR (DEFINED ENV{CI} AND DEFINED ENV{APPVEYOR})) + message(STATUS "Running in an Azure or AppVeyor environment, setting -Werror") target_compile_options(iio PRIVATE /WX) endif() elseif (CMAKE_C_COMPILER_ID MATCHES "GNU|Clang") @@ -231,10 +237,13 @@ elseif (CMAKE_C_COMPILER_ID MATCHES "GNU|Clang") SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage") SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fprofile-arcs -ftest-coverage") endif() - if(DEFINED ENV{CI} AND (DEFINED ENV{TRAVIS} OR DEFINED ENV{APPVEYOR})) - message(STATUS "Running in CI environment (Travis or AppVeyor), setting -Werror") + if(DEFINED ENV{TF_BUILD} OR (DEFINED ENV{CI} AND (DEFINED ENV{TRAVIS} OR DEFINED ENV{APPVEYOR}))) + message(STATUS "Running in CI environment (Azure, Travis or AppVeyor), setting -Werror") target_compile_options(iio PRIVATE -Werror) endif() +else() + message(STATUS "Unknown compiler ${CMAKE_C_COMPILER_ID}") + message(STATUS "GCC ${CMAKE_COMPILER_IS_GNUCC}") endif() IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux") @@ -291,7 +300,10 @@ if(WITH_LOCAL_BACKEND) target_sources(iio PRIVATE libini/libini.c) endif() + option(WITH_LOCAL_MMAP_API "Use the mmap API provided in Analog Devices' kernel (not upstream)" ON) option(WITH_HWMON "Add compatibility with the hardware monitoring (hwmon) subsystem" OFF) + + list(APPEND LIBIIO_SCAN_BACKENDS local) endif() option(WITH_SERIAL_BACKEND "Enable the serial backend" OFF) @@ -413,6 +425,10 @@ if(WITH_NETWORK_BACKEND) set(HAVE_AVAHI ON) endif() + if (HAVE_DNS_SD) + list(APPEND LIBIIO_SCAN_BACKENDS ip) + endif() + set(NEED_THREADS 1) set(IIOD_CLIENT 1) set(NEED_LIBXML2 1) @@ -506,6 +522,8 @@ add_subdirectory(man) include(cmake/Install.cmake) +string(REPLACE ";" "," LIBIIO_SCAN_BACKENDS "${LIBIIO_SCAN_BACKENDS}") + configure_file(iio-config.h.cmakein ${CMAKE_CURRENT_BINARY_DIR}/iio-config.h @ONLY) list(APPEND IIO_FEATURES_${WITH_XML_BACKEND} xml) @@ -517,6 +535,7 @@ list(APPEND IIO_FEATURES_${HAVE_BONJOUR} bonjour) list(APPEND IIO_FEATURES_${ENABLE_IPV6} ipv6) list(APPEND IIO_FEATURES_${WITH_SERIAL_BACKEND} serial) list(APPEND IIO_FEATURES_${WITH_LOCAL_BACKEND} local) +list(APPEND IIO_FEATURES_${WITH_LOCAL_MMAP_API} local-mmap) list(APPEND IIO_FEATURES_${WITH_HWMON} hwmon) list(APPEND IIO_FEATURES_${WITH_USB_BACKEND} usb) list(APPEND IIO_FEATURES_${WITH_TESTS} utils) diff --git a/README.md b/README.md index 0f69ff3be..2f3582307 100644 --- a/README.md +++ b/README.md @@ -25,17 +25,18 @@ As with many open source packages, we use [GitHub](https://github.com/analogdevi | Operating System | GitHub master status | Version | Primary Installer Package | Alternative Package, tarball or zip | |:-----------------------:|:---------------------:|:-------:|:-------------------:|:--------------:| -| Windows | [![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=Builds&jobName=WindowsBuilds&configuration=WindowsBuilds%20VS2019_Win64)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | Windows-64 Server 2019 | [![Latest Windows installer](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/win_box.png)](https://swdownloads.analog.com/cse/azure_builds/libiio-setup.exe)
[![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=PushArtifacts&jobName=GenerateSetupExe)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | [![Latest Windows zip](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/win_box.png)](https://swdownloads.analog.com/cse/azure_builds/Windows-VS-16-2019-x64.zip) | -| | [![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=Builds&jobName=WindowsBuilds&configuration=WindowsBuilds%20VS2019_Win32)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | Windows-32 Server 2019 | (libiio-setup.exe file works for both Win64 and Win32) | [![Latest Windows zip](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/win_box.png)](https://swdownloads.analog.com/cse/azure_builds/Windows-VS-16-2019-Win32.zip) | +| Windows | [![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=Builds&jobName=WindowsBuilds&configuration=WindowsBuilds%20VS2019)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | Windows-64 Server 2019 | [![Latest Windows installer](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/win_box.png)](https://swdownloads.analog.com/cse/azure_builds/libiio-setup.exe)
[![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=ManageArtifacts&jobName=GenerateSetupExe)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | [![Latest Windows zip](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/win_box.png)](https://swdownloads.analog.com/cse/azure_builds/Windows-VS-2019-x64-latest_master_libiio.zip) | +| | [![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=Builds&jobName=WindowsBuilds&configuration=WindowsBuilds%20VS2022)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | Windows-64 Server 2022 | (libiio-setup.exe works for both Windows Server 2019 and Windows Server 2022) | [![Latest Windows zip](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/win_box.png)](https://swdownloads.analog.com/cse/azure_builds/Windows-VS-2022-x64-latest_master_libiio.zip) | | OS X | [![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=Builds&jobName=macOSBuilds&configuration=macOSBuilds%20macOS_11)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | macOS Big Sur
(v 11) | [![OS-X package 11](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/osx_box.png)](https://swdownloads.analog.com/cse/azure_builds/macOS-11_latest_master_libiio.pkg) | [![OS-X tarball 11](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/osx_box.png)](https://swdownloads.analog.com/cse/azure_builds/macOS-11_latest_master_libiio.tar.gz) | -| | [![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=Builds&jobName=macOSBuilds&configuration=macOSBuilds%20macOS_10_15)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | macOS Catalina
(v 10.15) | [![OS-X package 10.13](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/osx_box.png)](https://swdownloads.analog.com/cse/azure_builds/macOS-10.15_latest_master_libiio.pkg) | [![OS-X tarball 10.13](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/osx_box.png)](https://swdownloads.analog.com/cse/azure_builds/macOS-10.15_latest_master_libiio.tar.gz) | -| Linux | [![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=Builds&jobName=LinuxBuilds&configuration=LinuxBuilds%20ubuntu_20_04_x86_64)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | Ubuntu Focal Fossa
(v 20.04)1 | [![Debian](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/deb.png)](https://swdownloads.analog.com/cse/azure_builds/Ubuntu-20.04-x86_64_latest_master_libiio.deb) | [![RPM File](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/rpm.png)](https://swdownloads.analog.com/cse/azure_builds/Ubuntu-20.04-x86_64_latest_master_libiio.rpm) | -| | [![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=Builds&jobName=LinuxBuilds&configuration=LinuxBuilds%20ubuntu_18_04_x86_64)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | Ubuntu Bionic Beaver
(v 18.04)1 | [![Debian](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/deb.png)](https://swdownloads.analog.com/cse/azure_builds/Ubuntu-18.04-x86_64_latest_master_libiio.deb) | [![RPM File](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/rpm.png)](https://swdownloads.analog.com/cse/azure_builds/Ubuntu-18.04-x86_64_latest_master_libiio.rpm) | -| | [![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=Builds&jobName=LinuxBuilds&configuration=LinuxBuilds%20ubuntu_16_04_x86_64)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | Ubuntu Xenial Xerus
(v 16.04)1 | [![Debian](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/deb.png)](https://swdownloads.analog.com/cse/azure_builds/Ubuntu-16.04-x86_64_latest_master_libiio.deb) | [![RPM File](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/rpm.png)](https://swdownloads.analog.com/cse/azure_builds/Ubuntu-16.04-x86_64_latest_master_libiio.rpm) | -| | [![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=Builds&jobName=LinuxBuilds&configuration=LinuxBuilds%20debian_buster_arm32v7)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | Debian Buster ARM | [![Debian](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/deb.png)](https://swdownloads.analog.com/cse/azure_builds/Debian-Buster-ARM_latest_master_libiio.deb) | [![RPM File](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/rpm.png)](https://swdownloads.analog.com/cse/azure_builds/Debian-Buster-ARM_latest_master_libiio.rpm) | -| | [![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=Builds&jobName=LinuxBuilds&configuration=LinuxBuilds%20debian_buster_arm64v8)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | Debian Buster ARM64 | [![Debian](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/deb.png)](https://swdownloads.analog.com/cse/azure_builds/Debian-Buster-ARM64_latest_master_libiio.deb) | [![RPM File](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/rpm.png)](https://swdownloads.analog.com/cse/azure_builds/Debian-Buster-ARM64_latest_master_libiio.rpm) | -| | [![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=Builds&jobName=LinuxBuilds&configuration=LinuxBuilds%20centos_8_x86_64)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | CentOS 8 | [![RPM File](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/rpm.png)](https://swdownloads.analog.com/cse/azure_builds/CentOS-8-x86_64_latest_master_libiio.rpm) | [![Debian](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/deb.png)](https://swdownloads.analog.com/cse/azure_builds/CentOS-8-x86_64_latest_master_libiio.deb) | -| | [![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=Builds&jobName=LinuxBuilds&configuration=LinuxBuilds%20centos_7_x86_64)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | CentOS 7 | [![RPM File](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/rpm.png)](https://swdownloads.analog.com/cse/azure_builds/CentOS-7-x86_64_latest_master_libiio.rpm) | [![Debian](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/deb.png)](https://swdownloads.analog.com/cse/azure_builds/CentOS-7-x86_64_latest_master_libiio.deb) | +| | [![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=Builds&jobName=macOSBuilds&configuration=macOSBuilds%20macOS_10_15)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | macOS Catalina
(v 10.15) | [![OS-X package 10.15](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/osx_box.png)](https://swdownloads.analog.com/cse/azure_builds/macOS-10.15_latest_master_libiio.pkg) | [![OS-X tarball 10.15](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/osx_box.png)](https://swdownloads.analog.com/cse/azure_builds/macOS-10.15_latest_master_libiio.tar.gz) | +| Linux | [![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=Builds&jobName=LinuxBuilds&configuration=LinuxBuilds%20ubuntu_20_04)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | Ubuntu Focal Fossa
(v 20.04)1 | [![Debian](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/deb.png)](https://swdownloads.analog.com/cse/azure_builds/Ubuntu-20.04_latest_master_libiio.deb) | | +| | [![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=Builds&jobName=LinuxBuilds&configuration=LinuxBuilds%20ubuntu_18_04)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | Ubuntu Bionic Beaver
(v 18.04)1 | [![Debian](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/deb.png)](https://swdownloads.analog.com/cse/azure_builds/Ubuntu-18.04_latest_master_libiio.deb) | | +| | [![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=Builds&jobName=LinuxBuilds&configuration=LinuxBuilds%20fedora34)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | Fedora 34 | [![Debian](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/deb.png)](https://swdownloads.analog.com/cse/azure_builds/Fedora-34_latest_master_libiio.deb) | [![RPM File](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/rpm.png)](https://swdownloads.analog.com/cse/azure_builds/Fedora-34_latest_master_libiio.rpm) | +| ARM | [![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=Builds&jobName=ARMBuilds&configuration=ARMBuilds%20ubuntu-ppc64le)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | Ubuntu-ppc64le | [![Debian](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/deb.png)](https://swdownloads.analog.com/cse/azure_builds/Ubuntu-ppc64le_latest_master_libiio.deb) | | +| | [![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=Builds&jobName=ARMBuilds&configuration=ARMBuilds%20ubuntu-x390x)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | Ubuntu-x390x | [![Debian](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/deb.png)](https://swdownloads.analog.com/cse/azure_builds/Ubuntu-x390x_latest_master_libiio.deb) | | +| | [![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=Builds&jobName=ARMBuilds&configuration=ARMBuilds%20ubuntu-arm64v8)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | Ubuntu-arm64v8 | [![Debian](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/deb.png)](https://swdownloads.analog.com/cse/azure_builds/Ubuntu-arm64v8_latest_master_libiio.deb) | | +| | [![Build Status](https://dev.azure.com/AnalogDevices/OpenSource/_apis/build/status/analogdevicesinc.libiio?branchName=master&stageName=Builds&jobName=ARMBuilds&configuration=ARMBuilds%20ubuntu-arm32v7)](https://dev.azure.com/AnalogDevices/OpenSource/_build/latest?definitionId=9&branchName=master) | Ubuntu-arm32v7 | [![Debian](https://raw.githubusercontent.com/wiki/analogdevicesinc/libiio/img/deb.png)](https://swdownloads.analog.com/cse/azure_builds/Ubuntu-arm32v7_latest_master_libiio.deb) | | + If you use it, and like it - please let us know. If you use it, and hate it - please let us know that too. The goal of the project is to try to make Linux IIO devices easier to use on a variety of platforms. If we aren't doing that - we will try to make it better. diff --git a/README_BUILD.md b/README_BUILD.md index d92ccfde2..1c69ace2e 100644 --- a/README_BUILD.md +++ b/README_BUILD.md @@ -11,7 +11,7 @@ Install Prerequisites ```shell analog@precision:~$ sudo apt-get install libxml2-dev bison flex libcdk5-dev cmake ``` -Install Backends +Install libraries for Backends ```shell analog@precision:~$ sudo apt-get install libaio-dev libusb-1.0-0-dev analog@precision:~$ sudo apt-get install libserialport-dev libavahi-client-dev @@ -24,12 +24,7 @@ Install to build python backends ```shell analog@precision:~$ sudo apt-get install python3 python3-pip python3-setuptools ``` -Install to Read local context attributes from `/etc/libiio.ini` -```shell -analog@precision:~$ git clone https://github.com/pcercuei/libini.git -analog@precision:~$ cd libini -analog@precision:~/libini$ mkdir build && cd build && cmake ../ && make && sudo make install -``` + ## Clone ```shell analog@precision:~$ git clone https://github.com/analogdevicesinc/libiio.git @@ -42,26 +37,61 @@ when configuring libiio with cmake, there are a few optional settings that you c Cmake Options | Default | Description | ------------------- | ------- | ---------------------------------------------- | +`BUILD_SHARED_LIBS` | ON | Build shared libraries | +`CMAKE_INSTALL_PREFIX` | `/usr` | default install path | +`ENABLE_PACKAGING` | OFF | Create .deb/.rpm or .tar.gz packages via 'make package' | `CSHARP_BINDINGS` | OFF | Install C# bindings | `PYTHON_BINDINGS` | OFF | Install PYTHON bindings | `WITH_DOC` | OFF | Generate documentation with Doxygen and Sphinx | `WITH_MAN` | OFF | Generate and install man pages | -`WITH_TESTS` | ON | Build the test programs | +`WITH_TESTS` | ON | Build the test programs (iio-utils) | +`INSTALL_UDEV_RULE` | ON | Install a Linux udev rule for detection of USB devices | +`UDEV_RULES_INSTALL_DIR` | /lib/udev/rules.d | default install path for udev rules | +`WITH_EXAMPLES` | OFF | Build the example programs | `WITH_LOCAL_CONFIG` | ON | Read local context attributes from /etc/libiio.ini | `WITH_HWMON` | OFF | Add compatibility with the hwmon subsystem | -`ENABLE_PACKAGING` | OFF | Create .deb/.rpm/.tar.gz via 'make package' | -`INSTALL_UDEV_RULE` | ON | Install a udev rule for detection of USB devices | +`NO_THREADS` | OFF | Disable multi-threading support | +`WITH_GCOV` | OFF | Build with gcov profiling flags | Which backends the library supports is dependent on the build system, but can be overridden. (If cmake finds libusb, it will use it, unless turned off manually) -Cmake Options | Depends on | Description | ----------------------- | ------------- | ------------------------------- | -`WITH_XML_BACKEND` | libxml2 | Enable the XML backend | -`WITH_USB_BACKEND` | libusb | Enable the libusb backend | -`WITH_SERIAL_BACKEND` | libserialport | Enable the Serial backend | -`WITH_NETWORK_BACKEND` | | Supports TCP/IP | -`WITH_LOCAL_BACKEND` | Linux | Enables local support with iiod | +Cmake Options | Default | Depends on | Description | +---------------------- | ------- | ------------- | ------------------------------- | +`WITH_XML_BACKEND` | ON | libxml2 | Enable the XML backend, required when using network, serial, or USB backend | +`WITH_USB_BACKEND` | ON | libusb | Enable the libusb backend | +`WITH_SERIAL_BACKEND` | OFF | libserialport | Enable the Serial backend | +`WITH_NETWORK_BACKEND` | ON | | Supports TCP/IP | +`HAVE_DNS_SD` | ON | Networking | Enable DNS-SD (ZeroConf) support | +`ENABLE_IPV6` | ON | Networking | Define if you want to enable IPv6 support | +`WITH_LOCAL_BACKEND` | ON | Linux | Enables local support with iiod | +`WITH_LOCAL_CONFIG` | ON | Local backend | Read local context attributes from /etc/libiio.ini | + + +There are a few options, which are experimental, which should be left to their default settings: + +Cmake Options | Default | Description | +------------------- | ------- | ---------------------------------------------- | +`WITH_LOCAL_MMAP_API` | ON | Use the mmap API provided in Analog Devices' kernel (not upstream) | +`WITH_NETWORK_GET_BUFFER` | OFF | Enable experimental zero-copy transfers | +`WITH_ZSTD` | OFF | Support for ZSTD compressed metadata | + + +Options which effect iiod only. These are only avalible on Linux. + +Cmake Options | Default | Description | +------------------- | ------- | ---------------------------------------------- | +`WITH_IIOD` | ON | Build the IIO Daemon | +`WITH_IIOD_SERIAL` | ON | Add serial (UART) support | +`WITH_IIOD_USBD` | ON | Add support for USB through FunctionFS within IIOD | +`WITH_AIO` | ON | Build IIOD with async. I/O support | +`WITH_SYSTEMD` | OFF | Enable installation of systemd service file for iiod | +`SYSTEMD_UNIT_INSTALL_DIR` | /lib/systemd/system | default install path for systemd unit files | +`WITH_SYSVINIT` | OFF | Enable installation of SysVinit script for iiod | +`SYSVINIT_INSTALL_DIR` | /etc/init.d | default install path for SysVinit scripts | +`WITH_UPSTART` | OFF | Enable installation of upstart config file for iiod | +`UPSTART_CONF_INSTALL_DIR`: | /etc/init | default install path for upstart conf files | + ```shell @@ -80,3 +110,16 @@ Note: Some things (specifically building doc) need to find libiio or the bindin That means that you configure (with -DWITH_DOC=OFF), build, install, configure (with -DWITH_DOC=ON), build again to get the doc. If you have issues, please ask. + +## Notes + +Special Note on Microsoft Visual Compiler (MSVC): + +MSVC in debug mode is just very stupid. If it sees this code: +```c +if (0) + call_function(); +``` +It will try to link against the `call_function` symbol even though it's clearly dead code. + +For this reason, when building with MSVC, please build in `RelWithDebInfo` mode. If you try to build in `Debug` mode, it will error. diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index bd8144253..000000000 --- a/appveyor.yml +++ /dev/null @@ -1,184 +0,0 @@ -version: '{branch}.{build}' -clone_depth: 1 - -skip_commits: - message: /(iiod|IIOD):.*/ - -environment: - # Tell msys2 to add mingw64 to the path - MSYSTEM: MINGW64 - # Tell msys2 to inherit the current directory when starting the shell - CHERE_INVOKING: 1 - -configuration: - - Release - -install: - - echo "Checking out sub-modules..." - - git submodule update --init - - echo "Downloading deps..." - - cd C:\ - - appveyor DownloadFile http://swdownloads.analog.com/cse/build/libiio-win-deps.zip - - 7z x -y "C:\libiio-win-deps.zip" - #Install Inno Setup - - choco install InnoSetup - - set PATH=%PATH%;"C:\Program Files (x86)\Inno Setup 5" - -build_script: - - set OLD_PATH=%PATH% - - set OPT_PATH=C:\msys64\mingw32\bin;C:\msys64\mingw64\bin; - - set PATH=%OPT_PATH%%PATH% - - set GENERATOR=Unix Makefiles - - set MINGW_TOOLCHAIN_VERSION=10.0.0-3 - - set DOXYGEN_VERSION=1.8.18-1 - - set GRAPHVIZ_VERSION=2.40.1-13 - - cd C:\projects\libiio - - set folder-path=C:\projects\libiio\build-mingw-win32\%configuration% - # MinGW 32 bit - - echo "Running cmake for MinGW 32 bit... " - - mkdir C:\projects\libiio\build-mingw-win32 - - cd C:\projects\libiio\build-mingw-win32 - - C:\msys64\usr\bin\bash -lc "pwd" - - mkdir C:\projects\libiio\build-mingw-win32\"%configuration%"& cd C:\projects\libiio\build-mingw-win32\"%configuration%" - - C:\msys64\usr\bin\bash -lc "pwd" - # TODO: Revert this after appveyor supports the latest installer. - - C:\msys64\usr\bin\bash -lc "pacman --noconfirm -U http://repo.msys2.org/msys/x86_64/pacman-5.2.2-1-x86_64.pkg.tar.xz" - - C:\msys64\usr\bin\bash -lc "curl -O http://repo.msys2.org/msys/x86_64/msys2-keyring-r21.b39fb11-1-any.pkg.tar.xz" - - C:\msys64\usr\bin\bash -lc "curl -O http://repo.msys2.org/msys/x86_64/msys2-keyring-r21.b39fb11-1-any.pkg.tar.xz.sig" - - C:\msys64\usr\bin\bash -lc "pacman-key --verify msys2-keyring-r21.b39fb11-1-any.pkg.tar.xz{.sig,}" - - C:\msys64\usr\bin\bash -lc "pacman-key --populate" - - C:\msys64\usr\bin\bash -lc "pacman --noconfirm -U msys2-keyring-r21.b39fb11-1-any.pkg.tar.xz" - - C:\msys64\usr\bin\bash -lc "pacman --noconfirm -Syu" - - C:\msys64\usr\bin\bash -lc "pacman -Rs --noconfirm mingw-w64-i686-gcc-ada mingw-w64-i686-gcc-fortran mingw-w64-i686-gcc-libgfortran mingw-w64-i686-gcc-objc" - - C:\msys64\usr\bin\bash -lc "rm /mingw32/etc/gdbinit" - - C:\msys64\usr\bin\bash -lc "pacman --noconfirm -Sy mingw-w64-i686-gcc mingw-w64-i686-libusb mingw-w64-i686-curl mingw-w64-i686-cmake mingw-w64-i686-libxml2 mingw-w64-i686-pkg-config mingw-w64-i686-libzip" - # Newer llvm breaks doxygen, use old version for now - - C:\msys64\usr\bin\bash -lc "pacman -U --noconfirm http://repo.msys2.org/mingw/i686/mingw-w64-i686-llvm-%MINGW_TOOLCHAIN_VERSION%-any.pkg.tar.zst http://repo.msys2.org/mingw/i686/mingw-w64-i686-clang-%MINGW_TOOLCHAIN_VERSION%-any.pkg.tar.zst" - # set the specific version of doxygen (06-Jun-2018), need to look at this later. - - C:\msys64\usr\bin\bash -lc "pacman -U --noconfirm http://repo.msys2.org/mingw/i686/mingw-w64-i686-doxygen-%DOXYGEN_VERSION%-any.pkg.tar.zst" - - C:\msys64\usr\bin\bash -lc "pacman -U --noconfirm http://repo.msys2.org/mingw/i686/mingw-w64-i686-graphviz-%GRAPHVIZ_VERSION%-any.pkg.tar.zst" - # Download a 32-bit version of windres.exe - - appveyor DownloadFile http://swdownloads.analog.com/cse/build/windres.exe.gz -FileName C:\windres.exe.gz - - C:\msys64\usr\bin\bash -lc "cd /c ; gunzip windres.exe.gz" - - C:\msys64\usr\bin\bash -lc "cmake -G '%GENERATOR%' -DCMAKE_RC_COMPILER=/c/windres.exe -DGIT_EXECUTABLE=C:/Program\ Files/Git/cmd/git.exe -DCMAKE_BUILD_TYPE=%configuration% -DCMAKE_INSTALL_PREFIX=/mingw32 -DCMAKE_C_COMPILER:FILEPATH=/mingw32/bin/i686-w64-mingw32-gcc.exe -DCMAKE_CXX_COMPILER:FILEPATH=/mingw32/bin/i686-w64-mingw32-g++.exe -DPKG_CONFIG_EXECUTABLE:FILEPATH=/mingw32/bin/pkg-config.exe -DENABLE_IPV6:BOOL=OFF -DLIBSERIALPORT_LIBRARIES=/c/libs/32/libserialport.dll.a -DLIBSERIALPORT_INCLUDE_DIR=/c/include -DLIBLZMA_LIBRARY=c:/msys64/mingw32/lib/liblzma.dll.a /c/projects/libiio && make -j3" - - # MinGW 64 bit - - cd c:\projects\libiio - - echo "Running cmake for MinGW 64 bit... " - - mkdir c:\projects\libiio\build-mingw-win64 - - cd c:\projects\libiio\build-mingw-win64 - - mkdir c:\projects\libiio\build-mingw-win64\"%configuration%"& cd c:\projects\libiio\build-mingw-win64\"%configuration%" - - C:\msys64\usr\bin\bash -lc "pwd" - - C:\msys64\usr\bin\bash -lc "pacman -Rs --noconfirm mingw-w64-x86_64-gcc-ada mingw-w64-x86_64-gcc-fortran mingw-w64-x86_64-gcc-libgfortran mingw-w64-x86_64-gcc-objc" - - C:\msys64\usr\bin\bash -lc "rm /mingw64/etc/gdbinit" - - C:\msys64\usr\bin\bash -lc "pacman --noconfirm -Sy mingw-w64-x86_64-gcc mingw-w64-x86_64-libusb mingw-w64-x86_64-curl mingw-w64-x86_64-cmake mingw-w64-x86_64-libxml2 mingw-w64-x86_64-pkg-config mingw-w64-x86_64-libzip" - - C:\msys64\usr\bin\bash -lc "pacman --noconfirm -Sy pacman" - - C:\msys64\usr\bin\bash -lc "pacman --noconfirm -Su" - # Newer llvm breaks doxygen, use old version for now - - C:\msys64\usr\bin\bash -lc "pacman -U --noconfirm http://repo.msys2.org/mingw/x86_64/mingw-w64-x86_64-llvm-%MINGW_TOOLCHAIN_VERSION%-any.pkg.tar.zst http://repo.msys2.org/mingw/x86_64/mingw-w64-x86_64-clang-%MINGW_TOOLCHAIN_VERSION%-any.pkg.tar.zst" - # set the specific version of doxygen, need to look at this later. - - C:\msys64\usr\bin\bash -lc "pacman -U --noconfirm http://repo.msys2.org/mingw/x86_64/mingw-w64-x86_64-doxygen-%DOXYGEN_VERSION%-any.pkg.tar.zst" - - C:\msys64\usr\bin\bash -lc "pacman -U --noconfirm http://repo.msys2.org/mingw/x86_64/mingw-w64-x86_64-graphviz-%GRAPHVIZ_VERSION%-any.pkg.tar.zst" - - C:\msys64\usr\bin\bash -lc "cmake -G '%GENERATOR%' -DCMAKE_RC_COMPILER=/c/msys64/mingw64/bin/windres.exe -DCMAKE_BUILD_TYPE=%configuration% -DCMAKE_INSTALL_PREFIX=/mingw64 -DCMAKE_C_COMPILER:FILEPATH=/mingw64/bin/x86_64-w64-mingw32-gcc.exe -DCMAKE_CXX_COMPILER:FILEPATH=/mingw64/bin/x86_64-w64-mingw32-g++.exe -DPKG_CONFIG_EXECUTABLE:FILEPATH=/mingw64/bin/pkg-config.exe -DENABLE_IPV6:BOOL=OFF -DLIBSERIALPORT_LIBRARIES=/c/libs/64/libserialport.dll.a -DLIBSERIALPORT_INCLUDE_DIR=/c/include /c/projects/libiio && make -j3" - - # Move the tests folder - - cd c:\projects\libiio - - mkdir build-mingw-win32\tests\ build-mingw-win32\tests\"%configuration%"& copy build-mingw-win32\Release\tests\*.exe build-mingw-win32\tests\"%configuration%"\ - - mkdir build-mingw-win64\tests\ build-mingw-win64\tests\"%configuration%"& copy build-mingw-win64\Release\tests\*.exe build-mingw-win64\tests\"%configuration%"\ - - - set PATH=%OLD_PATH% - - set GENERATOR=Visual Studio 12 - - cd c:\projects\libiio - - set folder-path=c:\projects\libiio\build-win32 - - #MSVC 32 bit - - set PATH=C:\\Python37;C:\\Python37\\libs;%PATH% - - echo "Running cmake for Visual Studio 32 bit... " - - mkdir build-win32 - - cd build-win32 - - set MCS_EXECUTABLE_PATH="C:\Windows\Microsoft.NET\Framework\v4.0.30319" - - cmake -G "%GENERATOR%" -DCMAKE_BUILD_TYPE:STRING="%configuration%" -DENABLE_IPV6:BOOL=OFF -DCMAKE_SYSTEM_PREFIX_PATH="C:" -DCSHARP_BINDINGS:BOOL=ON -DPYTHON_BINDINGS:BOOL=ON -DLIBXML2_LIBRARIES="C:\\libs\\32\\libxml2.lib" -DLIBUSB_LIBRARIES="C:\\libs\\32\\libusb-1.0.lib" -DLIBSERIALPORT_LIBRARIES="C:\\libs\\32\\libserialport.dll.a" .. - - cmake --build . --config %configuration% - - - cd bindings/python - - python.exe setup.py sdist - - ps: Get-ChildItem dist\libiio-*.tar.gz | Rename-Item -NewName "libiio-py37-win32.tar.gz" - - ps: cp dist\*.tar.gz . - - ps: rm dist\*.tar.gz - - set PATH=C:\\Python36;C:\\Python36\\libs;%PATH% - - python.exe setup.py sdist - - ps: Get-ChildItem dist\libiio-*.tar.gz | Rename-Item -NewName "libiio-py36-win32.tar.gz" - - ps: cp dist\*.tar.gz . - - ps: rm dist\*.tar.gz - - #MSVC 64 bit - - set PATH=C:\Python37-x64;C:\\Python37-x64\\libs;%PATH% - - cd c:\projects\libiio - - echo "Running cmake for Visual Studio 64 bit... " - - mkdir build-win64 - - cd build-win64 - - cmake -G "%GENERATOR% Win64" -DCMAKE_BUILD_TYPE:STRING="%configuration%" -DENABLE_IPV6:BOOL=OFF -DCMAKE_SYSTEM_PREFIX_PATH="C:" -DCSHARP_BINDINGS:BOOL=ON -DPYTHON_BINDINGS:BOOL=ON -DLIBXML2_LIBRARIES="C:\\libs\\64\\libxml2.lib" -DLIBUSB_LIBRARIES="C:\\libs\\64\\libusb-1.0.lib" -DLIBSERIALPORT_LIBRARIES="C:\\libs\\64\\libserialport.dll.a" .. - - cmake --build . --config %configuration% - - - cd bindings/python - - python.exe setup.py sdist - - ps: Get-ChildItem dist\libiio-*.tar.gz | Rename-Item -NewName "libiio-py37-amd64.tar.gz" - - ps: cp dist\*.tar.gz . - - ps: rm dist\*.tar.gz - - set PATH=C:\Python36-x64;C:\\Python36-x64\\libs;%PATH% - - python.exe setup.py sdist - - ps: Get-ChildItem dist\libiio-*.tar.gz | Rename-Item -NewName "libiio-py36-amd64.tar.gz" - - ps: cp dist\*.tar.gz . - - ps: rm dist\*.tar.gz - - cd c:\projects\libiio\build-win64 - - #Create the installer - - ISCC %folder-path%\libiio.iss - - appveyor PushArtifact C:\libiio-setup.exe - - # Create ZIP package - # set LIBIIO_VERSION to current project version determined by cmake - - ps: >- - Set-AppveyorBuildVariable -Name LIBIIO_VERSION -Value (get-content .version) - - set ARCHIVE_NAME=libiio-%LIBIIO_VERSION% - - cd c:\projects\libiio - - mkdir c:\%ARCHIVE_NAME% c:\%ARCHIVE_NAME%\include c:\%ARCHIVE_NAME%\MS32 c:\%ARCHIVE_NAME%\MS64 c:\%ARCHIVE_NAME%\MinGW32 c:\%ARCHIVE_NAME%\MinGW64 - - copy iio.h c:\%ARCHIVE_NAME%\include - - copy build-win32\Release\libiio.* c:\%ARCHIVE_NAME%\MS32 - - copy build-win64\Release\libiio.* c:\%ARCHIVE_NAME%\MS64 - - copy build-win32\bindings\csharp\libiio-sharp.dll c:\%ARCHIVE_NAME%\MS32 - - copy build-win64\bindings\csharp\libiio-sharp.dll c:\%ARCHIVE_NAME%\MS64 - - copy build-win32\bindings\python\*.tar.gz c:\%ARCHIVE_NAME%\MS32 - - copy build-win64\bindings\python\*.tar.gz c:\%ARCHIVE_NAME%\MS64 - - copy build-mingw-win32\Release\libiio.* c:\%ARCHIVE_NAME%\MinGW32 - - copy build-mingw-win64\Release\libiio.* c:\%ARCHIVE_NAME%\MinGW64 - - del c:\%ARCHIVE_NAME%\MinGW32\libiio.iss - - del c:\%ARCHIVE_NAME%\MinGW64\libiio.iss - - del c:\%ARCHIVE_NAME%\MinGW32\libiio.pc - - del c:\%ARCHIVE_NAME%\MinGW64\libiio.pc - - - copy build-win32\tests\Release\*.exe c:\%ARCHIVE_NAME%\MS32 - - copy build-win64\tests\Release\*.exe c:\%ARCHIVE_NAME%\MS64 - - copy build-mingw-win32\tests\Release\*.exe c:\%ARCHIVE_NAME%\MinGW32 - - copy build-mingw-win64\tests\Release\*.exe c:\%ARCHIVE_NAME%\MinGW64 - - #Copy dependencies for MSVC - - copy c:\libs\32\libxml2.dll c:\%ARCHIVE_NAME%\MS32 - - copy c:\libs\64\libxml2.dll c:\%ARCHIVE_NAME%\MS64 - - copy c:\libs\32\libusb-1.0.dll c:\%ARCHIVE_NAME%\MS32 - - copy c:\libs\64\libusb-1.0.dll c:\%ARCHIVE_NAME%\MS64 - - copy c:\libs\32\libserialport-0.dll c:\%ARCHIVE_NAME%\MS32 - - copy c:\libs\64\libserialport-0.dll c:\%ARCHIVE_NAME%\MS64 - - #Copy dependencies for MinGW - - C:\msys64\usr\bin\bash -lc "cd c:/msys64/mingw32/bin ; cp -r libwinpthread-*.dll libgcc_*.dll libstdc++-*.dll libiconv-*.dll zlib*.dll libxml2-*.dll liblzma-*.dll libzip*.dll libusb-*.dll /c/%ARCHIVE_NAME%/MinGW32" - - C:\msys64\usr\bin\bash -lc "cd c:/msys64/mingw64/bin ; cp -r libwinpthread-*.dll libgcc_*.dll libstdc++-*.dll libiconv-*.dll zlib*.dll libxml2-*.dll liblzma-*.dll libzip*.dll libusb-*.dll /c/%ARCHIVE_NAME%/MinGW64" - - C:\msys64\usr\bin\bash -lc "cd c:/libs/32 ; cp libserialport-*.dll /c/%ARCHIVE_NAME%/MinGW32" - - C:\msys64\usr\bin\bash -lc "cd c:/libs/64 ; cp libserialport-*.dll /c/%ARCHIVE_NAME%/MinGW64" - - - copy "c:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\redist\x86\Microsoft.VC120.CRT\msvcr120.dll" c:\%ARCHIVE_NAME%\MS32 - - copy "c:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\redist\x64\Microsoft.VC120.CRT\msvcr120.dll" c:\%ARCHIVE_NAME%\MS64 - - - copy c:\projects\libiio\CI\travis\zip.txt c:\%ARCHIVE_NAME%\README.txt - - 7z a "c:\libiio.zip" c:\%ARCHIVE_NAME% - - appveyor PushArtifact c:\libiio.zip diff --git a/artifact_manifest.txt.cmakein b/artifact_manifest.txt.cmakein new file mode 100644 index 000000000..65d67085b --- /dev/null +++ b/artifact_manifest.txt.cmakein @@ -0,0 +1,67 @@ +Libiio-Setup-Exe/libiio-setup.exe + +Linux-Fedora-34/libiio-@VERSION@.g@LIBIIO_VERSION_GIT@-Linux-Fedora-34.deb +Linux-Fedora-34/libiio-@VERSION@.g@LIBIIO_VERSION_GIT@-Linux-Fedora-34.rpm +Linux-Fedora-34/libiio-@VERSION@.g@LIBIIO_VERSION_GIT@-Linux-Fedora-34.tar.gz + +Linux-Ubuntu-18.04/libiio-@VERSION@.g@LIBIIO_VERSION_GIT@-Linux-Ubuntu-18.04.deb +Linux-Ubuntu-18.04/libiio-@VERSION@.g@LIBIIO_VERSION_GIT@-Linux-Ubuntu-18.04.tar.gz + +Linux-Ubuntu-20.04/libiio-@VERSION@.g@LIBIIO_VERSION_GIT@-Linux-Ubuntu-20.04.deb +Linux-Ubuntu-20.04/libiio-@VERSION@.g@LIBIIO_VERSION_GIT@-Linux-Ubuntu-20.04.tar.gz + +macOS-10.15/libiio-@VERSION@.g@LIBIIO_VERSION_GIT@-macOS-10.15.tar.gz +macOS-10.15/libiio-@VERSION@.g@LIBIIO_VERSION_GIT@.pkg + +macOS-11/libiio-@VERSION@.g@LIBIIO_VERSION_GIT@-macOS-11.tar.gz +macOS-11/libiio-@VERSION@.g@LIBIIO_VERSION_GIT@.pkg + +Ubuntu-arm32v7/libiio-@VERSION@.g@LIBIIO_VERSION_GIT@-Ubuntu-arm32v7.deb +Ubuntu-arm32v7/libiio-@VERSION@.g@LIBIIO_VERSION_GIT@-Ubuntu-arm32v7.tar.gz + +Ubuntu-arm64v8/libiio-@VERSION@.g@LIBIIO_VERSION_GIT@-Ubuntu-arm64v8.deb +Ubuntu-arm64v8/libiio-@VERSION@.g@LIBIIO_VERSION_GIT@-Ubuntu-arm64v8.tar.gz + +Ubuntu-ppc64le/libiio-@VERSION@.g@LIBIIO_VERSION_GIT@-Ubuntu-ppc64le.deb +Ubuntu-ppc64le/libiio-@VERSION@.g@LIBIIO_VERSION_GIT@-Ubuntu-ppc64le.tar.gz + +Ubuntu-x390x/libiio-@VERSION@.g@LIBIIO_VERSION_GIT@-Ubuntu-x390x.deb +Ubuntu-x390x/libiio-@VERSION@.g@LIBIIO_VERSION_GIT@-Ubuntu-x390x.tar.gz + +Windows-VS-2019-x64/iio.h +Windows-VS-2019-x64/iio_attr.exe +Windows-VS-2019-x64/iio_genxml.exe +Windows-VS-2019-x64/iio_info.exe +Windows-VS-2019-x64/iio_readdev.exe +Windows-VS-2019-x64/iio_reg.exe +Windows-VS-2019-x64/iio_writedev.exe +Windows-VS-2019-x64/libiio-py39-amd64.tar.gz +Windows-VS-2019-x64/libiio-sharp.dll +Windows-VS-2019-x64/libiio.dll +Windows-VS-2019-x64/libiio.exp +Windows-VS-2019-x64/libiio.iss +Windows-VS-2019-x64/libiio.lib +Windows-VS-2019-x64/libserialport-0.dll +Windows-VS-2019-x64/libusb-1.0.dll +Windows-VS-2019-x64/libxml2.dll +Windows-VS-2019-x64/msvcp140.dll +Windows-VS-2019-x64/vcruntime140.dll + +Windows-VS-2022-x64/iio.h +Windows-VS-2022-x64/iio_attr.exe +Windows-VS-2022-x64/iio_genxml.exe +Windows-VS-2022-x64/iio_info.exe +Windows-VS-2022-x64/iio_readdev.exe +Windows-VS-2022-x64/iio_reg.exe +Windows-VS-2022-x64/iio_writedev.exe +Windows-VS-2022-x64/libiio-py39-amd64.tar.gz +Windows-VS-2022-x64/libiio-sharp.dll +Windows-VS-2022-x64/libiio.dll +Windows-VS-2022-x64/libiio.exp +Windows-VS-2022-x64/libiio.iss +Windows-VS-2022-x64/libiio.lib +Windows-VS-2022-x64/libserialport-0.dll +Windows-VS-2022-x64/libusb-1.0.dll +Windows-VS-2022-x64/libxml2.dll +Windows-VS-2022-x64/msvcp140.dll +Windows-VS-2022-x64/vcruntime140.dll diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 5be92bb0a..8cfb89493 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -1,3 +1,6 @@ +# If you make changes to builds or artifacts, please check and update the following files if needed: +# README.md, CI/azure/prepare_assets.sh, artifact_manifest.txt.cmakein, CI/publish_deps.ps1 + trigger: branches: include: @@ -11,132 +14,81 @@ trigger: - v* pr: -- main -- master -- dev -- 20* + branches: + include: + - main + - master + - dev + - 20* stages: - stage: Builds + ############################################# + # Builds + ############################################# jobs: - job: LinuxBuilds - strategy: - matrix: - centos_7_x86_64: - imageName: 'ubuntu-latest' - OS_TYPE: 'centos_docker' - OS_VERSION: centos7 - artifactName: 'Linux-CentOS-7-x86_64' - centos_8_x86_64: - imageName: 'ubuntu-latest' - OS_TYPE: 'centos_docker' - OS_VERSION: centos8 - artifactName: 'Linux-CentOS-8-x86_64' - ubuntu_16_04_x86_64: - imageName: 'ubuntu-latest' - OS_TYPE: 'ubuntu_docker' - OS_VERSION: xenial - artifactName: 'Linux-Ubuntu-16.04-x86_64' - ubuntu_18_04_x86_64: - imageName: 'ubuntu-latest' - OS_TYPE: 'ubuntu_docker' - OS_VERSION: bionic - artifactName: 'Linux-Ubuntu-18.04-x86_64' - ubuntu_20_04_x86_64: - imageName: 'ubuntu-latest' - OS_TYPE: 'ubuntu_docker' - OS_VERSION: focal - artifactName: 'Linux-Ubuntu-20.04-x86_64' - CHECK_AGAINST_KERNEL_HEADER: 1 - debian_buster_arm32v7: - imageName: 'ubuntu-latest' - OS_TYPE: 'arm32v7/debian_docker' - OS_VERSION: 'buster' - artifactName: 'Linux-Debian-Buster-ARM' - debian_buster_arm64v8: - imageName: 'ubuntu-latest' - OS_TYPE: 'arm64v8/debian_docker' - OS_VERSION: 'buster' - artifactName: 'Linux-Debian-Buster-ARM64' - doxygen: - imageName: 'ubuntu-latest' - OS_TYPE: 'doxygen' - OS_VERSION: focal - artifactName: 'Libiio-documentation' - CI_BUILD_SPHINX_DOCS: 1 + # Host Box pool: - vmImage: $(imageName) - steps: - - checkout: self - fetchDepth: 1 - clean: true - persistCredentials: true - - script: ./CI/travis/before_install_linux - displayName: "Install Dependencies" - - script: ./CI/travis/make_linux - displayName: "Build" - - task: CopyFiles@2 - condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'), ne(variables['CI_BUILD_SPHINX_DOCS'], '1')) - inputs: - sourceFolder: '$(Agent.BuildDirectory)/s/build/' - contents: '$(Agent.BuildDirectory)/s/build/?(*.deb|*.rpm)' - targetFolder: '$(Build.ArtifactStagingDirectory)' - - task: PublishPipelineArtifact@1 - condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'), ne(variables['CI_BUILD_SPHINX_DOCS'], '1')) - inputs: - targetPath: '$(Build.ArtifactStagingDirectory)' - artifactName: '$(artifactName)' - - - job: macOSBuilds + vmImage: 'ubuntu-latest' + # Docker Images strategy: matrix: - macOS_10_15: - imageName: 'macOS-10.15' - artifactName: 'macOS-10.15' - macOS_11: - imageName: 'macOS-11' - artifactName: 'macOS-11' - pool: - vmImage: $(imageName) + ubuntu_18_04: + image: 'tfcollins/libiio_ubuntu_18_04-ci:latest' + artifactName: 'Linux-Ubuntu-18.04' + ubuntu_20_04: + image: 'tfcollins/libiio_ubuntu_20_04-ci:latest' + artifactName: 'Linux-Ubuntu-20.04' + fedora34: + image: 'tfcollins/libiio_fedora_34-ci:latest' + artifactName: 'Linux-Fedora-34' + container: $[ variables['image'] ] steps: - checkout: self fetchDepth: 1 clean: true - - script: ./CI/travis/before_install_darwin - displayName: "Install Dependencies" - - script: ./CI/travis/make_darwin - displayName: "Build" + persistCredentials: true + - script: | + mkdir build && cd build + cmake .. -DENABLE_PACKAGING=ON -DPYTHON_BINDINGS=ON -DWITH_DOC=ON -DCPACK_SYSTEM_NAME=${ARTIFACTNAME} + make + make package + displayName: 'Build' - task: CopyFiles@2 + condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) inputs: sourceFolder: '$(Agent.BuildDirectory)/s/build/' - contents: '$(Agent.BuildDirectory)/s/build/?(*.pkg)' - targetFolder: '$(Build.ArtifactStagingDirectory)' - - task: CopyFiles@2 - inputs: - sourceFolder: '$(Agent.BuildDirectory)/s/build_tar/' - contents: '$(Agent.BuildDirectory)/s/build_tar/?(*.gz)' + contents: '$(Agent.BuildDirectory)/s/build/?(*.deb|*.gz|*.rpm)' targetFolder: '$(Build.ArtifactStagingDirectory)' + - script: | + cd $(Agent.BuildDirectory)/s/build/ + sh generateDocumentationAndDeploy.sh + displayName: 'Documentation' + condition: eq(variables['artifactName'], 'Linux-Fedora-34') - task: PublishPipelineArtifact@1 condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) inputs: targetPath: '$(Build.ArtifactStagingDirectory)' artifactName: '$(artifactName)' + ############################################# - job: WindowsBuilds + # Host Box strategy: matrix: - VS2019_Win32: - imageName: 'windows-2019' - COMPILER: 'Visual Studio 16 2019' - ARCH: 'Win32' - artifactName: 'Windows-VS-16-2019-Win32' - VS2019_Win64: - imageName: 'windows-2019' + VS2022: + vmImage: 'windows-2022' + COMPILER: 'Visual Studio 17 2022' + ARCH: 'x64' + artifactName: 'Windows-VS-2022-x64' + VS2019: + vmImage: 'windows-2019' COMPILER: 'Visual Studio 16 2019' ARCH: 'x64' - artifactName: 'Windows-VS-16-2019-x64' + artifactName: 'Windows-VS-2019-x64' pool: - vmImage: $[ variables['imageName'] ] + vmImage: $[ variables['vmImage'] ] steps: - checkout: self fetchDepth: 1 @@ -145,15 +97,27 @@ stages: inputs: versionSpec: '3.9' - task: PowerShell@2 + displayName: 'Dependencies' inputs: - targetType: 'filePath' - filePath: .\CI\install_deps_win.ps1 - displayName: Dependencies + targetType: inline + script: | + git submodule update --init + if ( !( Test-Path deps ) ) { + mkdir deps + } + cd deps + mkdir libxml + wget https://www.zlatkovic.com/pub/libxml/64bit/libxml2-2.9.3-win32-x86_64.7z -OutFile "libxml.7z" + 7z x -y libxml.7z + rm libxml.7z + cd C:\ + wget http://swdownloads.analog.com/cse/build/libiio-win-deps-libusb1.0.24.zip -OutFile "libiio-win-deps.zip" + 7z x -y "C:\libiio-win-deps.zip" - task: PowerShell@2 inputs: targetType: 'filePath' filePath: .\CI\build_win.ps1 - displayName: Build + displayName: 'Build' - task: CopyFiles@2 displayName: 'Copy libraries' inputs: @@ -174,7 +138,7 @@ stages: - task: CopyFiles@2 displayName: 'Copy .tar.gz files' inputs: - sourceFolder: '$(Agent.BuildDirectory)/s/bindings/python' + sourceFolder: '$(Agent.BuildDirectory)/s/build-x64/bindings/python' contents: '*.gz' targetFolder: '$(Build.ArtifactStagingDirectory)' - task: CopyFiles@2 @@ -194,66 +158,219 @@ stages: targetPath: '$(Build.ArtifactStagingDirectory)' artifactName: '$(artifactName)' -- stage: PushArtifacts + ############################################# + - job: macOSBuilds + # Host Box + strategy: + matrix: + macOS_10_15: + vmImage: 'macOS-10.15' + artifactName: 'macOS-10.15' + macOS_11: + vmImage: 'macOS-11' + artifactName: 'macOS-11' + pool: + vmImage: $[ variables['vmImage'] ] + steps: + - checkout: self + fetchDepth: 1 + clean: true + - script: | + brew install cmake doxygen libusb libxml2 ncurses cdk libserialport + pip3 install sphinx sphinx-rtd-theme + displayName: 'Dependencies' + - script: | + mkdir build && cd build + cmake .. -DOSX_PACKAGE=ON -DPYTHON_BINDINGS=ON -DWITH_EXAMPLES=ON -DWITH_SERIAL_BACKEND=OFF -DWITH_ZSTD=ON + make + sudo make install + cd .. + displayName: 'Build' + - script: | + mkdir build_tar && cd build_tar + cmake .. -DOSX_PACKAGE=OFF -DENABLE_PACKAGING=ON -DPYTHON_BINDINGS=ON -DWITH_SERIAL_BACKEND=OFF -DWITH_ZSTD=ON -DCPACK_SYSTEM_NAME=${ARTIFACTNAME} + make + make package + cd .. + displayName: 'Build tar' + - script: | + cd build + cmake .. -DPYTHON_BINDINGS=ON -DWITH_DOC=ON + make + cd .. + displayName: 'Build With Doc' + - task: CopyFiles@2 + inputs: + sourceFolder: '$(Agent.BuildDirectory)/s/build/' + contents: '$(Agent.BuildDirectory)/s/build/?(*.pkg)' + targetFolder: '$(Build.ArtifactStagingDirectory)' + - task: CopyFiles@2 + inputs: + sourceFolder: '$(Agent.BuildDirectory)/s/build_tar/' + contents: '$(Agent.BuildDirectory)/s/build_tar/?(*.gz)' + targetFolder: '$(Build.ArtifactStagingDirectory)' + - task: PublishPipelineArtifact@1 + condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) + inputs: + targetPath: '$(Build.ArtifactStagingDirectory)' + artifactName: '$(artifactName)' + + ############################################# + - job: ARMBuilds + # Host Box + pool: + vmImage: "ubuntu-latest" + # Docker Images + strategy: + matrix: + ubuntu-ppc64le: + image: tfcollins/libiio_ubuntu_18_04-ci-arm-ppc:latest + arch: ppc64le + build_script: ci-ubuntu.sh + artifactName: 'Ubuntu-ppc64le' + ubuntu-x390x: + image: tfcollins/libiio_ubuntu_18_04-ci-arm-ppc:latest + arch: s390x + build_script: ci-ubuntu.sh + artifactName: 'Ubuntu-x390x' + ubuntu-arm64v8: + image: tfcollins/libiio_ubuntu_18_04-ci-arm-ppc:latest + arch: aarch64 + build_script: ci-ubuntu.sh + artifactName: 'Ubuntu-arm64v8' + ubuntu-arm32v7: + image: tfcollins/libiio_ubuntu_18_04-ci-arm-ppc:latest + arch: arm + build_script: ci-ubuntu.sh + artifactName: 'Ubuntu-arm32v7' + steps: + - script: | + sudo apt-get install -y gcc-arm-linux-gnueabihf libc6-dev-armhf-cross qemu-arm-static + sudo apt-get install -y g++-arm-linux-gnueabihf libstdc++-4.8-dev-armhf-cross + sudo apt-get install -y g++-aarch64-linux-gnu libstdc++-4.8-dev-arm64-cross + sudo apt-get install -y qemu-system-ppc64 + sudo apt-get install qemu + sudo docker run --rm --privileged multiarch/qemu-user-static --reset -p yes + displayName: 'Setup' + - script: | + sudo docker run --rm -t --privileged -e ARTIFACTNAME=$(artifactName) -v "$(Agent.BuildDirectory)/s":"/ci" -v "/usr/bin/qemu-$(arch)-static":"/usr/bin/qemu-$(arch)-static" "$(image)" /bin/bash -c "cd /ci/ && chmod +x ./CI/azure/$(build_script) && ./CI/azure/$(build_script)" + displayName: 'Build' + - task: CopyFiles@2 + condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) + inputs: + sourceFolder: '$(Agent.BuildDirectory)/s/build/' + contents: '$(Agent.BuildDirectory)/s/build/?(*.deb|*.gz)' + targetFolder: '$(Build.ArtifactStagingDirectory)' + - task: PublishPipelineArtifact@1 + condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) + inputs: + targetPath: '$(Build.ArtifactStagingDirectory)' + artifactName: '$(artifactName)' + + ############################################# +- stage: ManageArtifacts dependsOn: Builds + ############################################# + # Deploy + ############################################# jobs: - job: GenerateSetupExe condition: and(succeeded(), or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))) pool: vmImage: 'windows-2019' steps: - - task: DownloadPipelineArtifact@2 - inputs: - path: '$(Build.ArtifactStagingDirectory)' - - task: PowerShell@2 - inputs: - targetType: 'filePath' - filePath: .\CI\generate_exe.ps1 - displayName: "Generate libiio-setup.exe" - - task: PublishPipelineArtifact@1 - condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) - inputs: - targetPath: '$(Build.ArtifactStagingDirectory)' - artifactName: 'Libiio-Setup-Exe' - - job: PushToSWDownloads + - task: DownloadPipelineArtifact@2 + inputs: + path: '$(Build.ArtifactStagingDirectory)' + - task: PowerShell@2 + inputs: + targetType: 'filePath' + filePath: .\CI\generate_exe.ps1 + displayName: 'Generate libiio-setup.exe' + - task: PublishPipelineArtifact@1 + condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) + inputs: + targetPath: '$(Build.ArtifactStagingDirectory)' + artifactName: 'Libiio-Setup-Exe' + + ############################################# + - job: CheckArtifacts dependsOn: GenerateSetupExe + condition: and(succeeded(), or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))) + # Host Box + pool: + vmImage: 'ubuntu-latest' + # Docker Images + strategy: + matrix: + ubuntu_20_04: + image: 'tfcollins/libiio_ubuntu_20_04-ci:latest' + artifactName: 'Check artifacts' + container: $[ variables['image'] ] + steps: + - script: | + mkdir build && cd build + cmake .. + mkdir artifacts + displayName: 'Build artifact manifest' + - task: DownloadPipelineArtifact@2 + inputs: + path: '$(Agent.BuildDirectory)/s/build/artifacts' + - script: ./CI/azure/prepare_assets.sh check + displayName: 'Check files' + - task: CopyFiles@2 + inputs: + sourceFolder: '$(Agent.BuildDirectory)/s/build/' + contents: 'artifact_manifest.txt' + targetFolder: '$(Build.ArtifactStagingDirectory)' + - task: PublishPipelineArtifact@1 + inputs: + targetPath: '$(Build.ArtifactStagingDirectory)' + artifactName: 'Artifact manifest' + + ############################################# + - job: PushToSWDownloads + dependsOn: CheckArtifacts condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master')) pool: vmImage: 'ubuntu-latest' steps: - - task: DownloadPipelineArtifact@2 - inputs: - path: '$(Build.ArtifactStagingDirectory)' - - bash: ./CI/travis/prepare_assets.sh swdownloads - displayName: "Prepare artifacts for SWDownloads" - - task: DownloadSecureFile@1 - name: key - displayName: 'Download rsa key' - inputs: - secureFile: 'id_rsa' - - bash: chmod 600 $(key.secureFilePath) ; scp -2 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o HostKeyAlgorithms=+ssh-dss -i $(key.secureFilePath) -r /home/vsts/work/1/a/* $MAPPED_VAR - env: - MAPPED_VAR: $(SERVER_ADDRESS) - displayName: "Push artifacts to SW Downloads" + - task: DownloadPipelineArtifact@2 + inputs: + path: '$(Build.ArtifactStagingDirectory)' + - bash: ./CI/azure/prepare_assets.sh swdownloads + displayName: "Prepare artifacts for SWDownloads" + - task: DownloadSecureFile@1 + name: key + displayName: 'Download rsa key' + inputs: + secureFile: 'id_rsa' + - bash: chmod 600 $(key.secureFilePath) ; scp -2 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o HostKeyAlgorithms=+ssh-dss -i $(key.secureFilePath) -r /home/vsts/work/1/a/* $MAPPED_VAR + env: + MAPPED_VAR: $(SERVER_ADDRESS) + displayName: 'Push artifacts to SW Downloads' + + ############################################## - job: PushToGithubRelease + dependsOn: CheckArtifacts condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/v')) pool: vmImage: 'ubuntu-latest' steps: - - task: DownloadPipelineArtifact@2 - inputs: - path: '$(Build.ArtifactStagingDirectory)' - - bash: ./CI/travis/prepare_assets.sh release - displayName: "Prepare assets for release" - - task: GithubRelease@0 - displayName: 'Attach artifacts to GitHub Release' - inputs: - gitHubConnection: libiio-release - repositoryName: $(Build.Repository.Name) - action: create - target: $(Build.SourceVersion) - tag: $(Build.SourceBranchName) - title: "Libiio release $(Build.SourceBranchName)" - assets: $(Build.ArtifactStagingDirectory)/* - addChangeLog: true - isDraft: true + - task: DownloadPipelineArtifact@2 + inputs: + path: '$(Build.ArtifactStagingDirectory)' + - bash: ./CI/azure/prepare_assets.sh release + displayName: 'Prepare assets for release' + - task: GithubRelease@0 + displayName: 'Attach artifacts to GitHub Release' + inputs: + gitHubConnection: libiio-release + repositoryName: $(Build.Repository.Name) + action: create + target: $(Build.SourceVersion) + tag: $(Build.SourceBranchName) + title: "Libiio release $(Build.SourceBranchName)" + assets: $(Build.ArtifactStagingDirectory)/* + addChangeLog: true + isDraft: true diff --git a/bindings/python/README.md b/bindings/python/README.md index 66db5fc4e..0a7b84828 100644 --- a/bindings/python/README.md +++ b/bindings/python/README.md @@ -4,13 +4,18 @@ This package contains the python bindings for libiio, a library for interfacing libiio is used to interface to the Linux Industrial Input/Output (IIO) Subsystem. The Linux IIO subsystem is intended to provide support for devices that in some sense are analog to digital or digital to analog converters (ADCs, DACs). This includes, but is not limited to ADCs, Accelerometers, Gyros, IMUs, Capacitance to Digital Converters (CDCs), Pressure Sensors, Color, Light and Proximity Sensors, Temperature Sensors, Magnetometers, DACs, DDS (Direct Digital Synthesis), PLLs (Phase Locked Loops), Variable/Programmable Gain Amplifiers (VGA, PGA), and RF transceivers. You can use libiio natively on an embedded Linux target (local mode), or use libiio to communicate remotely to that same target from a host Linux, Windows or MAC over USB or Ethernet or Serial. -[![Build Status](https://travis-ci.com/analogdevicesinc/libiio.svg?branch=master)](https://travis-ci.com/analogdevicesinc/libiio) -[![PyPI version](https://badge.fury.io/py/pylibiio.svg)](https://badge.fury.io/py/pylibiio) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/4bd027bfc5774029a30a9e1cedf5a434)](https://www.codacy.com/app/rgetz/libiio?utm_source=github.com&utm_medium=referral&utm_content=analogdevicesinc/libiio&utm_campaign=Badge_Grade) -![open bugs](https://img.shields.io/github/issues/analogdevicesinc/libiio.svg) - -[[Docs](https://analogdevicesinc.github.io/libiio/v0.19/python/index.html)] -[[Support](http://ez.analog.com)] -[[Wiki](https://wiki.analog.com/resources/tools-software/linux-software/libiio)] +Library License : [![Library License](https://img.shields.io/badge/license-LGPL2+-blue.svg)](https://github.com/analogdevicesinc/libiio/blob/master/COPYING.txt) +Tests/Examples License : [![Application License](https://img.shields.io/badge/license-GPL2+-blue.svg)](https://github.com/analogdevicesinc/libiio/blob/master/COPYING_GPL.txt) +Latest Release : [![GitHub release](https://img.shields.io/github/release/analogdevicesinc/libiio.svg)](https://github.com/analogdevicesinc/libiio/releases/latest) +Downloads : [![Github All Releases](https://img.shields.io/github/downloads/analogdevicesinc/libiio/total.svg)](https://github.com/analogdevicesinc/libiio/releases/latest) + +Scans : [![Coverity Scan Build Status](https://img.shields.io/coverity/scan/4796.svg)](https://scan.coverity.com/projects/analogdevicesinc-libiio) +Release docs: [![Documentation](https://codedocs.xyz/analogdevicesinc/libiio.svg)](http://analogdevicesinc.github.io/libiio/) +Issues : [![open bugs](https://img.shields.io/github/issues/analogdevicesinc/libiio.svg)](https://github.com/analogdevicesinc/libiio/issues) +[![closed bugs](https://img.shields.io/github/issues-closed/analogdevicesinc/libiio.svg)](https://github.com/analogdevicesinc/libiio/issues?q=is%3Aissue+is%3Aclosed) + +Support:
+If you have a question about libiio and an Analog Devices IIO kernel driver please ask on : [![EngineerZone](https://img.shields.io/badge/chat-on%20EngineerZone-blue.svg)](https://ez.analog.com/linux-device-drivers/linux-software-drivers). If you have a question about a non-ADI devices, please ask it on [github](https://github.com/analogdevicesinc/libiio/issues). ## Requirements To use these bindings naturally you need the core library they depend upon, libiio. This is not packaged with the pypi release but there are a number of options: diff --git a/channel.c b/channel.c index a0c5d3408..750b7d177 100644 --- a/channel.c +++ b/channel.c @@ -177,7 +177,7 @@ void iio_channel_init_finalize(struct iio_channel *chn) char *mod; int type; - if (WITH_HWMON && iio_device_is_hwmon(chn->dev)) { + if (iio_device_is_hwmon(chn->dev)) { type = iio_channel_find_type(chn->id, hwmon_chan_type_name_spec, ARRAY_SIZE(hwmon_chan_type_name_spec)); } else { diff --git a/cmake/Install.cmake b/cmake/Install.cmake index f55be436f..4dadab3cf 100644 --- a/cmake/Install.cmake +++ b/cmake/Install.cmake @@ -25,6 +25,7 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") set(SKIP_INSTALL_ALL ${OSX_PACKAGE}) endif() +configure_file(artifact_manifest.txt.cmakein ${CMAKE_CURRENT_BINARY_DIR}/artifact_manifest.txt @ONLY) configure_file(libiio.iss.cmakein ${CMAKE_CURRENT_BINARY_DIR}/libiio.iss @ONLY) set(LIBIIO_PC ${CMAKE_CURRENT_BINARY_DIR}/libiio.pc) @@ -67,7 +68,7 @@ if(WITH_DOC) ${CMAKE_CURRENT_SOURCE_DIR}/bindings/csharp/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_csharp @ONLY) configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/CI/travis/generateDocumentationAndDeploy.sh.in + ${CMAKE_CURRENT_SOURCE_DIR}/CI/azure/generateDocumentationAndDeploy.sh.in ${CMAKE_CURRENT_BINARY_DIR}/generateDocumentationAndDeploy.sh @ONLY) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/doc DESTINATION ${CMAKE_HTML_DEST_DIR}/${CMAKE_API_DEST_DIR} diff --git a/dns_sd.c b/dns_sd.c index 6ded54a54..6820f3f4b 100644 --- a/dns_sd.c +++ b/dns_sd.c @@ -242,7 +242,7 @@ void remove_dup_discovery_data(const struct iio_context_params *params, } int dnssd_context_scan(const struct iio_context_params *params, - struct iio_scan *ctx) + struct iio_scan *ctx, const char *args) { struct dns_sd_discovery_data *ddata, *ndata; int ret = 0; diff --git a/dns_sd.h b/dns_sd.h index 8f41ece9d..9f6915b63 100644 --- a/dns_sd.h +++ b/dns_sd.h @@ -90,6 +90,6 @@ int dnssd_resolve_host(const struct iio_context_params *params, const char *hostname, char *ip_addr, const int addr_len); int dnssd_context_scan(const struct iio_context_params *params, - struct iio_scan *ctx); + struct iio_scan *ctx, const char *args); #endif /* __IIO_DNS_SD_H */ diff --git a/dynamic.c b/dynamic.c index 91c648e81..2d7bfb70e 100644 --- a/dynamic.c +++ b/dynamic.c @@ -154,7 +154,7 @@ int iio_dynamic_scan(const struct iio_context_params *params, params2.timeout_ms = backend->default_timeout_ms; if (backend->ops && backend->ops->scan) { - ret = backend->ops->scan(¶ms2, ctx); + ret = backend->ops->scan(¶ms2, ctx, NULL); /* TODO: Support args */ if (ret < 0) { prm_perror(params, -ret, "Unable to scan %s context(s)", buf); diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 594d0efb4..db29e1cb8 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -69,7 +69,10 @@ if (PTHREAD_LIBRARIES set(TEMP1 ${CMAKE_REQUIRED_INCLUDES}) list(APPEND CMAKE_REQUIRED_LIBRARIES ${CURSES_LIBRARY} ${CDK_LIBRARY}) list(APPEND CMAKE_REQUIRED_INCLUDES ${LIBCKD_INCLUDE_DIR}) + set(TMP_FLAGS "${CMAKE_C_FLAGS}") + set(CMAKE_C_FLAGS "") check_symbol_exists(CDK_CSTRING2 "cdk.h" HAS_CDK_CSTRING2) + set(CMAKE_C_FLAGS "${TMP_FLAGS}") set(CMAKE_REQUIRED_LIBRARIES ${TEMP}) set(CMAKE_REQUIRED_INCLUDES ${TEMP1}) endif() diff --git a/iio-backend.h b/iio-backend.h index b9d640ab9..dd165601b 100644 --- a/iio-backend.h +++ b/iio-backend.h @@ -92,7 +92,7 @@ enum iio_attr_type { struct iio_backend_ops { int (*scan)(const struct iio_context_params *params, - struct iio_scan *ctx); + struct iio_scan *ctx, const char *args); struct iio_context * (*create)(const struct iio_context_params *params, const char *uri); struct iio_context * (*clone)(const struct iio_context *ctx); @@ -131,8 +131,6 @@ struct iio_backend_ops { void (*shutdown)(struct iio_context *ctx); - char * (*get_description)(const struct iio_context *ctx); - int (*get_version)(const struct iio_context *ctx, unsigned int *major, unsigned int *minor, char git_tag[8]); diff --git a/iio-config.h.cmakein b/iio-config.h.cmakein index 0898f0963..fa903505e 100644 --- a/iio-config.h.cmakein +++ b/iio-config.h.cmakein @@ -13,6 +13,8 @@ #define IF_ENABLED(cfg, ptr) ((cfg) ? (ptr) : NULL) +#define LIBIIO_SCAN_BACKENDS "@LIBIIO_SCAN_BACKENDS@" + #cmakedefine01 WITH_LOCAL_BACKEND #cmakedefine01 WITH_XML_BACKEND #cmakedefine01 WITH_NETWORK_BACKEND @@ -28,6 +30,7 @@ #cmakedefine01 WITH_IIOD_USBD #cmakedefine01 WITH_IIOD_SERIAL #cmakedefine01 WITH_LOCAL_CONFIG +#cmakedefine01 WITH_LOCAL_MMAP_API #cmakedefine01 WITH_HWMON #cmakedefine01 WITH_AIO #cmakedefine01 HAVE_DNS_SD @@ -37,6 +40,7 @@ #cmakedefine HAS_PIPE2 #cmakedefine HAS_STRDUP #cmakedefine HAS_STRNDUP +#cmakedefine HAS_STRTOK_R #cmakedefine HAS_STRERROR_R #cmakedefine HAS_NEWLOCALE #cmakedefine HAS_PTHREAD_SETNAME_NP diff --git a/iio-private.h b/iio-private.h index 8f95775ac..05403f3f3 100644 --- a/iio-private.h +++ b/iio-private.h @@ -147,6 +147,11 @@ struct iio_buffer { bool dev_is_high_speed; }; +struct iio_context_info { + char *description; + char *uri; +}; + struct iio_module * iio_open_module(const char *path); void iio_release_module(struct iio_module *module); @@ -197,6 +202,8 @@ ssize_t iio_device_get_sample_size_mask(const struct iio_device *dev, void iio_channel_init_finalize(struct iio_channel *chn); unsigned int find_channel_modifier(const char *s, size_t *len_p); +char *iio_strndup(const char *str, size_t n); +char *iio_strtok_r(char *str, const char *delim, char **saveptr); char * iio_getenv (char * envvar); int iio_context_add_device(struct iio_context *ctx, struct iio_device *dev); diff --git a/iio.h b/iio.h index dfc4354ec..567237487 100644 --- a/iio.h +++ b/iio.h @@ -295,7 +295,14 @@ enum iio_event_direction { * of the backends to be scanned for contexts. If NULL, all the available * backends are scanned. * @return On success, a pointer to an iio_scan structure - * @return On failure, NULL is returned and errno is set appropriately */ + * @return On failure, NULL is returned and errno is set appropriately + * + * NOTE: It is possible to provide backend-specific information. + * For instance, "local,usb=0456:*" will scan the local backend and + * limit scans on USB to vendor ID 0x0456, and accept all product IDs. + * The "usb=0456:b673" string would limit the scan to the device with + * this particular VID/PID. Both IDs are expected in hexadecimal, no 0x + * prefix needed. */ __api __check_ret struct iio_scan * iio_scan(const struct iio_context_params *params, const char *backends); diff --git a/iiod/CMakeLists.txt b/iiod/CMakeLists.txt index d161c40da..b50d93df3 100644 --- a/iiod/CMakeLists.txt +++ b/iiod/CMakeLists.txt @@ -13,7 +13,10 @@ add_flex_bison_dependency(lexer parser) include(CheckSymbolExists) set(CMAKE_REQUIRED_LIBRARIES ${PTHREAD_LIBRARIES}) set(CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE) +set(TMP_FLAGS "${CMAKE_C_FLAGS}") +set(CMAKE_C_FLAGS "") check_symbol_exists(pthread_setname_np "pthread.h" HAS_PTHREAD_SETNAME_NP) +set(CMAKE_C_FLAGS "${TMP_FLAGS}") set(CMAKE_REQUIRED_LIBRARIES) set(CMAKE_REQUIRED_DEFINITIONS) diff --git a/iiod/lexer.l b/iiod/lexer.l index 962abccea..dfc9cd277 100644 --- a/iiod/lexer.l +++ b/iiod/lexer.l @@ -143,7 +143,7 @@ WORD (([[:alpha:]]+,)|(iio:))?(-|_|\.|[[:alnum:]])+ errno = 0; yylval->value = strtol(yytext, &end, 10); if (yytext == end || errno == ERANGE) { - sprintf(errstr,"lex : bad long constant: %s",(char*)yytext); + snprintf(errstr, sizeof(errstr), "lex : bad long constant: %s",(char*)yytext); perror(errstr); } return VALUE; diff --git a/iiod/parser.y b/iiod/parser.y index f25349e40..f39e7e458 100644 --- a/iiod/parser.y +++ b/iiod/parser.y @@ -145,7 +145,7 @@ Line: const char *xml = iio_context_get_xml(pdata->ctx); if (!pdata->verbose) { char buf[128]; - sprintf(buf, "%lu\n", (unsigned long) strlen(xml)); + snprintf(buf, sizeof(buf), "%lu\n", (unsigned long) strlen(xml)); output(pdata, buf); } output(pdata, xml); @@ -157,7 +157,7 @@ Line: if (pdata->xml_zstd) { if (!pdata->verbose) { char buf[128]; - sprintf(buf, "%lu\n", (unsigned long)pdata->xml_zstd_len); + snprintf(buf, sizeof(buf), "%lu\n", (unsigned long)pdata->xml_zstd_len); output(pdata, buf); } if (write_all(pdata, pdata->xml_zstd, pdata->xml_zstd_len) <= 0) @@ -166,7 +166,7 @@ Line: YYACCEPT; } else { char buf[128]; - sprintf(buf, "%d\n", -EINVAL); + snprintf(buf, sizeof(buf), "%d\n", -EINVAL); output(pdata, buf); YYABORT; } @@ -454,7 +454,7 @@ void yyerror(yyscan_t scanner, const char *msg) output(pdata, "\n"); } else { char buf[128]; - sprintf(buf, "%i\n", -EINVAL); + snprintf(buf, sizeof(buf), "%i\n", -EINVAL); output(pdata, buf); } } diff --git a/libiio.iss.cmakein b/libiio.iss.cmakein index fc8de59a0..621144669 100644 --- a/libiio.iss.cmakein +++ b/libiio.iss.cmakein @@ -39,27 +39,13 @@ Name: "turkish"; MessagesFile: "compiler:Languages\Turkish.isl" Name: "ukrainian"; MessagesFile: "compiler:Languages\Ukrainian.isl" [Files] -Source: "D:\a\1\a\Windows-VS-16-2019-Win32\libiio.dll"; DestDir: "{sys}"; Flags: 32bit replacesameversion -Source: "D:\a\1\a\Windows-VS-16-2019-x64\libiio.dll"; DestDir: "{sys}"; Check: Is64BitInstallMode; Flags: replacesameversion - -Source: "D:\a\1\a\Windows-VS-16-2019-Win32\*.exe"; DestDir: "{sys}"; Check: not Is64BitInstallMode; Flags: replacesameversion -Source: "D:\a\1\a\Windows-VS-16-2019-x64\*.exe"; DestDir: "{sys}"; Check: Is64BitInstallMode; Flags: replacesameversion - -Source: "D:\a\1\a\Windows-VS-16-2019-Win32\libiio.lib"; DestDir: "{commonpf32}\Microsoft Visual Studio 12.0\VC\lib"; Check: not Is64BitInstallMode -Source: "D:\a\1\a\Windows-VS-16-2019-x64\libiio.lib"; DestDir: "{commonpf32}\Microsoft Visual Studio 12.0\VC\lib\amd64"; Check: Is64BitInstallMode -Source: "D:\a\1\a\Windows-VS-16-2019-Win32\iio.h"; DestDir: "{commonpf32}\Microsoft Visual Studio 12.0\VC\include" - -Source: "D:\a\1\a\Windows-VS-16-2019-Win32\libxml2.dll"; DestDir: "{sys}"; Flags: onlyifdoesntexist 32bit -Source: "D:\a\1\a\Windows-VS-16-2019-x64\libxml2.dll"; DestDir: "{sys}"; Check: Is64BitInstallMode; Flags: onlyifdoesntexist - -Source: "D:\a\1\a\Windows-VS-16-2019-Win32\libusb-1.0.dll"; DestDir: "{sys}"; Flags: onlyifdoesntexist 32bit -Source: "D:\a\1\a\Windows-VS-16-2019-x64\libusb-1.0.dll"; DestDir: "{sys}"; Check: Is64BitInstallMode; Flags: onlyifdoesntexist - -Source: "D:\a\1\a\Windows-VS-16-2019-Win32\libserialport-0.dll"; DestDir: "{sys}"; Flags: onlyifdoesntexist 32bit -Source: "D:\a\1\a\Windows-VS-16-2019-x64\libserialport-0.dll"; DestDir: "{sys}"; Check: Is64BitInstallMode; Flags: onlyifdoesntexist - -Source: "D:\a\1\a\Windows-VS-16-2019-Win32\libiio-sharp.dll"; DestDir: "{commoncf}\libiio"; Flags: replacesameversion - -Source: "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Redist\MSVC\14.29.30133\x86\Microsoft.VC142.CRT\msvcp140.dll"; DestDir: "{sys}"; Flags: onlyifdoesntexist 32bit +Source: "D:\a\1\a\Windows-VS-2019-x64\libiio.dll"; DestDir: "{sys}"; Check: Is64BitInstallMode; Flags: replacesameversion +Source: "D:\a\1\a\Windows-VS-2019-x64\*.exe"; DestDir: "{sys}"; Check: Is64BitInstallMode; Flags: replacesameversion +Source: "D:\a\1\a\Windows-VS-2019-x64\libiio.lib"; DestDir: "{commonpf32}\Microsoft Visual Studio 12.0\VC\lib\amd64"; Check: Is64BitInstallMode +Source: "D:\a\1\a\Windows-VS-2019-x64\iio.h"; DestDir: "{commonpf32}\Microsoft Visual Studio 12.0\VC\include" +Source: "D:\a\1\a\Windows-VS-2019-x64\libxml2.dll"; DestDir: "{sys}"; Check: Is64BitInstallMode; Flags: onlyifdoesntexist +Source: "D:\a\1\a\Windows-VS-2019-x64\libusb-1.0.dll"; DestDir: "{sys}"; Check: Is64BitInstallMode; Flags: onlyifdoesntexist +Source: "D:\a\1\a\Windows-VS-2019-x64\libserialport-0.dll"; DestDir: "{sys}"; Check: Is64BitInstallMode; Flags: onlyifdoesntexist +Source: "D:\a\1\a\Windows-VS-2019-x64\libiio-sharp.dll"; DestDir: "{commoncf}\libiio"; Flags: replacesameversion Source: "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Redist\MSVC\14.29.30133\x64\Microsoft.VC142.CRT\msvcp140.dll"; DestDir: "{sys}"; Check: Is64BitInstallMode; Flags: onlyifdoesntexist - +Source: "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Redist\MSVC\14.29.30133\x64\Microsoft.VC142.CRT\vcruntime140.dll"; DestDir: "{sys}"; Check: Is64BitInstallMode; Flags: onlyifdoesntexist diff --git a/libiio.rules.cmakein b/libiio.rules.cmakein index 55b7a9d92..298d0a2fd 100644 --- a/libiio.rules.cmakein +++ b/libiio.rules.cmakein @@ -1 +1 @@ -SUBSYSTEM=="usb", PROGRAM=="/bin/sh -c '@CMAKE_INSTALL_FULL_BINDIR@/iio_info -S usb | grep %s{idVendor}:%s{idProduct}'", RESULT!="", MODE="666" +SUBSYSTEM=="usb", PROGRAM=="/bin/sh -c '@CMAKE_INSTALL_FULL_BINDIR@/iio_info -S usb=%s{idVendor}:%s{idProduct} | grep %s{idVendor}:%s{idProduct}'", RESULT!="", MODE="666" diff --git a/local.c b/local.c index 6974b370e..60fb1a1c8 100644 --- a/local.c +++ b/local.c @@ -54,7 +54,7 @@ static ssize_t local_write_chn_attr(const struct iio_channel *chn, static struct iio_context * local_create_context(const struct iio_context_params *params, const char *args); static int local_context_scan(const struct iio_context_params *params, - struct iio_scan *ctx); + struct iio_scan *ctx, const char *args); struct block_alloc_req { uint32_t type, @@ -102,6 +102,7 @@ static const char * const device_attrs_blacklist[] = { static const char * const buffer_attrs_reserved[] = { "length", "enable", + "watermark", }; static int ioctl_nointr(int fd, unsigned long request, void *data) @@ -435,7 +436,7 @@ static ssize_t local_get_buffer(const struct iio_device *dev, int f = pdata->fd; ssize_t ret; - if (!pdata->is_high_speed) + if (!WITH_LOCAL_MMAP_API || !pdata->is_high_speed) return -ENOSYS; if (f == -1) return -EBADF; @@ -842,8 +843,7 @@ static int enable_high_speed(const struct iio_device *dev) req.id = 0; req.type = 0; - req.size = pdata->samples_count * - iio_device_get_sample_size_mask(dev, dev->mask, dev->words); + req.size = pdata->samples_count * iio_device_get_sample_size(dev); req.count = nb_blocks; ret = ioctl_nointr(fd, BLOCK_ALLOC_IOCTL, &req); @@ -918,6 +918,15 @@ static int local_open(const struct iio_device *dev, if (ret < 0) return ret; + /* + * Set watermark to the buffer size; the driver will adjust to its + * maximum if it's too high without issueing an error. + */ + ret = local_write_dev_attr(dev, "buffer/watermark", + buf, strlen(buf) + 1, false); + if (ret < 0 && ret != -ENOENT && ret != -EACCES) + return ret; + pdata->cancel_fd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK); if (pdata->cancel_fd == -1) return -errno; @@ -952,11 +961,13 @@ static int local_open(const struct iio_device *dev, pdata->cyclic_buffer_enqueued = false; pdata->samples_count = samples_count; - ret = enable_high_speed(dev); - if (ret < 0 && ret != -ENOSYS) - goto err_close; + if (WITH_LOCAL_MMAP_API) { + ret = enable_high_speed(dev); + if (ret < 0 && ret != -ENOSYS) + goto err_close; - pdata->is_high_speed = !ret; + pdata->is_high_speed = !ret; + } if (!pdata->is_high_speed) { unsigned long size = samples_count * pdata->max_nb_blocks; @@ -1955,7 +1966,6 @@ static const struct iio_backend_ops local_ops = { .get_trigger = local_get_trigger, .set_trigger = local_set_trigger, .shutdown = local_shutdown, - .get_description = local_get_description, .set_timeout = local_set_timeout, .cancel = local_cancel, }; @@ -2173,7 +2183,7 @@ static int check_device(void *d, const char *path) } static int local_context_scan(const struct iio_context_params *params, - struct iio_scan *ctx) + struct iio_scan *ctx, const char *args) { char *machine, buf[2 * BUF_SIZE], names[BUF_SIZE]; bool exists = false; diff --git a/man/iio_attr.1.in b/man/iio_attr.1.in index a76feae06..aa4975139 100644 --- a/man/iio_attr.1.in +++ b/man/iio_attr.1.in @@ -83,8 +83,11 @@ Read and Write IIO Context attributes .B \-D \-\-debug-attr Read and Write IIO Debug attributes .TP -.B \-S, \-\-Scan -Scan for available IIO contexts, optional arg of specific backend(s) 'ip', 'usb' or 'ip:usb'. If no argument is given, it checks all that are availble. +.B \-S, \-\-scan +Scan for available IIO contexts, optional arg of specific backend(s) 'ip', 'usb' or 'ip,usb'. +Specific options for USB include Vendor ID, Product ID to limit scanning to specific devices 'usb=0456:b673'. +vid,pid are hexadecimal numbers (no prefix needed), "*" (match any for pid only) +If no argument is given, it checks all that are availble. .TP .B \-h, \-\-help Tells diff --git a/man/iio_info.1.in b/man/iio_info.1.in index 9fcd5be24..9fb15aedc 100644 --- a/man/iio_info.1.in +++ b/man/iio_info.1.in @@ -78,8 +78,11 @@ normally returned from with no address part .RE .TP -.B \-s, \-\-scan -Scan for available backends +.B \-S, \-\-scan +Scan for available IIO contexts, optional arg of specific backend(s) 'ip', 'usb' or 'ip,usb'. +Specific options for USB include Vendor ID, Product ID to limit scanning to specific devices 'usb=0456:b673'. +vid,pid are hexadecimal numbers (no prefix needed), "*" (match any for pid only) +If no argument is given, it checks all that are availble. .TP .B \-a, \-\-auto Scan for available contexts and if only one is available use it. diff --git a/man/iio_readdev.1.in b/man/iio_readdev.1.in index 862d7f531..6d0f0c267 100644 --- a/man/iio_readdev.1.in +++ b/man/iio_readdev.1.in @@ -76,7 +76,12 @@ Buffer timeout in milliseconds. 0 = no timeout. Default is 0. .TP .B \-a, \-\-auto Scan for available contexts and if only one is available use it. - +.TP +.B \-S, \-\-scan +Scan for available IIO contexts, optional arg of specific backend(s) 'ip', 'usb' or 'ip,usb'. +Specific options for USB include Vendor ID, Product ID to limit scanning to specific devices 'usb=0456:b673'. +vid,pid are hexadecimal numbers (no prefix needed), "*" (match any for pid only) +If no argument is given, it checks all that are availble. .SH RETURN VALUE If the specified device is not found, a non-zero exit code is returned. diff --git a/man/iio_writedev.1.in b/man/iio_writedev.1.in index 83d8e85b0..723d5b6e0 100644 --- a/man/iio_writedev.1.in +++ b/man/iio_writedev.1.in @@ -60,6 +60,12 @@ normally returned from .IP serial:[port] .IP local with no address part +.TP +.B \-S, \-\-scan +Scan for available IIO contexts, optional arg of specific backend(s) 'ip', 'usb' or 'ip,usb'. +Specific options for USB include Vendor ID, Product ID to limit scanning to specific devices 'usb=0456:b673'. +vid,pid are hexadecimal numbers (no prefix needed), "*" (match any for pid only) +If no argument is given, it checks all that are availble. .RE .TP .B \-t \-\-trigger diff --git a/network.c b/network.c index 66204236e..19760cb95 100644 --- a/network.c +++ b/network.c @@ -206,8 +206,8 @@ int create_socket(const struct addrinfo *addrinfo, unsigned int timeout) return fd; } -static char * __network_get_description(struct addrinfo *res, - const struct iio_context_params *params) +static char * network_get_description(struct addrinfo *res, + const struct iio_context_params *params) { char *description; unsigned int len; @@ -259,14 +259,6 @@ static char * __network_get_description(struct addrinfo *res, return description; } -static char *network_get_description(const struct iio_context *ctx) -{ - const struct iio_context_params *params = iio_context_get_params(ctx); - struct iio_context_pdata *pdata = iio_context_get_pdata(ctx); - - return __network_get_description(pdata->addrinfo, params); -} - static int network_open(const struct iio_device *dev, size_t samples_count, bool cyclic) { @@ -514,7 +506,6 @@ static const struct iio_backend_ops network_ops = { .get_trigger = network_get_trigger, .set_trigger = network_set_trigger, .shutdown = network_shutdown, - .get_description = network_get_description, .set_timeout = network_set_timeout, .set_kernel_buffers_count = network_set_kernel_buffers_count, @@ -735,7 +726,7 @@ static struct iio_context * network_create_context(const struct iio_context_para goto err_close_socket; } - description = __network_get_description(res, params); + description = network_get_description(res, params); if (!description) goto err_free_pdata; diff --git a/scan.c b/scan.c index 582c6c5ab..296a799e6 100644 --- a/scan.c +++ b/scan.c @@ -13,29 +13,21 @@ #include #include -struct iio_context_info { - char *description; - char *uri; -}; - struct iio_scan { struct iio_context_info *info; + char *backends; size_t count; }; -static bool has_backend(const char *backends, const char *backend) -{ - return !backends || iio_list_has_elem(backends, backend); -} - struct iio_scan * iio_scan(const struct iio_context_params *params, const char *backends) { const struct iio_context_params *default_params = get_default_params(); struct iio_context_params params2 = { 0 }; struct iio_scan *ctx; + const char *args, *uri; unsigned int i; - char buf[256]; + char *token, *rest = NULL; size_t len; int ret; @@ -53,25 +45,44 @@ struct iio_scan * iio_scan(const struct iio_context_params *params, return NULL; } - for (i = 0; i < iio_backends_size; i++) { - if (!iio_backends[i] || !iio_backends[i]->ops->scan) - continue; + if (!backends) + backends = LIBIIO_SCAN_BACKENDS; + + ctx->backends = iio_strdup(backends); + if (!ctx->backends) { + free(ctx); + errno = ENOMEM; + return NULL; + } + + for (token = iio_strtok_r(ctx->backends, ",", &rest); + token; token = iio_strtok_r(NULL, ",", &rest)) { + for (i = 0; i < iio_backends_size; i++) { + if (!iio_backends[i] || !iio_backends[i]->ops->scan) + continue; + + uri = iio_backends[i]->uri_prefix; + len = strlen(uri) - 1; /* -1: to remove the colon of the URI */ - len = strlen(iio_backends[i]->uri_prefix); + if (strncmp(token, uri, len)) + continue; - snprintf(buf, sizeof(buf), "%.*s", - (int)(len - 1), iio_backends[i]->uri_prefix); + if (token[len] == '\0') + args = NULL; + else if (token[len] == '=') + args = token + len + 1; + else + continue; - if (has_backend(backends, buf)) { if (params->timeout_ms) params2.timeout_ms = params->timeout_ms; else params2.timeout_ms = iio_backends[i]->default_timeout_ms; - ret = iio_backends[i]->ops->scan(¶ms2, ctx); + ret = iio_backends[i]->ops->scan(¶ms2, ctx, args); if (ret < 0) { prm_perror(¶ms2, -ret, - "Unable to scan %s context(s)", buf); + "Unable to scan %s context", token); } } } @@ -99,6 +110,7 @@ void iio_scan_destroy(struct iio_scan *ctx) } free(ctx->info); + free(ctx->backends); free(ctx); } diff --git a/serial.c b/serial.c index a41af46e7..9c08f4378 100644 --- a/serial.c +++ b/serial.c @@ -100,7 +100,7 @@ static inline int libserialport_to_errno(enum sp_return ret) } } -static char * __serial_get_description(struct sp_port *port) +static char * serial_get_description(struct sp_port *port) { char *description, *name, *desc; size_t desc_len; @@ -120,13 +120,6 @@ static char * __serial_get_description(struct sp_port *port) return description; } -static char * serial_get_description(const struct iio_context *ctx) -{ - struct iio_context_pdata *pdata = iio_context_get_pdata(ctx); - - return __serial_get_description(pdata->port); -} - static int serial_open(const struct iio_device *dev, size_t samples_count, bool cyclic) { @@ -384,7 +377,6 @@ static const struct iio_backend_ops serial_ops = { .write_channel_attr = serial_write_chn_attr, .set_kernel_buffers_count = serial_set_kernel_buffers_count, .shutdown = serial_shutdown, - .get_description = serial_get_description, .set_timeout = serial_set_timeout, .get_trigger = serial_get_trigger, .set_trigger = serial_set_trigger, @@ -473,7 +465,7 @@ static struct iio_context * serial_create_context( /* Empty the buffers */ sp_flush(port, SP_BUF_BOTH); - description = __serial_get_description(port); + description = serial_get_description(port); if (!description) goto err_close_port; diff --git a/sort.c b/sort.c index 04187e102..822cde0f7 100644 --- a/sort.c +++ b/sort.c @@ -81,3 +81,20 @@ int iio_buffer_attr_compare(const void *p1, const void *p2) return strcmp(tmp1, tmp2); } +int iio_context_info_compare(const void *p1, const void *p2) +{ + int ret; + const struct iio_context_info *tmp1 = *(struct iio_context_info **)p1; + const struct iio_context_info *tmp2 = *(struct iio_context_info **)p2; + + if(!tmp1->uri) + return 1; + if (!tmp2->uri) + return 0; + + ret = strcmp(tmp1->uri, tmp2->uri); + if (ret) + return ret; + + return strcmp(tmp1->description, tmp2->description); +} diff --git a/sort.h b/sort.h index 66953518d..670f1dc6a 100644 --- a/sort.h +++ b/sort.h @@ -14,5 +14,6 @@ int iio_channel_attr_compare(const void *p1, const void *p2); int iio_device_compare(const void *p1, const void *p2); int iio_device_attr_compare(const void *p1, const void *p2); int iio_buffer_attr_compare(const void *p1, const void *p2); +int iio_context_info_compare(const void *p1, const void *p2); #endif /* __IIO_QSORT_H__ */ diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index d0ee2e119..922354d63 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -24,6 +24,11 @@ if (MSVC) target_include_directories(iio_tests_helper PUBLIC ../deps/wingetopt/src) target_compile_definitions(iio_tests_helper PRIVATE _CRT_SECURE_NO_WARNINGS) endif() +set_target_properties(iio_tests_helper PROPERTIES + C_STANDARD 99 + C_STANDARD_REQUIRED ON + C_EXTENSIONS OFF +) foreach (test ${IIO_TESTS_TARGETS}) project(${test} LANGUAGES C) diff --git a/tests/iio_adi_xflow_check.c b/tests/iio_adi_xflow_check.c index 0b05cb9b1..193f77dc8 100644 --- a/tests/iio_adi_xflow_check.c +++ b/tests/iio_adi_xflow_check.c @@ -168,6 +168,7 @@ int main(int argc, char **argv) char unit; int ret; struct option *opts; + bool do_scan = false; argw = dup_argv(MY_NAME, argc, argv); @@ -188,6 +189,8 @@ int main(int argc, char **argv) case 'T': break; case 'S': + do_scan = true; + /* FALLTHROUGH */ case 'a': if (!optarg && argc > optind && argv[optind] != NULL && argv[optind][0] != '-') @@ -215,6 +218,9 @@ int main(int argc, char **argv) } free(opts); + if (do_scan) + return EXIT_SUCCESS; + if (optind + 1 != argc) { fprintf(stderr, "Incorrect number of arguments.\n\n"); usage(MY_NAME, options, options_descriptions); diff --git a/tests/iio_attr.c b/tests/iio_attr.c index 765cf5182..084ce2f8c 100644 --- a/tests/iio_attr.c +++ b/tests/iio_attr.c @@ -321,11 +321,11 @@ static const struct option options[] = { }; static const char *options_descriptions[] = { - "-d [device] [attr] [value]\n" + ("-d [device] [attr] [value]\n" "\t\t\t\t-c [device] [channel] [attr] [value]\n" "\t\t\t\t-B [device] [attr] [value]\n" "\t\t\t\t-D [device] [attr] [value]\n" - "\t\t\t\t-C [attr]", + "\t\t\t\t-C [attr]"), /* help */ "Ignore case distinctions.", "Return result only.", diff --git a/tests/iio_common.c b/tests/iio_common.c index b3e4b41d4..7747202cf 100644 --- a/tests/iio_common.c +++ b/tests/iio_common.c @@ -230,19 +230,19 @@ struct option * add_common_options(const struct option * longopts) static const char *common_options_descriptions[] = { "Show this help and quit.", "Use the XML backend with the provided XML file.", - "Use the context at the provided URI." + ("Use the context at the provided URI." "\n\t\t\teg: 'ip:192.168.2.1', 'ip:pluto.local', or 'ip:'" "\n\t\t\t 'usb:1.2.3', or 'usb:'" "\n\t\t\t 'serial:/dev/ttyUSB0,115200,8n1'" - "\n\t\t\t 'local:' (Linux only)", - "Scan for available backends." + "\n\t\t\t 'local:' (Linux only)"), + ("Scan for available backends." "\n\t\t\toptional arg of specific backend(s)" - "\n\t\t\t 'ip', 'usb' or 'ip:usb'", - "Scan for available contexts and if a single context is" + "\n\t\t\t 'ip', 'usb' or 'ip:usb'"), + ("Scan for available contexts and if a single context is" "\n\t\t\tavailable use it. filters backend(s)" - "\n\t\t\t 'ip', 'usb' or 'ip:usb:'", - "Context timeout in milliseconds." - "\n\t\t\t0 = no timeout (wait forever)", + "\n\t\t\t 'ip', 'usb' or 'ip:usb:'"), + ("Context timeout in milliseconds." + "\n\t\t\t0 = no timeout (wait forever)"), }; diff --git a/tests/iio_genxml.c b/tests/iio_genxml.c index 48ee5b984..a3a9923cf 100644 --- a/tests/iio_genxml.c +++ b/tests/iio_genxml.c @@ -33,9 +33,9 @@ static const struct option options[] = { }; static const char *options_descriptions[] = { - "\t[-x ]\n" + ("\t[-x ]\n" "\t\t\t\t[-u ]\n" - "\t\t\t\t[-n ]", + "\t\t\t\t[-n ]"), }; int main(int argc, char **argv) diff --git a/tests/iio_info.c b/tests/iio_info.c index 115436860..efb8afd6e 100644 --- a/tests/iio_info.c +++ b/tests/iio_info.c @@ -35,14 +35,12 @@ #endif static const struct option options[] = { - {"scan", no_argument, 0, 's'}, {0, 0, 0, 0}, }; static const char *options_descriptions[] = { - "[-x ]\n" - "\t\t\t\t[-u ]", - "Scan for available backends.", + ("[-x ]\n" + "\t\t\t\t[-u ]"), }; static int dev_is_buffer_capable(const struct iio_device *dev) @@ -59,7 +57,7 @@ static int dev_is_buffer_capable(const struct iio_device *dev) return false; } -#define MY_OPTS "s" +#define MY_OPTS "" int main(int argc, char **argv) { @@ -87,7 +85,7 @@ int main(int argc, char **argv) fprintf(stderr, "Failed to add common options\n"); return EXIT_FAILURE; } - while ((c = getopt_long(argc, argw, "+" COMMON_OPTIONS MY_OPTS, /* Flawfinder: ignore */ + while ((c = getopt_long(argc, argw, "+" COMMON_OPTIONS MY_OPTS "s", /* Flawfinder: ignore */ opts, NULL)) != -1) { switch (c) { /* All these are handled in the common */ diff --git a/tests/iio_readdev.c b/tests/iio_readdev.c index b200fd761..ad7f3d8de 100644 --- a/tests/iio_readdev.c +++ b/tests/iio_readdev.c @@ -195,17 +195,17 @@ static ssize_t print_sample(const struct iio_channel *chn, int main(int argc, char **argv) { char **argw; - unsigned int i, nb_channels; + unsigned int i, j, nb_channels; unsigned int nb_active_channels = 0; unsigned int buffer_size = SAMPLES_PER_READ; - unsigned int refill_per_benchmark = REFILL_PER_BENCHMARK; + uint64_t refill_per_benchmark = REFILL_PER_BENCHMARK; int c; struct iio_device *dev; ssize_t sample_size; ssize_t ret; struct option *opts; bool mib, benchmark = false; - uint64_t before, after, rate, total; + uint64_t before = 0, after, rate, total; argw = dup_argv(MY_NAME, argc, argv); @@ -263,7 +263,7 @@ int main(int argc, char **argv) } free(opts); - if (argc == optind) { + if (argc < optind || argc > optind + 2) { fprintf(stderr, "Incorrect number of arguments.\n\n"); usage(MY_NAME, options, options_descriptions); return EXIT_FAILURE; @@ -272,6 +272,48 @@ int main(int argc, char **argv) if (!ctx) return EXIT_FAILURE; + if (!argw[optind]) { + unsigned int nb_devices = iio_context_get_devices_count(ctx); + + for (i = 0; i < nb_devices; i++) { + const char *dev_id = NULL, *label = NULL, *name = NULL; + bool hit; + + dev = iio_context_get_device(ctx, i); + nb_channels = iio_device_get_channels_count(dev); + + if (!nb_channels) + continue; + + hit = false; + for (j = 0; j < nb_channels; j++) { + struct iio_channel *ch = iio_device_get_channel(dev, j); + + if (!iio_channel_is_scan_element(ch) || + iio_channel_is_output(ch)) + continue; + + hit = true; + + dev_id = iio_device_get_id(dev); + label = iio_device_get_label(dev); + name = iio_device_get_name(dev); + + printf("Example : " MY_NAME " -u %s -b 256 -s 1024 %s %s\n", + iio_context_get_attr_value(ctx, "uri"), + label ? label : name ? name : dev_id, + iio_channel_get_id(ch)); + } + if (hit) + printf("Example : " MY_NAME " -u %s -b 256 -s 1024 %s\n", + iio_context_get_attr_value(ctx, "uri"), + label ? label : name ? name : dev_id); + } + iio_context_destroy(ctx); + usage(MY_NAME, options, options_descriptions); + return EXIT_FAILURE; + } + setup_sig_handler(); dev = iio_context_find_device(ctx, argw[optind]); @@ -332,7 +374,6 @@ int main(int argc, char **argv) } } else { for (i = 0; i < nb_channels; i++) { - unsigned int j; struct iio_channel *ch = iio_device_get_channel(dev, i); for (j = optind + 1; j < (unsigned int) argc; j++) { const char *n = iio_channel_get_name(ch); diff --git a/tests/iio_reg.c b/tests/iio_reg.c index 04bb27e4a..c7e1e3802 100644 --- a/tests/iio_reg.c +++ b/tests/iio_reg.c @@ -82,6 +82,7 @@ int main(int argc, char **argv) int c; char * name; struct option *opts; + bool do_scan = false; argw = dup_argv(MY_NAME, argc, argv); @@ -102,6 +103,8 @@ int main(int argc, char **argv) case 'T': break; case 'S': + do_scan = true; + /* FALLTHRU */ case 'a': if (!optarg && argc > optind && argv[optind] != NULL && argv[optind][0] != '-') @@ -114,6 +117,9 @@ int main(int argc, char **argv) } free(opts); + if (do_scan) + return EXIT_SUCCESS; + if ((argc - optind) < 2 || (argc - optind) > 3) { usage(MY_NAME, options, options_descriptions); return EXIT_SUCCESS; diff --git a/tests/iio_stresstest.c b/tests/iio_stresstest.c index beec93451..0cfd52346 100644 --- a/tests/iio_stresstest.c +++ b/tests/iio_stresstest.c @@ -107,8 +107,8 @@ static const struct option options[] = { }; static const char *options_descriptions[] = { - "[-n ] [-u :] [-t ] [-b ] [-s ]" - " [ ...]", + ("[-n ] [-u :] [-t ] [-b ] [-s ]" + " [ ...]"), "Show this help and quit.", "Use the context at the provided URI.", "Size of the capture buffer. Default is 256.", diff --git a/tests/iio_writedev.c b/tests/iio_writedev.c index ea74c2ec7..704bc2972 100644 --- a/tests/iio_writedev.c +++ b/tests/iio_writedev.c @@ -56,16 +56,16 @@ static const struct option options[] = { }; static const char *options_descriptions[] = { - "[-t ] " + ("[-t ] " "[-b ] [-s ] " - " [ ...]", + " [ ...]"), "Use the specified trigger.", "Size of the transmit buffer. Default is 256.", "Number of samples to write, 0 = infinite. Default is 0.", "Scan for available contexts and if only one is available use it.", "Use cyclic buffer mode.", - "Benchmark throughput." - "\n\t\t\tStatistics will be printed on the standard input.", + ("Benchmark throughput." + "\n\t\t\tStatistics will be printed on the standard input."), }; static struct iio_context *ctx; @@ -206,17 +206,17 @@ static ssize_t read_sample(const struct iio_channel *chn, int main(int argc, char **argv) { char **argw; - unsigned int i, nb_channels; + unsigned int i, j, nb_channels; unsigned int nb_active_channels = 0; unsigned int buffer_size = SAMPLES_PER_READ; - unsigned int refill_per_benchmark = REFILL_PER_BENCHMARK; + uint64_t refill_per_benchmark = REFILL_PER_BENCHMARK; int c; struct iio_device *dev; ssize_t sample_size; bool mib, cyclic_buffer = false, benchmark = false; ssize_t ret; struct option *opts; - uint64_t before, after, rate, total; + uint64_t before = 0, after, rate, total; argw = dup_argv(MY_NAME, argc, argv); @@ -276,7 +276,7 @@ int main(int argc, char **argv) } free(opts); - if (argc == optind) { + if (argc < optind || argc > optind + 2) { fprintf(stderr, "Incorrect number of arguments.\n\n"); usage(MY_NAME, options, options_descriptions); return EXIT_FAILURE; @@ -285,6 +285,48 @@ int main(int argc, char **argv) if (!ctx) return EXIT_FAILURE; + if (!argw[optind]) { + unsigned int nb_devices = iio_context_get_devices_count(ctx); + + for (i = 0; i < nb_devices; i++) { + const char *dev_id = NULL, *label = NULL, *name = NULL; + bool hit; + + dev = iio_context_get_device(ctx, i); + nb_channels = iio_device_get_channels_count(dev); + + if (!nb_channels) + continue; + + hit = false; + for (j = 0; j < nb_channels; j++) { + struct iio_channel *ch = iio_device_get_channel(dev, j); + + if (!iio_channel_is_scan_element(ch) || + !iio_channel_is_output(ch)) + continue; + + hit = true; + + dev_id = iio_device_get_id(dev); + label = iio_device_get_label(dev); + name = iio_device_get_name(dev); + + printf("Example : " MY_NAME " -u %s -b 256 -s 1024 %s %s\n", + iio_context_get_attr_value(ctx, "uri"), + label ? label : name ? name : dev_id, + iio_channel_get_id(ch)); + } + if (hit) + printf("Example : " MY_NAME " -u %s -b 256 -s 1024 %s\n", + iio_context_get_attr_value(ctx, "uri"), + label ? label : name ? name : dev_id); + } + iio_context_destroy(ctx); + usage(MY_NAME, options, options_descriptions); + return EXIT_FAILURE; + } + if (benchmark && cyclic_buffer) { fprintf(stderr, "Cannot benchmark in cyclic mode.\n"); iio_context_destroy(ctx); @@ -351,7 +393,6 @@ int main(int argc, char **argv) } } else { for (i = 0; i < nb_channels; i++) { - unsigned int j; struct iio_channel *ch = iio_device_get_channel(dev, i); for (j = optind + 1; j < (unsigned int) argc; j++) { const char *n = iio_channel_get_name(ch); diff --git a/usb.c b/usb.c index d6b8f2c11..78a2cd857 100644 --- a/usb.c +++ b/usb.c @@ -106,7 +106,7 @@ static struct iio_context * usb_create_context_from_args(const struct iio_context_params *params, const char *args); static int usb_context_scan(const struct iio_context_params *params, - struct iio_scan *scan); + struct iio_scan *scan, const char *args); static ssize_t write_data_sync(struct iiod_client_pdata *ep, const char *data, size_t len); static ssize_t read_data_sync(struct iiod_client_pdata *ep, @@ -1189,14 +1189,58 @@ static int usb_add_context_info(struct iio_scan *scan, return iio_scan_add_result(scan, description, uri); } +static int parse_vid_pid(const char *vid_pid, uint16_t *vid, uint16_t *pid) +{ + unsigned long val; + char *ptr; + + /* + * vid_pid string must be either: + * - NULL: scan everything, + * - "vid:*": scan all devices with the given VID, + * - "vid:pid": scan the device with the given VID/PID. + * IDs are given in hexadecimal, and the 0x prefix is not required. + */ + + *vid = 0; + *pid = 0; + + if (!vid_pid) + return 0; + + val = strtoul(vid_pid, &ptr, 16); + if (ptr == vid_pid || val > 0xFFFF || *ptr != ':') + return -EINVAL; + + *vid = (uint16_t) val; + + vid_pid = ptr + 1; + + if (*vid_pid == '*') + return vid_pid[1] == '\0' ? 0 : -EINVAL; + + val = strtoul(vid_pid, &ptr, 16); + if (ptr == vid_pid || val > 0xFFFF || *ptr != '\0') + return -EINVAL; + + *pid = (uint16_t) val; + + return 0; +} + static int usb_context_scan(const struct iio_context_params *params, - struct iio_scan *scan) + struct iio_scan *scan, const char *args) { libusb_device **device_list; libusb_context *ctx; + uint16_t vid, pid; unsigned int i; int ret; + ret = parse_vid_pid(args, &vid, &pid); + if (ret) + return ret; + ret = libusb_init(&ctx); if (ret < 0) return -(int) libusb_to_errno(ret); @@ -1211,6 +1255,21 @@ static int usb_context_scan(const struct iio_context_params *params, struct libusb_device_handle *hdl; struct libusb_device *dev = device_list[i]; unsigned int intrfc = 0; + struct libusb_device_descriptor device_descriptor; + + /* If we are given a pid or vid, use that to qualify for things, + * this avoids open/closing random devices & potentially locking + * (blocking them) from other applications + */ + if(vid || pid) { + ret = libusb_get_device_descriptor(dev, &device_descriptor); + if (ret) + continue; + if (vid && vid != device_descriptor.idVendor) + continue; + if (pid && pid != device_descriptor.idProduct) + continue; + } ret = libusb_open(dev, &hdl); if (ret) diff --git a/utilities.c b/utilities.c index 6820e2be5..7b095a67e 100644 --- a/utilities.c +++ b/utilities.c @@ -201,6 +201,17 @@ void iio_strerror(int err, char *buf, size_t len) } } +char *iio_strtok_r(char *str, const char *delim, char **saveptr) +{ +#if defined(_WIN32) + return strtok_s(str, delim, saveptr); +#elif defined(HAS_STRTOK_R) + return strtok_r(str, delim, saveptr); +#else +#error Need a implentation of strtok_r for this platform +#endif +} + char *iio_strdup(const char *str) { #if defined(_WIN32) @@ -217,6 +228,24 @@ char *iio_strdup(const char *str) #endif } +/* strndup conforms to POSIX.1-2008; but Windows does not provided it + */ +char *iio_strndup(const char *str, size_t n) +{ +#ifdef HAS_STRNDUP + return strndup(str, n); +#else + size_t len = strnlen(str, n + 1); + char *buf = malloc(len + 1); + if (buf) { + /* len = size of buf, so memcpy is OK */ + memcpy(buf, str, len); /* Flawfinder: ignore */ + buf[len] = 0; + } + return buf; +#endif +} + /* strlcpy is designed to be safer, more consistent, and less error prone * replacements for strncpy, since it guarantees to NUL-terminate the result. *