diff --git a/CI/windows/install_deps.ps1 b/CI/windows/install_deps.ps1 index 45fe64d1..cb5355e1 100644 --- a/CI/windows/install_deps.ps1 +++ b/CI/windows/install_deps.ps1 @@ -10,6 +10,9 @@ $DEPS_DIR = Join-Path $SRC_DIR "deps" $BUILD_DIR = Join-Path $SRC_DIR "build-$ARCH" $LIBIIO_VERSION = "libiio-v0" +Write-Output "Python located at:" +Get-Command python + Write-Output "Running script from $SRC_DIR" Get-ChildItem @@ -34,12 +37,17 @@ function Get-Libiio-Deps { 7z x -y "libxml.7z" Remove-Item "libxml.7z" + Get-ChildItem + + Write-Output "## Installing libiio-deps" New-Item -Path (Join-Path $SRC_DIR "libiio-deps") -ItemType Directory Set-Location (Join-Path $SRC_DIR "libiio-deps") Invoke-WebRequest -Uri "http://swdownloads.analog.com/cse/build/libiio-deps-20220517.zip " -OutFile "libiio-win-deps.zip" 7z x -y "libiio-win-deps.zip" Remove-Item "libiio-win-deps.zip" + + Get-ChildItem } function Install-Libiiio { @@ -58,6 +66,8 @@ function Install-Libiiio { Write-Output "## Running cmake for $COMPILER on $ARCH..." # x64 instead of ARCH in example New-Item -Path (Join-Path $SRC_DIR "libiio\build-$ARCH") -ItemType Directory Copy-Item -Path ".\libiio.iss.cmakein" -Destination (Join-Path $SRC_DIR "libiio\build-$ARCH") + + Set-Location (Join-Path $SRC_DIR "libiio\build-$ARCH") Write-Output "## Inside build-$ARCH before cmake" @@ -73,6 +83,7 @@ function Install-Libiiio { # Try the cmake config from libiio CI scripts $pythonExecutable = python -c "import sys; print(sys.executable)" + Write-Output "## pythonExecutable = $pythonExecutable " cmake -G "$COMPILER" ` -DPYTHON_EXECUTABLE:FILEPATH=$pythonExecutable ` -DCMAKE_SYSTEM_PREFIX_PATH="C:" ` @@ -82,16 +93,22 @@ function Install-Libiiio { -DWITH_USB_BACKEND=ON ` -DWITH_SERIAL_BACKEND=ON ` -DPYTHON_BINDINGS=ON ` - -DCSHARP_BINDINGS:BOOL=$USE_CSHARP ` + -DCSHARP_BINDINGS:BOOL=OFF ` -DLIBXML2_LIBRARIES="$LIBIIO_DEPS_LIBS_PATH\libxml2.lib" ` -DLIBUSB_LIBRARIES="$LIBIIO_DEPS_LIBS_PATH\libusb-1.0.lib" ` -DLIBSERIALPORT_LIBRARIES="$LIBIIO_DEPS_LIBS_PATH\libserialport.dll.a" ` + -DLIBUSB_INCLUDE_DIR=Join-Path $SRC_DIR "libiio-deps\libs\libusb-1.0" ` + -DLIBXML2_INCLUDE_DIR=Join-Path $SRC_DIR "libiio-deps\libs\libxml2" ` .. # Don't know if i need these -> Where do they come from? - # -DLIBUSB_INCLUDE_DIR="C:\\include\\libusb-1.0" ` - # -DLIBXML2_INCLUDE_DIR="C:\\include\\libxml2" ` cmake --build . --config Release + Get-ChildItem + + if ($LASTEXITCODE -ne 0) { + Write-Output "## cmake failed with exit code $LASTEXITCODE" + exit $LASTEXITCODE + } # TODO: REVIEW THIS: is the executable installed? if so do i need it in the build dir / artifacts staging directory ? # Move to build dir - move .dll @@ -118,7 +135,7 @@ function Install-Swig { Remove-Item "swigwin-4.0.0.zip" Set-Location (Join-Path "swig" "swigwin-4.0.0") xcopy * .. /s /e /h /Q - + Get-ChildItem } function Install-Inno-Setup { @@ -133,6 +150,7 @@ function Install-Inno-Setup { $NEW_PATH = $CRNT_PATH + ";" + $NEW_PATH [System.Environment]::SetEnvironmentVariable('PATH', $NEW_PATH, [System.EnvironmentVariableTarget]::Machine) } + Get-ChildItem } function Install-Glog { @@ -159,6 +177,7 @@ function Install-Glog { cmake -DWITH_GFLAGS=off -DBUILD_SHARED_LIBS=on -G $GENERATOR -A $ARCH .. cmake --build . --target install --config "Release" + Get-ChildItem } function Install-All { diff --git a/CI/windows/make_windows.ps1 b/CI/windows/make_windows.ps1 index 18875bba..0a498687 100644 --- a/CI/windows/make_windows.ps1 +++ b/CI/windows/make_windows.ps1 @@ -2,25 +2,86 @@ $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 -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 \ No newline at end of file +$COMPILER = $Env:COMPILER +$ARCH = $Env:ARCH + +$SRC_DIR = Get-Location +$BUILD_DIR = Join-Path $SRC_DIR "build-$ARCH" +$DIST_DIR = Join-Path $SRC_DIR "build-$ARCH\dist" + +if (-not (Test-Path -Path (Join-Path $SRC_DIR "build-$ARCH\dist"))) { + New-Item -Path $DIST_DIR -ItemType Directory +} + +function Build-Python-Wheel { + param( + [string]$PLATFORM + [string]$PYTHON_PATH + ) + # TODO: extend path to include swig => export PATH="/c/swig/;/c/swig/Lib/;$OLD_PATH" => TO BE TESTED + $OLD_PATH = [System.Environment]::GetEnvironmentVariable('PATH', [System.EnvironmentVariableTarget]::Machine) + $SWIG_PATH= (Join-Path $SRC_DIR "swig") + ";" + (Join-Path $SRC_DIR "swig\Lib") + $NEW_PATH = $SWIG_PATH + ";" + $OLD_PATH + [System.Environment]::SetEnvironmentVariable('PATH', $NEW_PATH, [System.EnvironmentVariableTarget]::Machine) + + Invoke-Expression "$PYTHON_PATH -m pip install --user --upgrade pip setuptools wheel twine build virtualenv" + $env:COMPILE_BINDINGS = $true + Invoke-Expression "$PyPath -m build" + Remove-Item Env:\COMPILE_BINDINGS + Copy-Item "dist/libm2k*.whl" "$BUILD_DIR\dist" +} + +function Build-Libm2k { + param( + [string]$PLATFORM + [string]$PYTHON_VERSION, + [string]$PYTHON_PATH, + [string]$GENERATOR, + [string]$ARCH, + ) + + # Create the official build directory for this platform + New-Item -Path (Join-Path $SRC_DIR "\build-$PLATFORM\dist") -ItemType Directory + + # Create and clear up the temporary build directory for this platform + $TEMP_BUILD_DIR = Join-Path $SRC_DIR "tmp-build-$PLATFORM" + if (Test-Path -Path $TEMP_BUILD_DIR) { + Remove-Item $TEMP_BUILD_DIR -Recurse -Force + } + New-Item -Path $TEMP_BUILD_DIR -ItemType Directory + + # Q: do i need to add python path manually if already did this in a previous step in the CI job? + # $OLD_PATH = [System.Environment]::GetEnvironmentVariable('PATH', [System.EnvironmentVariableTarget]::Machine) + # $NEW_PATH = $SWIG_PATH + ";" + $OLD_PATH + # [System.Environment]::SetEnvironmentVariable('PATH', $NEW_PATH, [System.EnvironmentVariableTarget]::Machine) + Set-Location (Join-Path $SRC_DIR "tmp-build-$ARCH") + + cmake -G $GENERATOR ` + -A $ARCH ` + -DIIO_LIBRARIES:FILEPATH="$DEST_LIBIIO"-"$PLATFORM"/libiio.lib ` + -DIIO_INCLUDE_DIRS:PATH="$DEST_LIBIIO"-"$PLATFORM" ` + -DCMAKE_CONFIGURATION_TYPES=RELEASE ` + -DSWIG_DIR=/c/swig/Lib ` + -DSWIG_EXECUTABLE=/c/swig/swig.exe ` + -DSWIG_VERSION="4.0.0" ` + -DENABLE_TOOLS=ON ` + -DENABLE_LOG=ON ` + -DPython_EXECUTABLE="$PY_PATH/python.exe" ` + -DBUILD_EXAMPLES=ON ` + -DENABLE_CSHARP=ON ` + -DENABLE_LABVIEW=ON ` + .. + + cmake --build . --config Release + + cat setup.py + + $PY_SUFFIX="" + if ($PLATFORM -eq "win64") { + $PY_SUFFIX = "-x64" + } + + Build-Python-Wheel -PLATFORM $PLATFORM -PYTHON_PATH $PYTHON_PATH +} + +Build-Libm2k -PLATFORM "win32" -PYTHON_VERSION 37 -PYTHON_PATH "C:\Python39" -GENERATOR $COMPILER -ARCH $ARCH \ No newline at end of file