Skip to content

Commit

Permalink
ci/windows: create installer for windows x64
Browse files Browse the repository at this point in the history
Signed-off-by: Adrian Stanea <Adrian.Stanea@analog.com>
  • Loading branch information
Adrian-Stanea committed Nov 15, 2023
1 parent 34a963b commit ebbe088
Show file tree
Hide file tree
Showing 6 changed files with 166 additions and 14 deletions.
63 changes: 63 additions & 0 deletions CI/windows/create_installer.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
$ErrorActionPreference = "Stop"
$ErrorView = "NormalView"

$SRC_DIR = Get-Location

function Get-Dll-Paths() {
$vsPath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
if ($vsPath -eq $null) {
Write-Host "Visual Studio (vswhere.exe) not found - can't find dll paths."
return $null
}

$vsInstallerPath = & $vsPath -latest -requires Microsoft.Component.MSBuild -property installationPath
if ($vsInstallerPath -eq $null) {
Write-Host "Visual Studio Installer path is not available"
return $null
}

$msvcp140Path = Join-Path $vsInstallerPath 'VC\Tools\MSVC\14.*\bin\Hostx64\x64\msvcp140.dll'
$vcruntime140Path = Join-Path $vsInstallerPath 'VC\Tools\MSVC\14.*\bin\Hostx64\x64\vcruntime140.dll'
if (($msvcp140Path -eq $null) -or ($vcruntime140Path -eq $null)) {
Write-Host "Dll paths not found in Visual Studion installation path."
return $null
}

$result = New-Object PSObject -Property @{
msvcp140Path = $msvcp140Path
vcruntime140Path = $vcruntime140Path
}
return $result
}


Set-Location $SRC_DIR

$ddlPaths = Get-Dll-Paths

if ($ddlPaths -ne $null) {
Write-Host "msvcp140Path: $($ddlPaths.msvcp140Path)"
Write-Host "vcruntime140Path: $($ddlPaths.vcruntime140Path)"
} else {
Write-Host "Dll Paths not found."
}

$INSALLER_PATH = Join-Path $SRC_DIR "build-win64\installer"
$DIST_PATH = Join-Path $SRC_DIR "build-win64\dist" # should already exist from th step where we build libm2k

Copy-Item -Path $ddlPaths.msvcp140Path -Destination $DIST_PATH
Copy-Item -Path $ddlPaths.vcruntime140Path -Destination $DIST_PATH

# creates installer in: C:\libm2k-system-setup.exe
ISCC (Join-Path $DIST_PATH "libm2k.iss")

if (-not (Test-Path -Path $INSALLER_PATH)) {
New-Item -Path $INSALLER_PATH -ItemType Directory
}
Move-Item -Path "C:\libm2k-system-setup.exe" -Destination $INSALLER_PATH

# clear artifacts staging directory and copy the installer -> new step is to push an artifact
Get-ChildItem $env:BUILD_ARTIFACTSTAGINGDIRECTORY -Force -Recurse | Remove-Item -Force -Recurse
Copy-Item -Path (Join-Path $INSALLER_PATH "libm2k-system-setup.exe") -Destination $env:BUILD_ARTIFACTSTAGINGDIRECTORY

Set-Location $SRC_DIR
48 changes: 48 additions & 0 deletions CI/windows/create_zips.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
$ErrorActionPreference = "Stop"
$ErrorView = "NormalView"

$COMPILER = $Env:COMPILER
$ARCH = $Env:ARCH
$PLATFORM = "win64"

$SRC_DIR = Get-Location
$BUILD_DIR = Join-Path $SRC_DIR "build-$PLATFORM\dist"

$OUTSIDE_BUILD = [System.IO.Path]::GetDirectoryName($SRC_DIR.Path)
$DEST_LIBM2K = Join-Path $OUTSIDE_BUILD "libm2k-$PLATFORM"
$DEST_LIBM2K_DIST = Join-Path $DEST_LIBM2K "dist$PLATFORM"

if (-not (Test-Path -Path $DEST_LIBM2K)) {
New-Item -Path $DEST_LIBM2K -ItemType Directory
}
if (-not (Test-Path -Path $DEST_LIBM2K_DIST)) {
New-Item -Path $DEST_LIBM2K_DIST -ItemType Directory
}

Set-Location $SRC_DIR
xcopy include $DEST_LIBM2K /s /e /h
Copy-Item -Path "$BUILD_DIR\libm2k.*" -Destination $DEST_LIBM2K
Copy-Item -Path "$BUILD_DIR\_libm2k.*" -Destination $DEST_LIBM2K
Copy-Item -Path "$BUILD_DIR\libm2k_lv.dll" -Destination $DEST_LIBM2K
Copy-Item -Path "$BUILD_DIR\libm2k-sharp.dll" -Destination $DEST_LIBM2K
Copy-Item -Path "$BUILD_DIR\libm2k-sharp-cxx-wrap.dll" -Destination $DEST_LIBM2K
Copy-Item -Path "$BUILD_DIR\*.exe" -Destination $DEST_LIBM2K
Copy-Item -Path "$BUILD_DIR\msvc*.dll" -Destination $DEST_LIBM2K
Copy-Item -Path "$BUILD_DIR\vcruntime*.dll" -Destination $DEST_LIBM2K

