Skip to content

Commit

Permalink
ci/windows: devide the build command in substeps
Browse files Browse the repository at this point in the history
- The fragmentation of the steps allows to swap between python version, build
new wheels and then add them to the final zip.

Signed-off-by: Adrian Stanea <[email protected]>
  • Loading branch information
Adrian-Stanea committed Nov 15, 2023
1 parent ebbe088 commit 515afc2
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 41 deletions.
35 changes: 14 additions & 21 deletions CI/windows/make_windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,29 @@ $ErrorView = "NormalView"

$COMPILER = $Env:COMPILER
$ARCH = $Env:ARCH
$PLATFORM = $Env:PLATFORM

$SRC_DIR = Get-Location
$OUTSIDE_BUILD = [System.IO.Path]::GetDirectoryName($SRC_DIR.Path)
$DEPS_DIR= Join-Path $OUTSIDE_BUILD "deps"

$DIST_DIR = Join-Path $SRC_DIR "build-$PLATFORM/dist"
$TEMP_BUILD_DIR = Join-Path $SRC_DIR "tmp-build-$PLATFORM"
$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,
[string]$PYTHON_PATH
)
Set-Location $TEMP_BUILD_DIR

python.exe -m pip install --user --upgrade pip setuptools wheel twine build virtualenv
$env:COMPILE_BINDINGS = $true
Expand All @@ -32,31 +41,22 @@ function Build-Libm2k {
param(
[string]$PLATFORM,
[string]$PYTHON_VERSION,
[string]$PYTHON_PATH,
[string]$GENERATOR,
[string]$ARCH
)

$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"
if (Test-Path -Path $TEMP_BUILD_DIR) {
Remove-Item $TEMP_BUILD_DIR -Recurse -Force
}
New-Item -Path $TEMP_BUILD_DIR -ItemType Directory

Write-Output "DIST_DIR = $DIST_DIR"
Write-Output "TEMP_BUILD_DIR = $TEMP_BUILD_DIR"

Set-Location $TEMP_BUILD_DIR

$DEST_LIBIIO = Join-Path $OUTSIDE_BUILD "libiio-$ARCH"

$pythonExecutable = (python -c "import sys; print(sys.executable)") -replace '\\', '/'
$PATH_SWIG_DIR = (Join-Path $DEPS_DIR "swig\Lib") -replace '\\', '/'
$PATH_SWIG_EXE = (Join-Path $DEPS_DIR "swig\swig.exe") -replace '\\', '/'
Expand Down Expand Up @@ -87,32 +87,25 @@ function Build-Libm2k {


Get-Content setup.py

Build-Python-Wheel -PLATFORM $PLATFORM -PYTHON_PATH $PYTHON_PATH
}

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"
# Build-Libm2k -PLATFORM $PLATFORM -GENERATOR $COMPILER -ARCH $ARCH
# Build-Python-Wheel -PLATFORM $PLATFORM
# Move-to-Build-Dir -PLATFORM $PLATFORM

Set-Location $SRC_DIR
Set-Location $SRC_DIR
40 changes: 20 additions & 20 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,19 +173,22 @@ jobs:
vmImage: 'windows-2022'
COMPILER: 'Visual Studio 17 2022'
ARCH: 'x64'
$PLATFORM: 'win64'
artifactName: 'Windows-VS-2022-x64'
VS_2019:
poolName: 'Azure Pipelines'
vmImage: 'windows-2019'
COMPILER: 'Visual Studio 16 2019'
ARCH: 'x64'
$PLATFORM: 'win64'
artifactName: 'Windows-VS-2019-x64'
pool:
vmImage: $[ variables['vmImage'] ]
steps:
- 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'
Expand All @@ -194,11 +197,23 @@ jobs:
inputs:
targetType: filePath
filePath: ./CI/windows/install_deps.ps1
- task: PowerShell@2
- powershell: |
. ./CI/windows/make_windows.ps1
Build-Libm2k -PLATFORM $PLATFORM -COMPILER $COMPILER -ARCH $ARCH
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
displayName: Wheel Python ${{ pyVersion }}
- powershell: |
. ./CI/windows/make_windows.ps1
Move-to-Build-Dir -PLATFORM $PLATFORM
displayName: 'Move to build directory'
- task: PowerShell@2
displayName: 'Create libm2k-system-setup installer'
condition: eq(variables['System.JobName'], 'VS_2022')
Expand All @@ -219,22 +234,7 @@ jobs:
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)'
artifactName: '$(artifactName)'
# TODO: review what we want to do: have an installer for each vmimage or just the latest one??
# I think we should renaame installers based on the compiler used if we want to keep them all
# - job: GenerateSetupExe
# dependsOn: WindowsBuilds
# pool:
# vmImage: 'windows-2022'
# steps:
# - task: PowerShell@2
# displayName: 'Create libm2k-system-setup installer'
# inputs:
# targetType: 'filePath'
# filePath: ./CI/windows/create_installer.ps1
# - task: PublishPipelineArtifact@1
# inputs:
# targetPath: '$(Build.ArtifactStagingDirectory)'
# artifactName: 'Libm2k-System-Setup-Exe'




Expand Down

0 comments on commit 515afc2

Please sign in to comment.