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

Windows dependencies build #1197

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
35 changes: 35 additions & 0 deletions CI/azure/build_mingw.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/bash.exe
set -xe

init_env() {
export ARCH=x86_64
export MINGW_VERSION=mingw64
export CC=/${MINGW_VERSION}/bin/${ARCH}-w64-mingw32-gcc.exe
export CXX=/${MINGW_VERSION}/bin/${ARCH}-w64-mingw32-g++.exe
export CMAKE="/$MINGW_VERSION/bin/cmake"

}

install_pacman_deps() {
WINDEPS="mingw-w64-x86_64-libserialport \
mingw-w64-x86_64-libusb \
mingw-w64-x86_64-zstd \
mingw-w64-x86_64-libxml2 \
mingw-w64-x86_64-python3 \
mingw-w64-x86_64-cmake \
mingw-w64-x86_64-gcc \
cmake
"
pacman -S --noconfirm --needed $WINDEPS
}

build_libiio() {
$CMAKE -G "MinGW Makefiles" -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=OFF ..
$CMAKE --build . --config Release
}

init_env
$@
40 changes: 40 additions & 0 deletions CI/azure/windows_build_deps.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
:: this script will download and build the necessary dependencies of libiio for windows operating systems
:: if is run from the root of the libiio project all the dependencies will be found in the deps folder of the project
:: in case you already have some dependencies build just comment them in the script and during compilation of libiio specify the path
:: export as environment variables the ARCH, PLATFORM_TOOLSET and COMPILER used for visual studio build
:: ex: set ARCH=x64, PLATFROM_TOOLSET=v143 and COMPILER='Visual Studio 17 2022' for VS2022

IF not exist .\deps (
echo Directory does not exist. Creating it...
mkdir .\deps
) ELSE (
echo Directory already exists.
cd .\deps
)
choco install -y wget

:: set the msbuild compiler in order to build from terminal the visual studio projects
SETLOCAL ENABLEDELAYEDEXPANSION
IF "%COMPILER%" == "Visual Studio 16 2019" SET vswhere_params=-version [16,17) -products *
IF "%COMPILER%" == "Visual Studio 17 2022" SET vswhere_params=-version [17,18) -products *
SET vswhere="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
FOR /F "USEBACKQ TOKENS=*" %%F IN (`%vswhere% !vswhere_params! -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe`) DO (
SET msbuild="%%F"
)
:: clone the zstd repo and build it with the desierd configuration
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

desierd

should be desired? (spelling)

git clone --branch v1.5.6 https://github.com/facebook/zstd.git
%msbuild% .\zstd\build\VS2010\zstd.sln /p:Platform=%ARCH% /p:Configuration=Release /p:PlatformToolset=%PLATFORM_TOOLSET%

:: download libusb release
wget https://github.com/libusb/libusb/releases/download/v1.0.27/libusb-1.0.27.7z
7z x -y .\libusb-1.0.27.7z -o".\libusb"

:: download and build libxml2 library with cmake
wget https://download.gnome.org/sources/libxml2/2.9/libxml2-2.9.14.tar.xz
cmake -E tar xf .\libxml2-2.9.14.tar.xz
cmake -DCMAKE_INSTALL_PREFIX=libxml2-install -DLIBXML2_WITH_ICONV=OFF -DLIBXML2_WITH_LZMA=OFF -DLIBXML2_WITH_PYTHON=OFF -DLIBXML2_WITH_ZLIB=OFF -S .\libxml2-2.9.14\ -B libxml2-build
cmake --build libxml2-build --config Release --target install

:: clone and build libserialport project
git clone https://github.com/sigrokproject/libserialport.git
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for other repos - you are getting specific versions. for libserialport - you are grabbing tip of master - is that what you want to do? (I'm not sure there is a better idea, since the newest release is so old)...

Copy link
Collaborator Author

@AAndrisa AAndrisa Sep 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another idea would be to specifically git checkout a commit from the master branch, in case other commits will be added in which case that might brake things for us. (if this is not ok, I will leave it as it is)

%msbuild% .\libserialport\libserialport.vcxproj /p:Platform=%ARCH% /p:Configuration=Release /p:PlatformToolset=%PLATFORM_TOOLSET%
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
54 changes: 21 additions & 33 deletions CI/publish_deps.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,31 @@
$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") {
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
cp C:\ghcup\ghc\9.2.8\mingw\bin\libgcc_s_seh-1.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY
cp C:\ghcup\ghc\9.6.5\mingw\bin\libiconv-2.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY
cp C:\ghcup\ghc\9.6.5\mingw\bin\zlib1.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY
cp C:\ghcup\ghc\9.6.5\mingw\bin\liblzma-5.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY
cp C:\ghcup\ghc\9.6.5\mingw\bin\libwinpthread-1.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY
cp C:\ghcup\ghc\9.6.5\mingw\bin\libxml2-2.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY
cp C:\ghcup\ghc\9.2.8\mingw\bin\libstdc++-6.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY
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
cp C:\msys64\mingw64\bin\libzstd.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY
cp C:\msys64\mingw64\bin\libgcc_s_seh-1.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY
cp C:\msys64\mingw64\bin\libiconv-2.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY
cp C:\msys64\mingw64\bin\zlib1.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY
cp C:\msys64\mingw64\bin\liblzma-5.dll $env:BUILD_ARTIFACTSTAGINGDIRECTORY
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
}
60 changes: 41 additions & 19 deletions artifact_manifest.txt.cmakein
Original file line number Diff line number Diff line change
Expand Up @@ -48,60 +48,82 @@ Ubuntu-x390x/libiio-@[email protected]@[email protected]
Debian12-arm/libiio-@[email protected]@[email protected]
Debian12-arm/libiio-@[email protected]@[email protected]

