From ab35d46ac521da9b73117a6b3497052eaace9071 Mon Sep 17 00:00:00 2001 From: Adrian Stanea Date: Thu, 9 Nov 2023 13:17:09 +0200 Subject: [PATCH] ci: add libm2k build commands Signed-off-by: Adrian Stanea --- CI/windows/install_deps.ps1 | 39 +++++++++++++------ CI/windows/make_windows.ps1 | 77 +++++++++++++++++++++++++++---------- azure-pipelines.yml | 2 +- 3 files changed, 86 insertions(+), 32 deletions(-) diff --git a/CI/windows/install_deps.ps1 b/CI/windows/install_deps.ps1 index 72ea916a..7c67fd5a 100644 --- a/CI/windows/install_deps.ps1 +++ b/CI/windows/install_deps.ps1 @@ -9,6 +9,7 @@ $SRC_DIR = Get-Location $DEPS_DIR = Join-Path $SRC_DIR "deps" $BUILD_DIR = Join-Path $SRC_DIR "build-$ARCH" $LIBIIO_VERSION = "libiio-v0" +$DEST_LIBIIO = Join-Path $BUILD_DIR "libiio-$ARCH" Write-Output "Python located at:" Get-Command python @@ -20,8 +21,9 @@ if (-not (Test-Path -Path (Join-Path $SRC_DIR "deps"))) { New-Item -Path (Join-Path $SRC_DIR "deps") -ItemType Directory } -if (-not (Test-Path -Path (Join-Path $SRC_DIR "build"))) { +if (-not (Test-Path -Path ($BUILD_DIR))) { New-Item -Path ($BUILD_DIR) -ItemType Directory + New-Item -Path ($DEST_LIBIIO) -ItemType Directory } function Get-Libiio-Deps { #CHECKED @@ -39,7 +41,7 @@ function Get-Libiio-Deps { #CHECKED 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") @@ -106,8 +108,20 @@ function Install-Libiiio { # 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) + + Set-Location -Path .. + Copy-Item -Path "iio.h" -Destination ($DEST_LIBIIO) + # NOTE: the result of these commands is a .tar.gz file + Set-Location (Join-Path $SRC_DIR "libiio\build-$ARCH") + Set-Location -Path .\bindings\python python.exe setup.py sdist Get-ChildItem dist\pylibiio-*.tar.gz | Rename-Item -NewName "libiio-py39-amd64.tar.gz" @@ -155,8 +169,8 @@ function Install-Glog { [string]$GENERATOR ) Write-Output "# Installing glog" - Set-Location $SRC_DIR + if (-not (Test-Path -Path (Join-Path $SRC_DIR "glog"))) { git clone --branch v0.3.5 --depth 1 https://github.com/google/glog } @@ -168,18 +182,21 @@ function Install-Glog { } Set-Location ((Join-Path $SRC_DIR "glog\build_0_4_0-$ARCH")) - cmake -DWITH_GFLAGS=off -DBUILD_SHARED_LIBS=on -G $GENERATOR -A $ARCH .. - cmake --build . --target install --config "Release" + 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 # WORKS - Install-Glog -SRC_DIR $DEPS_DIR -GENERATOR $COMPILER -ARCH $ARCH # Needs testing - Install-Glog -SRC_DIR $DEPS_DIR -GENERATOR $COMPILER -ARCH $ARCH # Needs testing - Install-Swig -SRC_DIR $DEPS_DIR # WORKS - FIXED DOWNLOAD TIMEOUT - Get-Libiio-Deps -SRC_DIR $DEPS_DIR # WORKS + Install-Inno-Setup + Install-Glog -SRC_DIR $DEPS_DIR -CONFIGURATION "Release" -GENERATOR $COMPILER -ARCH "x64" + Install-Glog -SRC_DIR $DEPS_DIR -CONFIGURATION "Release" -GENERATOR $COMPILER -ARCH "Win32" + Install-Swig -SRC_DIR $DEPS_DIR + + Get-Libiio-Deps -SRC_DIR $DEPS_DIR Install-Libiiio -SRC_DIR $DEPS_DIR -GENERATOR $COMPILER -ARCH $ARCH # Needs testing + + Set-Location $SRC_DIR } -Install-All \ No newline at end of file +Install-All diff --git a/CI/windows/make_windows.ps1 b/CI/windows/make_windows.ps1 index 0a498687..8db0d17c 100644 --- a/CI/windows/make_windows.ps1 +++ b/CI/windows/make_windows.ps1 @@ -6,12 +6,14 @@ $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 -} +# $BUILD_DIR = Join-Path $SRC_DIR "build-$ARCH" +# $DIST_DIR = Join-Path $SRC_DIR "build-$ARCH\dist" + +# # Create the official build directory for this platform +# if (-not (Test-Path -Path $DIST_DIR)) { +# New-Item -Path $DIST_DIR -ItemType Directory +# } function Build-Python-Wheel { param( @@ -24,11 +26,13 @@ function Build-Python-Wheel { $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" + python.exe -m pip install --user --upgrade pip setuptools wheel twine build virtualenv $env:COMPILE_BINDINGS = $true - Invoke-Expression "$PyPath -m build" + python.exe -m build Remove-Item Env:\COMPILE_BINDINGS - Copy-Item "dist/libm2k*.whl" "$BUILD_DIR\dist" + + $DEST = Join-Path $SRC_DIR "build-$PLATFORM\dist" + Copy-Item -Path "dist/libm2k*.whl" -Destination $DEST } function Build-Libm2k { @@ -40,8 +44,11 @@ function Build-Libm2k { [string]$ARCH, ) - # Create the official build directory for this platform - New-Item -Path (Join-Path $SRC_DIR "\build-$PLATFORM\dist") -ItemType Directory + $DIST_DIR = Join-Path $SRC_DIR "build-$PLATFORM\dist" + # Create the official build directory for this platform + if (-not (Test-Path -Path $DIST_DIR)) { + New-Item -Path $DIST_DIR -ItemType Directory + } # Create and clear up the temporary build directory for this platform $TEMP_BUILD_DIR = Join-Path $SRC_DIR "tmp-build-$PLATFORM" @@ -54,19 +61,27 @@ function Build-Libm2k { # $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") + Set-Location $TEMP_BUILD_DIR + - cmake -G $GENERATOR ` - -A $ARCH ` - -DIIO_LIBRARIES:FILEPATH="$DEST_LIBIIO"-"$PLATFORM"/libiio.lib ` - -DIIO_INCLUDE_DIRS:PATH="$DEST_LIBIIO"-"$PLATFORM" ` + $pythonExecutable = (python -c "import sys; print(sys.executable)") -replace '\\', '/' + $PATH_SWIG_DIR = (Join-Path $SRC_DIR "swig\Lib") -replace '\\', '/' + $PATH_SWIG_EXE = (Join-Path $SRC_DIR "swig\Lib\swig.exe") -replace '\\', '/' + $SWIG_VERSION = "4.0.0" + $IIO_LIBS_DIR= (Join-Path $SRC_DIR "deps\libiio/build-$ARCH\Release\libiio.lib") -replace '\\', '/' + $IIO_INCLUDE_DIR= (Join-Path $SRC_DIR "deps\libiio/build-$ARCH") -replace '\\', '/' + + cmake -G "$GENERATOR" ` + -A "$ARCH" ` + -DIIO_LIBRARIES:FILEPATH="$IIO_LIBS_DIR" ` + -DIIO_INCLUDE_DIRS:PATH="$IIO_INCLUDE_DIR" ` -DCMAKE_CONFIGURATION_TYPES=RELEASE ` - -DSWIG_DIR=/c/swig/Lib ` - -DSWIG_EXECUTABLE=/c/swig/swig.exe ` - -DSWIG_VERSION="4.0.0" ` + -DSWIG_DIR="$PATH_SWIG_DIR" ` + -DSWIG_EXECUTABLE="$PATH_SWIG_EXE" ` + -DSWIG_VERSION="$SWIG_VERSION" ` -DENABLE_TOOLS=ON ` -DENABLE_LOG=ON ` - -DPython_EXECUTABLE="$PY_PATH/python.exe" ` + -DPython_EXECUTABLE="$pythonExecutable" ` -DBUILD_EXAMPLES=ON ` -DENABLE_CSHARP=ON ` -DENABLE_LABVIEW=ON ` @@ -84,4 +99,26 @@ function Build-Libm2k { 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 +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 "win32" -PYTHON_VERSION 37 -PYTHON_PATH "C:\Python39" -GENERATOR $COMPILER -ARCH $ARCH +# Move-to-Build-Dir -PLATFORM "win32" + +Build-Libm2k -PLATFORM "win64" -GENERATOR $COMPILER -ARCH $ARCH +Move-to-Build-Dir -PLATFORM "win64" \ No newline at end of file diff --git a/azure-pipelines.yml b/azure-pipelines.yml index d9f86ee2..3663fd3d 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -197,7 +197,7 @@ jobs: - task: PowerShell@2 inputs: targetType: 'filePath' - filePath: .\CI\build_win.ps1 + filePath: ./CI/windows/make_windows.ps1 displayName: 'Build libm2k'