-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6501ae9
commit 20d280c
Showing
3 changed files
with
369 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
|
||
$ErrorActionPreference = "Stop" | ||
$ErrorView = "NormalView" | ||
|
||
$COMPILER = $Env:COMPILER | ||
$ARCH = $Env:ARCH | ||
|
||
$SRC_DIR = Get-Location | ||
$BUILD_DIR = Join-Path $SRC_DIR "build-$ARCH" | ||
$LIBIIO_VERSION = "libiio-v0" | ||
|
||
Write-Output "Running script from $SRC_DIR" | ||
Get-ChildItem | ||
|
||
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"))) { | ||
New-Item -Path ($BUILD_DIR) -ItemType Directory | ||
} | ||
|
||
function Get-Libiio-Deps { | ||
param ( | ||
[string]$SRC_DIR | ||
) | ||
Write-Output "# Building libiio dependencies" | ||
|
||
Write-Output "## Installing libxml" | ||
New-Item -Path (Join-Path $SRC_DIR "libxml") -ItemType Directory | ||
Set-Location (Join-Path $SRC_DIR "libxml") | ||
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" | ||
|
||
Write-Output "## Installing libiio-deps" | ||
New-Item -Path (Join-Path $SRC_DIR "libiio-deps") -ItemType Directory | ||
Set-Location (Join-Path $SRC_DIR "libiio-deps") | ||
Invoke-WebRequest -Uri "http://swdownloads.analog.com/cse/build/libiio-deps-20220517.zip " -OutFile "libiio-win-deps.zip" | ||
7z x -y "libiio-win-deps.zip" | ||
Remove-Item "libiio-win-deps.zip" | ||
} | ||
|
||
function Install-Libiiio { | ||
param ( | ||
[string]$SRC_DIR, | ||
[string]$GENERATOR, | ||
[string]$ARCH | ||
) | ||
Write-Output "# Installing libiio" | ||
Set-Location $SRC_DIR | ||
|
||
git clone "https://github.com/analogdevicesinc/libiio" -b $LIBIIO_VERSION "libiio" | ||
Set-Location (Join-Path $SRC_DIR "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 | ||
Set-Location (Join-Path $SRC_DIR "libiio\build-$ARCH") | ||
|
||
$VERSION= $ARCH.substring(1) | ||
$LIBIIO_DEPS_LIBS_PATH = Join-Path $SRC_DIR "libiio-deps\libs\$VERSION" | ||
|
||
# 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" .. | ||
|
||
# Try the cmake config from libiio CI scripts | ||
$pythonExecutable = python -c "import sys; print(sys.executable)" | ||
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=$USE_CSHARP ` | ||
-DLIBXML2_LIBRARIES="$LIBIIO_DEPS_LIBS_PATH\libxml2.lib" ` | ||
-DLIBUSB_LIBRARIES="$LIBIIO_DEPS_LIBS_PATH\libusb-1.0.lib" ` | ||
-DLIBSERIALPORT_LIBRARIES="$LIBIIO_DEPS_LIBS_PATH\libserialport.dll.a" ` | ||
# -DLIBUSB_INCLUDE_DIR="C:\\include\\libusb-1.0" ` | ||
# -DLIBXML2_INCLUDE_DIR="C:\\include\\libxml2" ` | ||
.. | ||
|
||
cmake --build . --config Release | ||
|
||
# TODO: REVIEW THIS: is the executable installed? if so do i need it in the build dir / artifacts staging directory ? | ||
# Move to build dir - move .dll | ||
$DEST_FOLDER = (Join-Path $SRC_DIR "build\build-$ARCH") | ||
New-Item -Path ($DEST_FOLDER) -ItemType Directory | ||
|
||
Set-Location (Join-Path $SRC_DIR "libiio\build-$ARCH") | ||
Copy-Item -Path "Release\*.dll" -Destination $DEST_FOLDER | ||
Copy-Item -Path "Release\*.lib" -Destination $DEST_FOLDER | ||
Copy-Item -Path "*.iss" -Destination $DEST_FOLDER | ||
} | ||
|
||
|
||
|
||
function Install-Swig { | ||
param ( | ||
[string]$SRC_DIR | ||
) | ||
Write-Output "# Installing swig" | ||
Set-Location $SRC_DIR | ||
# NOTE: -UserAgent "NativeHost" solved the issue with the download - wait timeout before the download starts | ||
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" | ||
Set-Location (Join-Path "swig" "swigwin-4.0.0") | ||
xcopy * .. /s /e /h /Q | ||
|
||
} | ||
|
||
function Move-To-Build-Dir { | ||
param( | ||
[string]$PLATFORM | ||
[string]$VERSION | ||
[string]$CONFIGURATION | ||
|
||
) | ||
} | ||
|
||
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" | ||
$NEW_PATH = $CRNT_PATH + ";" + $NEW_PATH | ||
[System.Environment]::SetEnvironmentVariable('PATH', $NEW_PATH, [System.EnvironmentVariableTarget]::Machine) | ||
} | ||
} | ||
|
||
function Install-Glog { | ||
# This was in build script | ||
param ( | ||
[string]$SRC_DIR, | ||
[string]$CONFIGURATION, | ||
[string]$ARCH, | ||
[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 | ||
} | ||
Set-Location (Join-Path $SRC_DIR "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 | ||
} | ||
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" | ||
} | ||
|
||
function Install-All { | ||
Get-Libiio-Deps -SRC_DIR (Join-Path $SRC_DIR "deps") # WORKS | ||
Install-Libiiio -SRC_DIR (Join-Path $SRC_DIR "deps") -GENERATOR $COMPILER -ARCH $ARCH # Needs testing | ||
Install-Swig -SRC_DIR (Join-Path $SRC_DIR "deps") # WORKS - FIXED DOWNLOAD TIMEOUT | ||
Install-Inno-Setup # WORKS | ||
Install-Glog -SRC_DIR (Join-Path $SRC_DIR "deps") -GENERATOR $COMPILER -ARCH $ARCH # Needs testing | ||
Install-Glog -SRC_DIR (Join-Path $SRC_DIR "deps") -GENERATOR $COMPILER -ARCH $ARCH # Needs testing | ||
} | ||
|
||
Install-All |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_preference_variables?view=powershell-7.2#erroractionpreference | ||
$ErrorActionPreference = "Stop" | ||
$ErrorView = "NormalView" | ||
|
||
$COMPILER=$Env:COMPILER | ||
$USE_CSHARP=$Env:USE_CSHARP | ||
$src_dir=$pwd | ||
|
||
echo "Running cmake for $COMPILER on 64 bit..." | ||
mkdir build-x64 | ||
cp .\libiio.iss.cmakein .\build-x64 | ||
cd build-x64 | ||
|
||
cmake -G "$COMPILER" -DPYTHON_EXECUTABLE:FILEPATH=$(python -c "import os, sys; print(os.path.dirname(sys.executable) + '\python.exe')") -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=$USE_CSHARP -DLIBXML2_LIBRARIES="C:\\libs\\64\\libxml2.lib" -DLIBUSB_LIBRARIES="C:\\libs\\64\\libusb-1.0.lib" -DLIBSERIALPORT_LIBRARIES="C:\\libs\\64\\libserialport.dll.a" -DLIBUSB_INCLUDE_DIR="C:\\include\\libusb-1.0" -DLIBXML2_INCLUDE_DIR="C:\\include\\libxml2" -DLIBZSTD_INCLUDE_DIR="C:\\include" -DLIBZSTD_LIBRARIES="C:\\libs\\64\\libzstd.dll.a" .. | ||
|
||
cmake --build . --config Release | ||
if ( $LASTEXITCODE -ne 0 ) { | ||
throw "[*] cmake build failure" | ||
} | ||
cp .\libiio.iss $env:BUILD_ARTIFACTSTAGINGDIRECTORY | ||
|
||
cd bindings/python | ||
python.exe setup.py sdist | ||
Get-ChildItem dist\pylibiio-*.tar.gz | Rename-Item -NewName "libiio-py39-amd64.tar.gz" | ||
mv .\dist\*.gz . | ||
rm .\dist\*.gz |
Oops, something went wrong.