From 74b4c0b9fc8072a654d337c4661772ac3111db4c Mon Sep 17 00:00:00 2001 From: Raluca Groza Date: Fri, 23 Jun 2023 10:42:11 +0300 Subject: [PATCH 1/3] network: fix snprintf format string for MinGW MinGW build fail on unsigned int argument because long unsigned int is expected. Signed-off-by: Raluca Groza --- network.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/network.c b/network.c index 511322adb..cabc6fa2c 100644 --- a/network.c +++ b/network.c @@ -320,7 +320,7 @@ static char * network_get_description(struct addrinfo *res) if (errno == 0) { /* Windows uses numerical interface identifiers */ ptr = description + strnlen(description, len) + 1; - iio_snprintf(ptr, IF_NAMESIZE, "%u", in->sin6_scope_id); + iio_snprintf(ptr, IF_NAMESIZE, "%u", (unsigned int)in->sin6_scope_id); } else #endif { From 315be8eecff41b6896bccc4646a94270697ceda0 Mon Sep 17 00:00:00 2001 From: Raluca Groza Date: Fri, 23 Jun 2023 10:43:12 +0300 Subject: [PATCH 2/3] CI:add MinGW build Add MinGW build and modify related files to add artifacts to SwDownloads and GitHub release. Signed-off-by: Raluca Groza --- CI/azure/{zip.txt => README.txt} | 11 ++--- CI/azure/prepare_assets.sh | 21 +++++++-- CI/build_win.ps1 | 3 +- CI/publish_deps.ps1 | 38 ++++++++++------ artifact_manifest.txt.cmakein | 20 ++++++++ azure-pipelines.yml | 78 ++++++++++++++++++++++++++++++++ 6 files changed, 148 insertions(+), 23 deletions(-) rename CI/azure/{zip.txt => README.txt} (86%) diff --git a/CI/azure/zip.txt b/CI/azure/README.txt similarity index 86% rename from CI/azure/zip.txt rename to CI/azure/README.txt index 042735739..b67369afc 100644 --- a/CI/azure/zip.txt +++ b/CI/azure/README.txt @@ -7,17 +7,16 @@ In this archive, you should find the following directories: o ./include : Common include files -o ./MinGW32 : 32-bit binaries compiled by the MinGW toolchain -o ./MinGW64 : 64-bit binaries compiled by the MinGW toolchain -o ./MS32 : 32-bit binaries compiled by the MicroSoft toolchain -o ./MS64 : 364bit binaries compiled by the MicroSoft toolchain +o ./Windows-MinGW-W64 : 64-bit binaries compiled by the MinGW toolchain +o ./Windows-VS-2019-x64 : 64-bit binaries compiled by the MicroSoft toolchain, VS-2019 +o ./Windows-VS-2022-x64 : 64-bit binaries compiled by the MicroSoft toolchain, VS-2022 o Visual Studio: - Open existing or create a new project for your application - Copy iio.h, from the include\ directory, into your project and make sure that the location where the file reside appears in the 'Additional Include Directories' section (Configuration Properties -> C/C++ -> General). - - Copy the relevant .lib file from MS32\ or MS64\ and add 'libiio.lib' to + - Copy the relevant .lib file from Windows-VS-2019-x64\ or Windows-VS-2022-x64\ and add 'libiio.lib' to your 'Additional Dependencies' (Configuration Properties -> Linker -> Input) Also make sure that the directory where libiio.lib resides is added to 'Additional Library Directories' (Configuration Properties -> Linker @@ -44,7 +43,7 @@ o WDK/DDK: SOURCES=your_app.c o MinGW/cygwin - - Copy libiio.h, from include/ to your default include directory, + - Copy iio.h, from include/ to your default include directory, and copy the MinGW32/ or MinGW64/ .a files to your default library directory. Or, if you don't want to use the default locations, make sure that you feed the relevant -I and -L options to the compiler. diff --git a/CI/azure/prepare_assets.sh b/CI/azure/prepare_assets.sh index 18912d024..a32ef7959 100755 --- a/CI/azure/prepare_assets.sh +++ b/CI/azure/prepare_assets.sh @@ -31,12 +31,23 @@ release_artifacts() { rm -r "${i}" done - local zip_assets='2019 2022' + local zip_assets='VS-2019-x64 VS-2022-x64 MinGW-W64' cd "${BUILD_ARTIFACTSTAGINGDIRECTORY}" + mkdir Windows + cd Windows + mkdir include + cd .. + cp ./Windows-VS-2019-x64/iio.h ./Windows/include for i in $zip_assets; do - zip -r "Windows-VS-${i}-x64".zip "Windows-VS-${i}-x64" - rm -r "Windows-VS-${i}-x64" + rm ./"Windows-${i}"/iio.h + mv ./"Windows-${i}" Windows done + cp /home/vsts/work/1/s/CI/azure/README.txt ./Windows + cd Windows + zip Windows.zip ./* + cp ./Windows.zip ../ + cd .. + rm -r Windows local deb_arm_assets='arm32v7 arm64v8 ppc64le x390x' cd "${BUILD_ARTIFACTSTAGINGDIRECTORY}" @@ -88,6 +99,10 @@ swdownloads_artifacts() { cd "${BUILD_ARTIFACTSTAGINGDIRECTORY}/Libiio-Setup-Exe" mv libiio-setup.exe ../libiio-setup.exe rm -r ../Libiio-Setup-Exe + + cd "${BUILD_ARTIFACTSTAGINGDIRECTORY}" + zip -r Windows-MinGW-W64-latest_master_libiio.zip Windows-MinGW-W64 + rm -r Windows-MinGW-W64 } check_artifacts() { diff --git a/CI/build_win.ps1 b/CI/build_win.ps1 index 2d35ceb19..34d04bc4f 100644 --- a/CI/build_win.ps1 +++ b/CI/build_win.ps1 @@ -3,6 +3,7 @@ $ErrorActionPreference = "Stop" $ErrorView = "NormalView" $COMPILER=$Env:COMPILER +$USE_CSHARP=$Env:USE_CSHARP $src_dir=$pwd echo "Running cmake for $COMPILER on 64 bit..." @@ -10,7 +11,7 @@ mkdir build-x64 cp .\libiio.iss.cmakein .\build-x64 cd build-x64 -cmake -G "$COMPILER" -DCMAKE_SYSTEM_PREFIX_PATH="C:" -Werror=dev -DCOMPILE_WARNING_AS_ERROR=ON -DENABLE_IPV6=ON -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 -G "$COMPILER" -DCMAKE_SYSTEM_PREFIX_PATH="C:" -Werror=dev -DCOMPILE_WARNING_AS_ERROR=ON -DENABLE_IPV6=ON -DWITH_USB_BACKEND=ON -DWITH_SERIAL_BACKEND=ON -DPYTHON_BINDINGS=ON -DCSHARP_BINDINGS:BOOL=$USE_CSHARP -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" diff --git a/CI/publish_deps.ps1 b/CI/publish_deps.ps1 index 76ec7955a..1ac02fb86 100644 --- a/CI/publish_deps.ps1 +++ b/CI/publish_deps.ps1 @@ -5,22 +5,34 @@ $ErrorView = "NormalView" $src_dir=$pwd $COMPILER=$Env:COMPILER -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 { - 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 mkdir dependencies 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" -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 +if ($COMPILER -eq "MinGW Makefiles") { + cp $src_dir\dependencies\libs\64\libserialport-0.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY + cp $src_dir\dependencies\libs\64\libusb-1.0.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY + cp C:\ghcup\ghc\9.2.8\mingw\bin\libgcc_s_seh-1.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY + cp C:\ghcup\ghc\9.4.5\mingw\bin\libiconv-2.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY + cp C:\ghcup\ghc\9.4.5\mingw\bin\zlib1.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY + cp C:\ghcup\ghc\9.4.5\mingw\bin\liblzma-5.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY + cp C:\ghcup\ghc\9.4.5\mingw\bin\libwinpthread-1.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY + cp C:\ghcup\ghc\9.4.5\mingw\bin\libxml2-2.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY + cp C:\ghcup\ghc\9.2.8\mingw\bin\libstdc++-6.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY +} else { + cp $src_dir\dependencies\libs\64\libxml2.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY + cp $src_dir\dependencies\libs\64\libserialport-0.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY + cp $src_dir\dependencies\libs\64\libusb-1.0.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 { + 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 + } +} diff --git a/artifact_manifest.txt.cmakein b/artifact_manifest.txt.cmakein index 9e296aac4..0d7427b20 100644 --- a/artifact_manifest.txt.cmakein +++ b/artifact_manifest.txt.cmakein @@ -83,3 +83,23 @@ 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 + +Windows-MinGW--W64/iio.h +Windows-MinGW-W64/iio_attr.exe +Windows-MinGW-W64/iio_genxml.exe +Windows-MinGW-W64/iio_info.exe +Windows-MinGW-W64/iio_readdev.exe +Windows-MinGW-W64/iio_reg.exe +Windows-MinGW-W64/iio_writedev.exe +Windows-MinGW-W64/libgcc_s_seh-1.dll +Windows-MinGW-W64/libiconv-2.dll +Windows-MinGW-W64/libiio.dll +Windows-MinGW-W64/libiio.dll.a +Windows-MinGW-W64/liblzma-5.dll +Windows-MinGW-W64/libserialport-0.dll +Windows-MinGW-W64/libstdc++-6.dll +Windows-MinGW-W64/libusb-1.0.dll +Windows-MinGW-W64/libwinpthread-1.dll +Windows-MinGW-W64/libxml2-2.dll +Windows-MinGW-W64/zlib1.dll +Windows-MinGW-W64/libiio-py39-amd64.tar.gz diff --git a/azure-pipelines.yml b/azure-pipelines.yml index e39eeb035..ee86d0e92 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -96,6 +96,82 @@ stages: targetPath: '$(Build.ArtifactStagingDirectory)' artifactName: '$(artifactName)' + ############################################# + - job: MinGWBuilds + strategy: + matrix: + MinGW_W64: + COMPILER: 'MinGW Makefiles' + ARCH: 'x86_64' + USE_CSHARP: 'OFF' + artifactName: 'Windows-MinGW-W64' + pool: + vmImage: 'windows-2022' + steps: + - checkout: self + fetchDepth: 1 + clean: true + - task: UsePythonVersion@0 + inputs: + versionSpec: '3.9' + - task: PowerShell@2 + displayName: 'Dependencies' + inputs: + 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' + - task: CopyFiles@2 + displayName: 'Copy .exe files' + inputs: + sourceFolder: '$(Agent.BuildDirectory)/s/build-x64/tests' + contents: '*.exe' + targetFolder: '$(Build.ArtifactStagingDirectory)' + - task: CopyFiles@2 + displayName: 'Copy iio.h header' + inputs: + sourceFolder: '$(Agent.BuildDirectory)/s/' + contents: 'iio.h' + targetFolder: '$(Build.ArtifactStagingDirectory)' + - task: CopyFiles@2 + displayName: 'Copy libiio.dll and libiio.dll.a' + inputs: + sourceFolder: '$(Agent.BuildDirectory)/s/build-x64' + contents: | + libiio.dll + libiio.dll.a + targetFolder: '$(Build.ArtifactStagingDirectory)' + - task: CopyFiles@2 + displayName: 'Copy .tar.gz files' + inputs: + sourceFolder: '$(Agent.BuildDirectory)/s/build-x64/bindings/python' + contents: '*.gz' + targetFolder: '$(Build.ArtifactStagingDirectory)' + - task: PowerShell@2 + displayName: 'Copy dependencies' + inputs: + targetType: 'filePath' + filePath: .\CI\publish_deps.ps1 + - task: PublishPipelineArtifact@1 + inputs: + targetPath: '$(Build.ArtifactStagingDirectory)' + artifactName: '$(artifactName)' + ############################################# - job: WindowsBuilds # Host Box @@ -105,11 +181,13 @@ stages: vmImage: 'windows-2022' COMPILER: 'Visual Studio 17 2022' ARCH: 'x64' + USE_CSHARP: 'ON' artifactName: 'Windows-VS-2022-x64' VS2019: vmImage: 'windows-2019' COMPILER: 'Visual Studio 16 2019' ARCH: 'x64' + USE_CSHARP: 'ON' artifactName: 'Windows-VS-2019-x64' pool: vmImage: $[ variables['vmImage'] ] From af19492ce0a1d150cde1693c9c47dfdbe56d9e6b Mon Sep 17 00:00:00 2001 From: "Travis F. Collins" Date: Tue, 27 Jun 2023 12:05:26 -0600 Subject: [PATCH 3/3] Add rpathing and libusb updates for macOS CI Signed-off-by: Travis F. Collins --- CI/azure/macos_tar_fixup.sh | 71 +++++++++++++++++++++++++++++++++++++ CI/azure/prepare_assets.sh | 0 azure-pipelines.yml | 3 ++ 3 files changed, 74 insertions(+) create mode 100644 CI/azure/macos_tar_fixup.sh mode change 100755 => 100644 CI/azure/prepare_assets.sh diff --git a/CI/azure/macos_tar_fixup.sh b/CI/azure/macos_tar_fixup.sh new file mode 100644 index 000000000..3b4b30f84 --- /dev/null +++ b/CI/azure/macos_tar_fixup.sh @@ -0,0 +1,71 @@ +#!/bin/bash -xe + +# Extract tar.gz to temp folder +tarname=$(find . -maxdepth 1 -name '*.tar.gz') +if [ -z "${tarname}" ]; then + echo "tar.gz not found" + exit 1 +fi +# Remove .tar.gz from filename +subfoldername=$(echo "${tarname}" | rev | cut -b 8- | rev) + +mkdir -p temp_tar +tar -xzf "${tarname}" -C temp_tar +mv "temp_tar/${subfoldername}" temp +cd temp + +# Update rpath of library and tools +libusb_loc=$(find $(brew --cellar) -name libusb-1.0.dylib) +libxml_loc=$(find $(brew --cellar) -name libxml2.dylib) +libserialport_loc=$(find $(brew --cellar) -name libserialport.dylib) +libiio_loc=$(find . -name iio | grep Versions) +libiioheader_loc=$(find . -name iio.h) + +if [ ! -f "${libusb_loc}" ]; then + echo "libusb library not found" + exit 1 +fi +if [ ! -f "${libxml_loc}" ]; then + echo "libxml library not found" + exit 1 +fi +if [ ! -f "${libserialport_loc}" ]; then + echo "libserialport library not found" + exit 1 +fi + +# Create links to framework files +mkdir -p usr/local/{lib,include} +ln -fs "${libiio_loc}" usr/local/lib/libiio.dylib +ln -fs "${libiioheader_loc}" usr/local/include/iio.h + +# Copy dependent libs to local libs +cp "${libusb_loc}" usr/local/lib/ +cp "${libxml_loc}" usr/local/lib/ +cp "${libserialport_loc}" usr/local/lib/ +chmod +w usr/local/lib/libusb-1.0.dylib +chmod +w usr/local/lib/libxml2.dylib +chmod +w usr/local/lib/libserialport.dylib +install_name_tool -id @rpath/libusb-1.0.dylib usr/local/lib/libusb-1.0.dylib +install_name_tool -id @rpath/libxml2.dylib usr/local/lib/libxml2.dylib +install_name_tool -id @rpath/libserialport.dylib usr/local/lib/libserialport.dylib + +# Update rpath of library +install_name_tool -change "${libusb_loc}" "@rpath/libusb-1.0.dylib" "${libiio_loc}" +install_name_tool -change "${libxml_loc}" "@rpath/libxml2.dylib" "${libiio_loc}" +install_name_tool -change "${libserialport_loc}" "@rpath/libserialport.dylib" "${libiio_loc}" +install_name_tool -add_rpath @loader_path/. "${libiio_loc}" + +# Update tools +cd Library/Frameworks/iio.framework/Tools +for tool in *; +do + install_name_tool -add_rpath @loader_path/../.. "${tool}" +done +cd ../../../../ + +# Remove old tar and create new one +rm "../${tarname}" +tar -czf "../${tarname}" . +cd .. +rm -rf temp diff --git a/CI/azure/prepare_assets.sh b/CI/azure/prepare_assets.sh old mode 100755 new mode 100644 diff --git a/azure-pipelines.yml b/azure-pipelines.yml index ee86d0e92..95bf6481d 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -321,6 +321,9 @@ stages: cmake .. -Werror=dev -DCOMPILE_WARNING_AS_ERROR=ON -DOSX_PACKAGE=OFF -DENABLE_PACKAGING=ON -DCPP_BINDINGS=ON -DPYTHON_BINDINGS=ON -DWITH_SERIAL_BACKEND=OFF -DWITH_ZSTD=OFF -DCPACK_SYSTEM_NAME=${ARTIFACTNAME} -DCMAKE_SYSTEM_NAME="Darwin" make make package + mv ../CI/azure/macos_tar_fixup.sh . + chmod +x macos_tar_fixup.sh + ./macos_tar_fixup.sh cd .. displayName: 'Build tar' - script: |