From 952a18722f5713c2d71eb3dafdf95cf1f24c4dfb Mon Sep 17 00:00:00 2001 From: Andreea Andrisan Date: Thu, 12 Sep 2024 13:33:38 +0300 Subject: [PATCH] CI: integrate dependencies build script for msvc 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 --- CI/build_win.ps1 | 26 -------------------------- CI/build_win_msvc.ps1 | 32 ++++++++++++++++++++++++++++++++ CI/publish_deps.ps1 | 34 +++++++++++----------------------- azure-pipelines.yml | 33 ++++++++++----------------------- 4 files changed, 53 insertions(+), 72 deletions(-) delete mode 100644 CI/build_win.ps1 create mode 100644 CI/build_win_msvc.ps1 diff --git a/CI/build_win.ps1 b/CI/build_win.ps1 deleted file mode 100644 index 51da53306..000000000 --- a/CI/build_win.ps1 +++ /dev/null @@ -1,26 +0,0 @@ -# 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 -$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" -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=$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" -DLIBZSTD_INCLUDE_DIR="C:\\include" -DLIBZSTD_LIBRARIES="C:\\libs\\64\\libzstd.dll.a" .. - -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 diff --git a/CI/build_win_msvc.ps1 b/CI/build_win_msvc.ps1 new file mode 100644 index 000000000..4265cce29 --- /dev/null +++ b/CI/build_win_msvc.ps1 @@ -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 diff --git a/CI/publish_deps.ps1 b/CI/publish_deps.ps1 index d95d5a875..c82a268e3 100644 --- a/CI/publish_deps.ps1 +++ b/CI/publish_deps.ps1 @@ -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 @@ -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 } diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 17bce6c3f..c7701459f 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -180,14 +180,12 @@ stages: VS2022: 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'] ] @@ -198,32 +196,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' @@ -233,19 +220,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