Skip to content

Commit

Permalink
CI:add MinGW build
Browse files Browse the repository at this point in the history
Add MinGW build and modify related files to add artifacts to
SwDownloads and GitHub release.

Signed-off-by: Raluca Groza <raluca.groza@analog.com>
  • Loading branch information
ccraluca authored and pcercuei committed Jul 3, 2023
1 parent 25714d1 commit 9cc2e10
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 23 deletions.
11 changes: 5 additions & 6 deletions CI/azure/zip.txt → CI/azure/README.txt
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
21 changes: 18 additions & 3 deletions CI/azure/prepare_assets.sh
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
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
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
}
}
20 changes: 20 additions & 0 deletions artifact_manifest.txt.cmakein
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
78 changes: 78 additions & 0 deletions azure-pipelines.yml
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

0 comments on commit 9cc2e10

Please sign in to comment.