Skip to content

Commit

Permalink
ci: add libm2k build commands
Browse files Browse the repository at this point in the history
Signed-off-by: Adrian Stanea <[email protected]>
  • Loading branch information
Adrian-Stanea committed Nov 10, 2023
1 parent 142aa81 commit ab35d46
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 32 deletions.
39 changes: 28 additions & 11 deletions CI/windows/install_deps.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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")
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
Expand All @@ -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
Install-All
77 changes: 57 additions & 20 deletions CI/windows/make_windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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 {
Expand All @@ -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"
Expand All @@ -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 `
Expand All @@ -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
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"
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'


Expand Down

0 comments on commit ab35d46

Please sign in to comment.