Windows-VS-2019-x64/iio.h
Windows-VS-2019-x64/iio/iio.h
Windows-VS-2019-x64/iio/iio-backend.h
Windows-VS-2019-x64/iio/iiod-client.h
Windows-VS-2019-x64/iio/iio-debug.h
Windows-VS-2019-x64/iio/iio-lock.h
Windows-VS-2019-x64/iio_attr.exe
Windows-VS-2019-x64/iio_genxml.exe
Windows-VS-2019-x64/iio_attr.exe
Windows-VS-2019-x64/iio_event.exe
Windows-VS-2019-x64/iio_info.exe
Windows-VS-2019-x64/iio_readdev.exe
Windows-VS-2019-x64/iio_rwdev.exe
Windows-VS-2019-x64/iio_reg.exe
Windows-VS-2019-x64/iio_writedev.exe
Windows-VS-2019-x64/iiod_responder.lib
Windows-VS-2019-x64/libiio-py39-amd64.tar.gz
Windows-VS-2019-x64/iio.dll
Windows-VS-2019-x64/libiio-sharp.dll
Windows-VS-2019-x64/libiio.dll
Windows-VS-2019-x64/libiio.exp
Windows-VS-2019-x64/libiio1.dll
Windows-VS-2019-x64/libiio1.exp
Windows-VS-2019-x64/libiio.iss
Windows-VS-2019-x64/libiio.lib
Windows-VS-2019-x64/libserialport-0.dll
Windows-VS-2019-x64/libiio1.lib
Windows-VS-2019-x64/libiio1.pdb
Windows-VS-2019-x64/libserialport.dll
Windows-VS-2019-x64/libusb-1.0.dll
Windows-VS-2019-x64/libxml2.dll
Windows-VS-2019-x64/libzstd.dll
Windows-VS-2019-x64/msvcp140.dll
Windows-VS-2019-x64/vcruntime140.dll

Windows-VS-2022-x64/iio.h
Windows-VS-2022-x64/iio/iio.h
Windows-VS-2022-x64/iio/iio-backend.h
Windows-VS-2022-x64/iio/iiod-client.h
Windows-VS-2022-x64/iio/iio-debug.h
Windows-VS-2022-x64/iio/iio-lock.h
Windows-VS-2022-x64/iio_attr.exe
Windows-VS-2022-x64/iio_attr.exe
Windows-VS-2022-x64/iio_genxml.exe
Windows-VS-2022-x64/iio_event.exe
Windows-VS-2022-x64/iio_info.exe
Windows-VS-2022-x64/iio_readdev.exe
Windows-VS-2022-x64/iio_rwdev.exe
Windows-VS-2022-x64/iio_reg.exe
Windows-VS-2022-x64/iio_writedev.exe
Windows-VS-2022-x64/iiod_responder.lib
Windows-VS-2022-x64/libiio-py39-amd64.tar.gz
Windows-VS-2022-x64/iio.dll
Windows-VS-2022-x64/libiio-sharp.dll
Windows-VS-2022-x64/libiio.dll
Windows-VS-2022-x64/libiio.exp
Windows-VS-2022-x64/libiio1.dll
Windows-VS-2022-x64/libiio1.exp
Windows-VS-2022-x64/libiio.iss
Windows-VS-2022-x64/libiio.lib
Windows-VS-2022-x64/libserialport-0.dll
Windows-VS-2022-x64/libiio1.lib
Windows-VS-2022-x64/libiio1.pdb
Windows-VS-2022-x64/libserialport.dll
Windows-VS-2022-x64/libusb-1.0.dll
Windows-VS-2022-x64/libxml2.dll
Windows-VS-2022-x64/libzstd.dll
Windows-VS-2022-x64/msvcp140.dll
Windows-VS-2022-x64/vcruntime140.dll

Windows-MinGW--W64/iio.h
Windows-MinGW-W64/iio/iio.h
Windows-MinGW-W64/iio/iio-backend.h
Windows-MinGW-W64/iio/iiod-client.h
Windows-MinGW-W64/iio/iio-debug.h
Windows-MinGW-W64/iio/iio-lock.h
Windows-MinGW-W64/iio_attr.exe
Windows-MinGW-W64/iio_event.exe
Windows-MinGW-W64/iio_genxml.exe
Windows-MinGW-W64/iio_info.exe
Windows-MinGW-W64/iio_readdev.exe
Windows-MinGW-W64/iio_rwdev.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/libiio1.dll
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/libzstd.dll
Windows-MinGW-W64/zlib1.dll
Windows-MinGW-W64/libiio-py39-amd64.tar.gz
Loading
Loading