diff --git a/CI/windows/create_installer.ps1 b/CI/windows/create_installer.ps1 index 0e39173c..04fbea57 100644 --- a/CI/windows/create_installer.ps1 +++ b/CI/windows/create_installer.ps1 @@ -1,7 +1,7 @@ $ErrorActionPreference = "Stop" $ErrorView = "NormalView" -$SRC_DIR = Get-Location +$SRC_DIR = Get-Item -Path $env:BUILD_SOURCESDIRECTORY # path to repo function Get-Dll-Paths() { $vsPath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" @@ -30,7 +30,6 @@ function Get-Dll-Paths() { return $result } - Set-Location $SRC_DIR $ddlPaths = Get-Dll-Paths diff --git a/CI/windows/create_zips.ps1 b/CI/windows/create_zips.ps1 index f8ada74a..67d957c6 100644 --- a/CI/windows/create_zips.ps1 +++ b/CI/windows/create_zips.ps1 @@ -5,10 +5,10 @@ $COMPILER = $Env:COMPILER $ARCH = $Env:ARCH $PLATFORM = "win64" -$SRC_DIR = Get-Location +$SRC_DIR = Get-Item -Path $env:BUILD_SOURCESDIRECTORY # path to repo $BUILD_DIR = Join-Path $SRC_DIR "build-$PLATFORM\dist" -$OUTSIDE_BUILD = [System.IO.Path]::GetDirectoryName($SRC_DIR.Path) +$OUTSIDE_BUILD = $SRC_DIR.Parent.FullName $DEST_LIBM2K = Join-Path $OUTSIDE_BUILD "libm2k-$PLATFORM" $DEST_LIBM2K_DIST = Join-Path $DEST_LIBM2K "dist$PLATFORM" diff --git a/CI/windows/install_deps.ps1 b/CI/windows/install_deps.ps1 index 332df49b..e5870376 100644 --- a/CI/windows/install_deps.ps1 +++ b/CI/windows/install_deps.ps1 @@ -1,21 +1,18 @@ $ErrorActionPreference = "Stop" $ErrorView = "NormalView" -# NOTE: this is needed for the Invoke-WebRequest to work -# [Net.ServicePointManager]::SecurityProtocol = "Tls, Tls11, Tls12, Ssl3" - $COMPILER = $Env:COMPILER $ARCH = $Env:ARCH +$PLATFORM = $Env:PLATFORM +$LIBIIO_VERSION = $env:LIBIIO_VERSION -$SRC_DIR = Get-Location -$OUTSIDE_BUILD = [System.IO.Path]::GetDirectoryName($SRC_DIR.Path) -$DEPS_DIR = Join-Path $OUTSIDE_BUILD "deps" # save deps outside libm2k repo +$SRC_DIR = Get-Item -Path $env:BUILD_SOURCESDIRECTORY # path to repo +$OUTSIDE_BUILD = $SRC_DIR.Parent.FullName +$DEPS_DIR = Join-Path $OUTSIDE_BUILD "deps" # $BUILD_DIR = Join-Path $SRC_DIR "build-$ARCH" #libm2k build dir - WAS NOT BEING USED -$LIBIIO_VERSION = "libiio-v0" - -$DEST_LIBIIO = Join-Path $OUTSIDE_BUILD "libiio-$ARCH" +$LIBIIO_COMPILE_OUTPUT = Join-Path $OUTSIDE_BUILD "libiio-$ARCH" Write-Output "Python located at:" Get-Command python @@ -25,119 +22,95 @@ Write-Output "COMPILER = $COMPILER" Write-Output "ARCH = $ARCH" Write-Output "SRC_DIR to $SRC_DIR" Write-Output "DEPS_DIR to $DEPS_DIR" -# Write-Output "BUILD_DIR = $BUILD_DIR" Write-Output "OUTSIDE_BUILD to $OUTSIDE_BUILD" -Write-Output "DEST_LIBIIO = $DEST_LIBIIO" - -Get-ChildItem +Write-Output "LIBIIO_COMPILE_OUTPUT = $LIBIIO_COMPILE_OUTPUT" if (-not (Test-Path -Path ($DEPS_DIR))) { New-Item -Path ($DEPS_DIR) -ItemType Directory } -# if (-not (Test-Path -Path ($BUILD_DIR))) { -# New-Item -Path ($BUILD_DIR) -ItemType Directory -# } - -function Get-Libiio-Deps { #CHECKED +function Get-Libiio-Deps { param ( - [string]$SRC_DIR + [string]$DIR_PATH ) Write-Output "# Building libiio dependencies" + # migh be able to skip this step since libiio deps already contains it Write-Output "## Installing libxml" - New-Item -Path (Join-Path $SRC_DIR "libxml") -ItemType Directory - Set-Location (Join-Path $SRC_DIR "libxml") + $LIBXML_DIR = Join-Path $DIR_PATH "libxml" + New-Item -Path $LIBXML_PATH -ItemType Directory + Set-Location $LIBXML_PATH Invoke-WebRequest -Uri "https://www.zlatkovic.com/pub/libxml/64bit/libxml2-2.9.3-win32-x86_64.7z" -OutFile "libxml.7z" 7z x -y "libxml.7z" Remove-Item "libxml.7z" - Get-ChildItem - - # NOTE: this archive contains all he files needed - Write-Output "## Installing libiio-deps" - New-Item -Path (Join-Path $SRC_DIR "libiio-deps") -ItemType Directory - Set-Location (Join-Path $SRC_DIR "libiio-deps") + # NOTE: might only need this zip for libiio deps + Write-Output "## Installing libiio-deps" + $LIBIIO_DEPS_DIR = Join-Path $DIR_PATH "libiio-deps" + New-Item -Path $LIBIIO_DEPS_DIR -ItemType Directory + Set-Location $LIBIIO_DEPS_DIR Invoke-WebRequest -Uri "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" Remove-Item "libiio-win-deps.zip" - # recreate the folder structure needed in the cmake + # NOTE: cmake needs this folder structure Set-Location "include" - New-Item -Path (Join-Path $SRC_DIR "libiio-deps\include\libserialport") -ItemType Directory + New-Item -Path (Join-Path $LIBIIO_DEPS_DIR "include\libserialport") -ItemType Directory Move-Item -Path ./libserialport.h -Destination libserialport - - Get-ChildItem } function Install-Libiiio { param ( - [string]$SRC_DIR, + [string]$DIR_PATH, [string]$GENERATOR, [string]$ARCH ) Write-Output "# Installing libiio" - Set-Location $SRC_DIR + Set-Location $DIR_PATH git clone "https://github.com/analogdevicesinc/libiio" -b $LIBIIO_VERSION "libiio" - Set-Location (Join-Path $SRC_DIR "libiio") + Set-Location (Join-Path $DIR_PATH "libiio") git submodule update --init - 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" - Get-ChildItem - - # NOTE: this is the old cmake command - # cmake -G $GENERATOR -A $ARCH -DCMAKE_CONFIGURATION_TYPES=$CONFIGURATION -DWITH_TESTS=OFF -DENABLE_IPV6:BOOL=OFF -DCMAKE_SYSTEM_PREFIX_PATH="C:" -DCSHARP_BINDINGS:BOOL=OFF -DPYTHON_BINDINGS:BOOL=OFF -DLIBXML2_LIBRARIES="$LIBIIO_DEPS_LIBS_PATH\libxml2.lib" -DLIBUSB_LIBRARIES="$LIBIIO_DEPS_LIBS_PATH\libusb-1.0.lib" .. + Write-Output "## Running cmake for LIBIIO $COMPILER on $ARCH..." # x64 instead of ARCH in example + New-Item -Path (Join-Path $DIR_PATH "libiio\build-$ARCH") -ItemType Directory + Copy-Item -Path ".\libiio.iss.cmakein" -Destination (Join-Path $DIR_PATH "libiio\build-$ARCH") + Set-Location (Join-Path $DIR_PATH "libiio\build-$ARCH") - # Try the cmake config from libiio CI scripts + # cmake config from libiio CI scripts $pythonExecutable = (python -c "import sys; print(sys.executable)") -replace '\\', '/' - $PATH_LIBXML2_LIB = (Join-Path $SRC_DIR "libiio-deps\libs\64\libxml2.lib") -replace '\\', '/' - $PATH_LIBUSB_LIB = (Join-Path $SRC_DIR "libiio-deps\libs\64\libusb-1.0.lib") -replace '\\', '/' - $PATH_LIBSERIALPORT_LIB = (Join-Path $SRC_DIR "libiio-deps\libs\64\libserialport.dll.a") -replace '\\', '/' + $PATH_LIBXML2_LIB = (Join-Path $DIR_PATH "libiio-deps\libs\64\libxml2.lib") -replace '\\', '/' + $PATH_LIBUSB_LIB = (Join-Path $DIR_PATH "libiio-deps\libs\64\libusb-1.0.lib") -replace '\\', '/' + $PATH_LIBSERIALPORT_LIB = (Join-Path $DIR_PATH "libiio-deps\libs\64\libserialport.dll.a") -replace '\\', '/' + $PATH_LIBUSB_INCLUDE = (Join-Path $DIR_PATH "libiio-deps\include\libusb-1.0") -replace '\\', '/' + $PATH_LIBXML2_INCLUDE = (Join-Path $DIR_PATH "libiio-deps\include\libxml2") -replace '\\', '/' + $PATH_LIBSERIALPORT_INCLUDE = (Join-Path $DIR_PATH "libiio-deps\include\libserialport") -replace '\\', '/' - $PATH_LIBUSB_INCLUDE = (Join-Path $SRC_DIR "libiio-deps\include\libusb-1.0") -replace '\\', '/' - $PATH_LIBXML2_INCLUDE = (Join-Path $SRC_DIR "libiio-deps\include\libxml2") -replace '\\', '/' - $PATH_LIBSERIALPORT_INCLUDE = (Join-Path $SRC_DIR "libiio-deps\include\libserialport") -replace '\\', '/' - - Write-Output "## pythonExecutable = $pythonExecutable " - cmake -G "$COMPILER" -DPYTHON_EXECUTABLE:FILEPATH="$pythonExecutable" -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=OFF -DLIBXML2_LIBRARIES="$PATH_LIBXML2_LIB" -DLIBUSB_LIBRARIES="$PATH_LIBUSB_LIB" -DLIBSERIALPORT_LIBRARIES="$PATH_LIBSERIALPORT_LIB" -DLIBUSB_INCLUDE_DIR="$PATH_LIBUSB_INCLUDE" -DLIBXML2_INCLUDE_DIR="$PATH_LIBXML2_INCLUDE" -DLIBSERIALPORT_INCLUDE_DIR="$PATH_LIBSERIALPORT_INCLUDE" .. 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 ? - # same steps as in libiio ci build - # cp .\libiio.iss $env:BUILD_ARTIFACTSTAGINGDIRECTORY # TODO: IS THIS NEEDED?? - - # NOTE: inside build-x64 there is a Release folder with the .dll - # TODO: copy the results in another folder as it s done in the appveyor script => $DEST_LIBIIO - New-Item -Path ($DEST_LIBIIO) -ItemType Directory - - Copy-Item -Path ".\Release\*.dll" -Destination ($DEST_LIBIIO) - Copy-Item -Path ".\Release\*.lib" -Destination ($DEST_LIBIIO) - Copy-Item -Path "*.iss" -Destination ($DEST_LIBIIO) + # After building libiio, copy files to a known directory + if (-not (Test-Path -Path ($LIBIIO_COMPILE_OUTPUT))) { + New-Item -Path ($LIBIIO_COMPILE_OUTPUT) -ItemType Directory + } + Copy-Item -Path ".\Release\*.dll" -Destination ($LIBIIO_COMPILE_OUTPUT) + Copy-Item -Path ".\Release\*.lib" -Destination ($LIBIIO_COMPILE_OUTPUT) + Copy-Item -Path "*.iss" -Destination ($LIBIIO_COMPILE_OUTPUT) Set-Location -Path .. - Copy-Item -Path "iio.h" -Destination ($DEST_LIBIIO) + Copy-Item -Path "iio.h" -Destination ($LIBIIO_COMPILE_OUTPUT) + Copy-Item -Path ".\*.dll" -Destination ($LIBIIO_COMPILE_OUTPUT) # might not need this: no .dll files in libiio sources + # copy .dll used to build libiio + Copy-Item -Path (Join-Path $libiio-deps "libs\64/*.dll") -Destination ($LIBIIO_COMPILE_OUTPUT) - # Note: also copy the dll from the libiio dependencies inside the DEST_LIBIIO folder -> used while making the installer through the .iss file - Set-Location (Join-Path $DEPS_DIR "libiio-deps\libs\64") - Copy-Item -Path ".\*.dll" -Destination ($DEST_LIBIIO) - # NOTE: the result of these commands is a .tar.gz file - Set-Location (Join-Path $SRC_DIR "libiio\build-$ARCH") + + # NOTE: the result of these commands is a .tar.gz file -> copied from LIBIIO CI scripts + Set-Location (Join-Path $DIR_PATH "libiio\build-$ARCH") Set-Location -Path .\bindings\python python.exe setup.py sdist @@ -149,10 +122,10 @@ function Install-Libiiio { function Install-Swig { param ( - [string]$SRC_DIR + [string]$DIR_PATH ) Write-Output "# Installing swig" - Set-Location $SRC_DIR + Set-Location $DIR_PATH # NOTE: -UserAgent "NativeHost" solved the issue with the download - wait timeout before the download starts [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 Invoke-WebRequest -Uri "https://sourceforge.net/projects/swig/files/swigwin/swigwin-4.0.0/swigwin-4.0.0.zip/download" -OutFile "swigwin-4.0.0.zip" -UserAgent "NativeHost" @@ -165,52 +138,49 @@ function Install-Swig { function Install-Inno-Setup { Write-Output "# Installing inno-setup" - choco install InnoSetup -y - $NEW_PATH = "C:\Program Files (x86)\Inno Setup 6" - $CRNT_PATH = [System.Environment]::GetEnvironmentVariable('PATH', [System.EnvironmentVariableTarget]::Machine) - + if ($CRNT_PATH -notcontains $NEW_PATH) { Write-Output "## Adding inno-setup to PATH" + $CRNT_PATH = [System.Environment]::GetEnvironmentVariable('PATH', [System.EnvironmentVariableTarget]::Machine) + $NEW_PATH = "C:\Program Files (x86)\Inno Setup 6" $NEW_PATH = $CRNT_PATH + ";" + $NEW_PATH [System.Environment]::SetEnvironmentVariable('PATH', $NEW_PATH, [System.EnvironmentVariableTarget]::Machine) } - Get-ChildItem } function Install-Glog { param ( - [string]$SRC_DIR, + [string]$DIR_PATH, [string]$CONFIGURATION, [string]$ARCH, [string]$GENERATOR ) Write-Output "# Installing glog" - Set-Location $SRC_DIR + Set-Location $DIR_PATH - if (-not (Test-Path -Path (Join-Path $SRC_DIR "glog"))) { + if (-not (Test-Path -Path (Join-Path $DIR_PATH "glog"))) { git clone --branch v0.3.5 --depth 1 https://github.com/google/glog } - Set-Location (Join-Path $SRC_DIR "glog") + Set-Location (Join-Path $DIR_PATH "glog") git checkout "tags/v0.3.5" - if (-not (Test-Path -Path (Join-Path $SRC_DIR "glog\build_0_4_0-$ARCH"))) { - New-Item -Path (Join-Path $SRC_DIR "glog\build_0_4_0-$ARCH") -ItemType Directory + if (-not (Test-Path -Path (Join-Path $DIR_PATH "glog\build_0_4_0-$ARCH"))) { + New-Item -Path (Join-Path $DIR_PATH "glog\build_0_4_0-$ARCH") -ItemType Directory } - Set-Location ((Join-Path $SRC_DIR "glog\build_0_4_0-$ARCH")) + Set-Location ((Join-Path $DIR_PATH "glog\build_0_4_0-$ARCH")) cmake -DWITH_GFLAGS=off -DBUILD_SHARED_LIBS=on -G "$GENERATOR" -A "$ARCH" .. cmake --build . --target install --config "$CONFIGURATION" - Get-ChildItem } function Install-All { Install-Inno-Setup - Install-Glog -SRC_DIR $DEPS_DIR -CONFIGURATION "Release" -GENERATOR $COMPILER -ARCH "x64" - Install-Swig -SRC_DIR $DEPS_DIR - Get-Libiio-Deps -SRC_DIR $DEPS_DIR - Install-Libiiio -SRC_DIR $DEPS_DIR -GENERATOR $COMPILER -ARCH $ARCH - Set-Location $SRC_DIR + Install-Glog -DIR_PATH $DEPS_DIR -CONFIGURATION "Release" -GENERATOR $COMPILER -ARCH $ARCH + Install-Swig -DIR_PATH $DEPS_DIR + Get-Libiio-Deps -DIR_PATH $DEPS_DIR + Install-Libiiio -DIR_PATH $DEPS_DIR -GENERATOR $COMPILER -ARCH $ARCH } Install-All +Set-Location $SRC_DIR diff --git a/CI/windows/make_windows.ps1 b/CI/windows/make_windows.ps1 index b2c2a573..ece76113 100644 --- a/CI/windows/make_windows.ps1 +++ b/CI/windows/make_windows.ps1 @@ -6,8 +6,8 @@ $COMPILER = $Env:COMPILER $ARCH = $Env:ARCH $PLATFORM = $Env:PLATFORM -$SRC_DIR = Get-Location -$OUTSIDE_BUILD = [System.IO.Path]::GetDirectoryName($SRC_DIR.Path) +$SRC_DIR = Get-Item -Path $env:BUILD_SOURCESDIRECTORY # path to repo +$OUTSIDE_BUILD = $SRC_DIR.Parent.FullName $DEPS_DIR= Join-Path $OUTSIDE_BUILD "deps" $DIST_DIR = Join-Path $SRC_DIR "build-$PLATFORM/dist" @@ -17,26 +17,10 @@ $DEST_LIBIIO = Join-Path $OUTSIDE_BUILD "libiio-$ARCH" Write-Output "SRC DIR = $SRC_DIR" Write-Output "COMPILER = $COMPILER" Write-Output "ARCH = $ARCH" -Write-Output "DIST_DIR = $DIST_DIR" Write-Output "TEMP_BUILD_DIR = $TEMP_BUILD_DIR" Write-Output "DEST_LIBIIO = $DEST_LIBIIO" -function Build-Python-Wheel { - param( - [string]$PLATFORM - ) - Set-Location $TEMP_BUILD_DIR - - python.exe -m pip install --user --upgrade pip setuptools wheel twine build virtualenv - $env:COMPILE_BINDINGS = $true - python.exe -m build - Remove-Item Env:\COMPILE_BINDINGS - - $DEST = Join-Path $SRC_DIR "build-$PLATFORM\dist" - Copy-Item -Path "dist/libm2k*.whl" -Destination $DEST -} - function Build-Libm2k { param( [string]$PLATFORM, @@ -84,28 +68,8 @@ function Build-Libm2k { exit $LASTEXITCODE } Get-ChildItem - - Get-Content setup.py } -function Move-to-Build-Dir { - param( - [string]$PLATFORM - ) - $DEST_DIR = Join-Path $SRC_DIR "build-$PLATFORM\dist" - $TEMP_BUILD_DIR = Join-Path $SRC_DIR "tmp-build-$PLATFORM" - - Set-Location $TEMP_BUILD_DIR - Copy-Item -Path "*.dll" -Destination $DEST_DIR - Copy-Item -Path "*.exe" -Destination $DEST_DIR - Copy-Item -Path "*.lib" -Destination $DEST_DIR - Copy-Item -Path "*.iss" -Destination $DEST_DIR - Set-Location .. -} - -# Build-Libm2k -PLATFORM $PLATFORM -GENERATOR $COMPILER -ARCH $ARCH -# Build-Python-Wheel -PLATFORM $PLATFORM -# Move-to-Build-Dir -PLATFORM $PLATFORM - +Build-Libm2k -PLATFORM $PLATFORM -GENERATOR $COMPILER -ARCH $ARCH Set-Location $SRC_DIR diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 3547b98e..072bab00 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -7,6 +7,7 @@ variables: BRANCH_NAME: $(Build.SourceBranchName) REPO_SLUG: $(Build.Repository.Name) CURRENT_COMMIT: $(Build.SourceVersion) + LIBIIO_VERSION: 'libiio-v0' trigger: - main @@ -188,7 +189,6 @@ jobs: - checkout: self fetchDepth: 1 clean: true - # TODO: review if libiio needs to be rebuilt on every python version - task: UsePythonVersion@0 inputs: versionSpec: '3.11' @@ -197,22 +197,39 @@ jobs: inputs: targetType: filePath filePath: ./CI/windows/install_deps.ps1 - - powershell: | - . ./CI/windows/make_windows.ps1 - Build-Libm2k -PLATFORM $PLATFORM -COMPILER $COMPILER -ARCH $ARCH - displayName: 'Build libm2k' + - task: PowerShell@2 + displayName: "Build libm2k" + inputs: + targetType: 'filePath' + filePath: ./CI/windows/make_windows.ps1 - ${{ each pyVersion in parameters.pythonVersions }}: - task: UsePythonVersion@0 displayName: Use Python ${{ pyVersion }} inputs: versionSpec: '${{ pyVersion }}' - powershell: | - . ./CI/windows/make_windows.ps1 - Build-Python-Wheel -PLATFORM $PLATFORM -PYTHON_PATH $PYTHON_PATH + $SRC_DIR = Get-Location + $TEMP_BUILD_DIR = Join-Path $SRC_DIR "tmp-build-$Env:PLATFORM" + $DEST = Join-Path $SRC_DIR "build-$Env:PLATFORM\dist" + + python.exe -m pip install --user --upgrade pip setuptools wheel twine build virtualenv + $env:COMPILE_BINDINGS = $true + python.exe -m build + Remove-Item Env:\COMPILE_BINDINGS + Copy-Item -Path "dist/libm2k*.whl" -Destination $DEST + Set-Location $SRC_DIR displayName: Wheel Python ${{ pyVersion }} - powershell: | - . ./CI/windows/make_windows.ps1 - Move-to-Build-Dir -PLATFORM $PLATFORM + $SRC_DIR = Get-Location + $DEST_DIR = Join-Path $SRC_DIR "build-$Env:PLATFORM\dist" + $TEMP_BUILD_DIR = Join-Path $SRC_DIR "tmp-build-$Env:PLATFORM" + + python.exe -m pip install --user --upgrade pip setuptools wheel twine build virtualenv + $env:COMPILE_BINDINGS = $true + python.exe -m build + Remove-Item Env:\COMPILE_BINDINGS + Copy-Item -Path "dist/libm2k*.whl" -Destination $DEST + Set-Location $SRC_DIR displayName: 'Move to build directory' - task: PowerShell@2 displayName: 'Create libm2k-system-setup installer'