# TODO: do we want to have the wheels build for different python versions? or just the latest
# current implementatino only .whl version using the latest python version
Copy-Item -Path "$BUILD_DIR\*.whl" -Destination $DEST_LIBM2K_DIST

Copy-Item -Path (Join-Path $OUTSIDE_BUILD "libiio-$ARCH\*.dll") -Destination $DEST_LIBM2K
Copy-Item -Path (Join-Path $OUTSIDE_BUILD "libiio-$ARCH\*.dll") -Destination $DEST_LIBM2K
Copy-Item -Path (Join-Path $OUTSIDE_BUILD "deps\glog\build_0_4_0-x64\Release\glog.dll") -Destination $DEST_LIBM2K

Set-Location $OUTSIDE_BUILD
7z a "libm2k-$PLATFORM.7z" "libm2k-$PLATFORM"

# Clean artifacts staging directory and copy the installer -> new step is to push an artifact
Get-ChildItem $env:BUILD_ARTIFACTSTAGINGDIRECTORY -Force -Recurse | Remove-Item -Force -Recurse
Copy-Item -Path (Join-Path $OUTSIDE_BUILD "libm2k-$PLATFORM.7z") -Destination $env:BUILD_ARTIFACTSTAGINGDIRECTORY

Set-Location $SRC_DIR
20 changes: 13 additions & 7 deletions CI/windows/install_deps.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
$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

Expand All @@ -9,7 +12,7 @@ $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

$BUILD_DIR = Join-Path $SRC_DIR "build-$ARCH" #libm2k build dir
# $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"
Expand All @@ -22,7 +25,7 @@ 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 "BUILD_DIR = $BUILD_DIR"
Write-Output "OUTSIDE_BUILD to $OUTSIDE_BUILD"
Write-Output "DEST_LIBIIO = $DEST_LIBIIO"

Expand All @@ -32,9 +35,9 @@ 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
}
# if (-not (Test-Path -Path ($BUILD_DIR))) {
# New-Item -Path ($BUILD_DIR) -ItemType Directory
# }

function Get-Libiio-Deps { #CHECKED
param (
Expand Down Expand Up @@ -129,6 +132,9 @@ function Install-Libiiio {
Set-Location -Path ..
Copy-Item -Path "iio.h" -Destination ($DEST_LIBIIO)

# 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")
Expand All @@ -148,6 +154,7 @@ function Install-Swig {
Write-Output "# Installing swig"
Set-Location $SRC_DIR
# 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"
7z x "swigwin-4.0.0.zip" -oswig
Remove-Item "swigwin-4.0.0.zip"
Expand Down Expand Up @@ -200,11 +207,10 @@ function Install-Glog {
function Install-All {
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-Glog -SRC_DIR $DEPS_DIR -CONFIGURATION "Release" -GENERATOR $COMPILER -ARCH "Win32" # we are not building for 32 bit
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
}

Expand Down
8 changes: 3 additions & 5 deletions CI/windows/make_windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,6 @@ function Build-Libm2k {

Get-Content setup.py

# $PY_SUFFIX=""
# if ($PLATFORM -eq "win64") {
# $PY_SUFFIX = "-x64"
# }
Build-Python-Wheel -PLATFORM $PLATFORM -PYTHON_PATH $PYTHON_PATH
}

Expand All @@ -117,4 +113,6 @@ function Move-to-Build-Dir {
# Move-to-Build-Dir -PLATFORM "win32"

Build-Libm2k -PLATFORM "win64" -GENERATOR $COMPILER -ARCH $ARCH
Move-to-Build-Dir -PLATFORM "win64"
Move-to-Build-Dir -PLATFORM "win64"

Set-Location $SRC_DIR
39 changes: 38 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,47 @@ jobs:
targetType: filePath
filePath: ./CI/windows/install_deps.ps1
- task: PowerShell@2
displayName: 'Build libm2k'
inputs:
targetType: 'filePath'
filePath: ./CI/windows/make_windows.ps1
displayName: 'Build libm2k'
- task: PowerShell@2
displayName: 'Create libm2k-system-setup installer'
condition: eq(variables['System.JobName'], 'VS_2022')
inputs:
targetType: 'filePath'
filePath: ./CI/windows/create_installer.ps1
- task: PublishPipelineArtifact@1
condition: eq(variables['System.JobName'], 'VS_2022')
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)'
artifactName: 'Libm2k-System-Setup-Exe'
- task: PowerShell@2
displayName: "Create ZIPs"
inputs:
targetType: 'filePath'
filePath: ./CI/windows/create_zips.ps1
- task: PublishPipelineArtifact@1
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'




2 changes: 1 addition & 1 deletion libm2k.iss.cmakein
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ AppSupportURL="http://www.analog.com"
AppUpdatesURL="http://www.analog.com"
AppCopyright="Copyright 2019 ADI and other contributors"
CreateAppDir=no
LicenseFile="C:\projects\libm2k\LICENSE"
LicenseFile="D:\a\1\s\LICENSE"
OutputBaseFilename=libm2k-system-setup
OutputDir="C:\"
Compression=lzma
Expand Down

0 comments on commit ebbe088

Please sign in to comment.