Skip to content

Commit

Permalink
CI: integrate dependencies build script for msvc
Browse files Browse the repository at this point in the history
Switch to new script and modify the paths form cmake command and also
the path from where the dll files were copied.

The old script build_win.ps1 was renamed in build_win_msvc.ps1 because
now it supports just the msvc compiler, eliminating the support for
mingw because was not needed anymore.

Signed-off-by: Andreea Andrisan <[email protected]>
  • Loading branch information
AAndrisa committed Sep 12, 2024
1 parent d2adbd3 commit 994e168
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 70 deletions.
26 changes: 0 additions & 26 deletions CI/build_win.ps1

This file was deleted.

32 changes: 32 additions & 0 deletions CI/build_win_msvc.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_preference_variables?view=powershell-7.2#erroractionpreference
$ErrorActionPreference = "Stop"
$ErrorView = "NormalView"

echo "Running cmake for $Env:COMPILER on 64 bit..."
mkdir build-msvc
cp .\libiio.iss.cmakein .\build-msvc
cd build-msvc
if ( "$Env:COMPILER" -eq "Visual Studio 17 2022" ){
$VS_version="VS2022"
}elseif ( "$Env:COMPILER" -eq "Visual Studio 16 2019" ) {
$VS_version="VS2019"
}
cmake -G "$Env:COMPILER" -DPYTHON_EXECUTABLE:FILEPATH=$(python -c "import os, sys; print(os.path.dirname(sys.executable) + '\python.exe')") -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 -DCPP_BINDINGS=ON -DCSHARP_BINDINGS:BOOL=ON `
-DLIBXML2_LIBRARIES="$Env:BUILD_SOURCESDIRECTORY\deps\libxml2-install\lib\libxml2.lib" -DLIBXML2_INCLUDE_DIR="$Env:BUILD_SOURCESDIRECTORY\deps\libxml2-install\include\libxml2" `
-DLIBUSB_LIBRARIES="$Env:BUILD_SOURCESDIRECTORY\deps\libusb\$VS_version\MS64\dll\libusb-1.0.lib" -DLIBUSB_INCLUDE_DIR="$Env:BUILD_SOURCESDIRECTORY\deps\libusb\include" `
-DLIBSERIALPORT_LIBRARIES="$Env:BUILD_SOURCESDIRECTORY\deps\libserialport\x64\Release\libserialport.lib" -DLIBSERIALPORT_INCLUDE_DIR="$Env:BUILD_SOURCESDIRECTORY\deps\libserialport" `
-DLIBZSTD_LIBRARIES="$Env:BUILD_SOURCESDIRECTORY\deps\zstd\build\VS2010\bin\x64_Release\libzstd.lib" -DLIBZSTD_INCLUDE_DIR="$Env:BUILD_SOURCESDIRECTORY\deps\zstd\lib" ..

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 sdist
Get-ChildItem dist\pylibiio-*.tar.gz | Rename-Item -NewName "libiio-py39-amd64.tar.gz"
mv .\dist\*.gz .
rm .\dist\*.gz
34 changes: 11 additions & 23 deletions CI/publish_deps.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,7 @@
$ErrorActionPreference = "Stop"
$ErrorView = "NormalView"

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

cd $src_dir
mkdir dependencies
cd dependencies
wget http://swdownloads.analog.com/cse/build/libiio-deps-20220517.zip -OutFile "libiio-win-deps.zip"
7z x -y "libiio-win-deps.zip"

# Version numbers inside this directory change all the time; print what's
# currently in the folder to make it easier to debug CI breakages on MinGW.
dir C:\ghcup\ghc\

