Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI:add MinGW builds #991

Merged
merged 3 commits into from
Jul 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions CI/azure/zip.txt → CI/azure/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down
71 changes: 71 additions & 0 deletions CI/azure/macos_tar_fixup.sh
Original file line number Diff line number Diff line change
@@ -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
21 changes: 18 additions & 3 deletions CI/azure/prepare_assets.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down Expand Up @@ -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() {
Expand Down
3 changes: 2 additions & 1 deletion CI/build_win.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ $ErrorActionPreference = "Stop"
$ErrorView = "NormalView"

$COMPILER=$Env:COMPILER
$USE_CSHARP=$Env:USE_CSHARP
$src_dir=$pwd

echo "Running cmake for $COMPILER on 64 bit..."
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"
Expand Down
38 changes: 25 additions & 13 deletions CI/publish_deps.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
ccraluca marked this conversation as resolved.
Show resolved Hide resolved
}
20 changes: 20 additions & 0 deletions artifact_manifest.txt.cmakein
Original file line number Diff line number Diff line change
Expand Up @@ -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
81 changes: 81 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'] ]
Expand Down Expand Up @@ -243,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: |
Expand Down
2 changes: 1 addition & 1 deletion network.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down