if ($COMPILER -eq "MinGW Makefiles") {
if ("$Env:COMPILER" -eq "MinGW Makefiles") {
cp C:\msys64\mingw64\bin\libserialport-0.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY
cp C:\msys64\mingw64\bin\libusb-1.0.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY
cp C:\msys64\mingw64\bin\libxml2-2.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY
Expand All @@ -27,18 +14,19 @@ if ($COMPILER -eq "MinGW Makefiles") {
cp C:\msys64\mingw64\bin\libwinpthread-1.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY
cp C:\msys64\mingw64\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
cp $src_dir\dependencies\libs\64\libzstd.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'
if ( "$Env:COMPILER" -eq "Visual Studio 17 2022" ){
$VS_version="VS2022"
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
} else {
cd 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Redist\MSVC\14.29.30133\x64\Microsoft.VC142.CRT'
}elseif ( "$Env:COMPILER" -eq "Visual Studio 16 2019" ) {
$VS_version="VS2019"
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
}
cp $Env:BUILD_SOURCESDIRECTORY\deps\libxml2-install\bin\libxml2.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY
cp $Env:BUILD_SOURCESDIRECTORY\deps\libusb\$VS_version\MS64\dll\libusb-1.0.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY
cp $Env:BUILD_SOURCESDIRECTORY\deps\libserialport\x64\Release\libserialport.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY
cp $Env:BUILD_SOURCESDIRECTORY\deps\zstd\build\VS2010\bin\x64_Release\libzstd.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY
}
31 changes: 10 additions & 21 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,13 @@ stages:
vmImage: 'windows-2022'
COMPILER: 'Visual Studio 17 2022'
ARCH: 'x64'
USE_CSHARP: 'ON'
PLATFORM_TOOLSET: 'v143'
artifactName: 'Windows-VS-2022-x64'
VS2019:
vmImage: 'windows-2019'
COMPILER: 'Visual Studio 16 2019'
ARCH: 'x64'
USE_CSHARP: 'ON'
PLATFORM_TOOLSET: 'v142'
artifactName: 'Windows-VS-2019-x64'
pool:
vmImage: $[ variables['vmImage'] ]
Expand All @@ -198,32 +198,21 @@ stages:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.9'
- task: PowerShell@2
displayName: 'Dependencies'
- task: CmdLine@2
displayName: 'Build dependecies'
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-deps-20220517.zip -OutFile "libiio-win-deps.zip"
7z x -y "C:\libiio-win-deps.zip"
.\CI\azure\windows_build_deps.cmd
- task: PowerShell@2
inputs:
targetType: 'filePath'
filePath: .\CI\build_win.ps1
filePath: .\CI\build_win_msvc.ps1
displayName: 'Build'
- task: CopyFiles@2
displayName: 'Copy libraries'
inputs:
sourceFolder: '$(Agent.BuildDirectory)/s/build-$(ARCH)/Release'
sourceFolder: '$(Agent.BuildDirectory)/s/build-msvc/Release'
targetFolder: '$(Build.ArtifactStagingDirectory)'
- task: CopyFiles@2
displayName: 'Copy public headers'
Expand All @@ -233,19 +222,19 @@ stages:
- task: CopyFiles@2
displayName: 'Copy .exe files'
inputs:
sourceFolder: '$(Agent.BuildDirectory)/s/build-$(ARCH)/utils/Release'
sourceFolder: '$(Agent.BuildDirectory)/s/build-msvc/utils/Release'
contents: '*.exe'
targetFolder: '$(Build.ArtifactStagingDirectory)'
- task: CopyFiles@2
displayName: 'Copy .tar.gz files'
inputs:
sourceFolder: '$(Agent.BuildDirectory)/s/build-x64/bindings/python'
sourceFolder: '$(Agent.BuildDirectory)/s/build-msvc/bindings/python'
contents: '*.gz'
targetFolder: '$(Build.ArtifactStagingDirectory)'
- task: CopyFiles@2
displayName: 'Copy libiio-sharp.dll file'
inputs:
sourceFolder: '$(Agent.BuildDirectory)/s/build-$(ARCH)/bindings/csharp'
sourceFolder: '$(Agent.BuildDirectory)/s/build-msvc/bindings/csharp'
contents: 'libiio-sharp.dll'
targetFolder: '$(Build.ArtifactStagingDirectory)'
- task: PowerShell@2
Expand Down

0 comments on commit 994e168

Please sign in to comment.