diff --git a/CI/windows/install_deps.ps1 b/CI/windows/install_deps.ps1 new file mode 100644 index 00000000..ad2b570e --- /dev/null +++ b/CI/windows/install_deps.ps1 @@ -0,0 +1,138 @@ + +$ErrorActionPreference = "Stop" +$ErrorView = "NormalView" + +$SRC_DIR = Get-Location +$LIBIIO_VERSION = "libiio-v0" + +$COMPILER = $Env:COMPILER +$ARCH = $Env:ARCH + +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 (Join-Path $SRC_DIR "build") -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") + + $LIBIIO_DEPS_LIBS_PATH = Join-Path $SRC_DIR "libiio-deps\libs\$ARCH" + 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" .. + 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 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 \ No newline at end of file diff --git a/CI/windows/make_windows.ps1 b/CI/windows/make_windows.ps1 new file mode 100644 index 00000000..18875bba --- /dev/null +++ b/CI/windows/make_windows.ps1 @@ -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 \ No newline at end of file diff --git a/azure-pipelines.yml b/azure-pipelines.yml index f74957ca..266f446d 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -32,133 +32,173 @@ parameters: - 3.7 jobs: -- job: LinuxBuilds - strategy: - matrix: - ubuntu_20_04: - imageName: 'ubuntu-20.04' - OS_TYPE: 'ubuntu_docker' - OS_VERSION: focal - artifactName: 'Linux-Ubuntu-20.04' - PACKAGE_TO_INSTALL: 'build/*.deb' - ubuntu_22_04: - imageName: 'ubuntu-22.04' - OS_TYPE: 'ubuntu_docker' - OS_VERSION: jammy - artifactName: 'Linux-Ubuntu-22.04' - PACKAGE_TO_INSTALL: 'build/*.deb' - deploy_doxygen: - imageName: 'ubuntu-20.04' - OS_TYPE: 'doxygen' - OS_VERSION: focal - artifactName: 'Linux-Ubuntu-20.04' - PACKAGE_TO_INSTALL: 'build/*.deb' - pool: - vmImage: $(imageName) - steps: - - checkout: self - fetchDepth: 1 - clean: true - persistCredentials: true - - script: ./CI/ubuntu/install_deps - displayName: "Install Dependencies" - - script: ./CI/ubuntu/make_linux - displayName: "Build" - - task: CopyFiles@2 - condition: ne(variables['System.JobName'], 'deploy_doxygen') - inputs: - sourceFolder: '$(Agent.BuildDirectory)/s/build/' - contents: '$(Agent.BuildDirectory)/s/build/?(*.deb|*.rpm)' - targetFolder: '$(Build.ArtifactStagingDirectory)' - - task: PublishPipelineArtifact@1 - condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'), ne(variables['System.JobName'], 'deploy_doxygen')) - inputs: - targetPath: '$(Build.ArtifactStagingDirectory)' - artifactName: '$(artifactName)' +# - job: LinuxBuilds +# strategy: +# matrix: +# ubuntu_20_04: +# imageName: 'ubuntu-20.04' +# OS_TYPE: 'ubuntu_docker' +# OS_VERSION: focal +# artifactName: 'Linux-Ubuntu-20.04' +# PACKAGE_TO_INSTALL: 'build/*.deb' +# ubuntu_22_04: +# imageName: 'ubuntu-22.04' +# OS_TYPE: 'ubuntu_docker' +# OS_VERSION: jammy +# artifactName: 'Linux-Ubuntu-22.04' +# PACKAGE_TO_INSTALL: 'build/*.deb' +# deploy_doxygen: +# imageName: 'ubuntu-20.04' +# OS_TYPE: 'doxygen' +# OS_VERSION: focal +# artifactName: 'Linux-Ubuntu-20.04' +# PACKAGE_TO_INSTALL: 'build/*.deb' +# pool: +# vmImage: $(imageName) +# steps: +# - checkout: self +# fetchDepth: 1 +# clean: true +# persistCredentials: true +# - script: ./CI/ubuntu/install_deps +# displayName: "Install Dependencies" +# - script: ./CI/ubuntu/make_linux +# displayName: "Build" +# - task: CopyFiles@2 +# condition: ne(variables['System.JobName'], 'deploy_doxygen') +# inputs: +# sourceFolder: '$(Agent.BuildDirectory)/s/build/' +# contents: '$(Agent.BuildDirectory)/s/build/?(*.deb|*.rpm)' +# targetFolder: '$(Build.ArtifactStagingDirectory)' +# - task: PublishPipelineArtifact@1 +# condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'), ne(variables['System.JobName'], 'deploy_doxygen')) +# inputs: +# targetPath: '$(Build.ArtifactStagingDirectory)' +# artifactName: '$(artifactName)' + +# - job: macOSBuilds +# workspace: +# clean: all +# strategy: +# matrix: +# macOS_11: +# poolName: 'Azure Pipelines' +# vmImage: 'macOS-11' +# agentName: 'Azure Pipelines 4' +# artifactName: 'macOS-11' +# macOS_12: +# poolName: 'Azure Pipelines' +# vmImage: 'macOS-12' +# agentName: 'Azure Pipelines 3' +# artifactName: 'macOS-12' +# macOS_13_x64: +# poolName: 'Azure Pipelines' +# vmImage: 'macOS-13' +# agentName: 'Azure Pipelines 2' +# artifactName: 'macOS-13-x64' +# # TODO: discuss with DevOps team how to setup ARM agent +# # macOS_13_arm64: +# # poolName: 'Default' +# # vmImage: +# # agentName: 'macOS_arm64' +# # artifactName: 'macOS-13-arm64' +# pool: +# name: $(poolName) +# vmImage: $(vmImage) +# demands: +# - agent.name -equals $(agentName) +# variables: +# PACKAGE_TO_INSTALL: 'build/*.pkg' +# steps: +# - checkout: self +# fetchDepth: 1 +# clean: true +# - script: ./CI/macOS/install_deps +# displayName: "Install Dependencies" +# condition: ne(variables['agentName'],'macOS_arm64') +# - script: ./CI/macOS/make_macOS +# displayName: "Build" +# - ${{ each pyVersion in parameters.pythonVersions }}: +# - task: UsePythonVersion@0 +# displayName: Use Python ${{ pyVersion }} +# inputs: +# versionSpec: '${{ pyVersion }}' +# - script: | +# python3 --version +# python3 -m pip install wheel twine build virtualenv +# cd '$(Agent.BuildDirectory)/s/build/' +# mkdir -p wheelhouse +# export COMPILE_BINDINGS=True +# python3 -m build +# export COMPILE_BINDINGS= +# cp dist/*.whl wheelhouse +# displayName: Wheel Python ${{ pyVersion }} +# - task: CopyFiles@2 +# inputs: +# sourceFolder: '$(Agent.BuildDirectory)/s/build/' +# contents: '$(Agent.BuildDirectory)/s/build/?(*.pkg)' +# targetFolder: '$(Build.ArtifactStagingDirectory)' +# - task: CopyFiles@2 +# inputs: +# sourceFolder: '$(Agent.BuildDirectory)/s/build/' +# contents: '$(Agent.BuildDirectory)/s/build/wheelhouse/?(*.whl)' +# targetFolder: '$(Build.ArtifactStagingDirectory)' +# - task: CopyFiles@2 +# inputs: +# sourceFolder: '$(Agent.BuildDirectory)/s/build_tar/' +# contents: '$(Agent.BuildDirectory)/s/build_tar/?(*.tar.gz)' +# targetFolder: '$(Build.ArtifactStagingDirectory)' +# - task: PublishPipelineArtifact@1 +# condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) +# inputs: +# targetPath: '$(Build.ArtifactStagingDirectory)' +# artifactName: '$(artifactName)' +# - script: | +# python -m pip install --upgrade pip twine +# cd '$(Agent.BuildDirectory)/s/build/wheelhouse/' +# python -m twine upload --repository "testpypi" *.whl +# condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/v')) +# displayName: "Upload to PyPI" +# env: +# TWINE_USERNAME: '__token__' +# TWINE_PASSWORD: $(TWINE_PASSWORD) + + - job: WindowsBuilds + workspace: + clean: all + strategy: + matrix: + VS_2022: + poolName: 'Azure Pipelines' + vmImage: 'windows-2022' + COMPILER: 'Visual Studio 17 2022' + ARCH: 'x64' + artifactName: 'Windows-VS-2022-x64' + VS_2019: + poolName: 'Azure Pipelines' + vmImage: 'windows-2019' + COMPILER: 'Visual Studio 16 2019' + ARCH: 'x64' + artifactName: 'Windows-VS-2019-x64' + pool: + vmImage: $[ variables['vmImage'] ] + steps: + - checkout: self + fetchDepth: 1 + clean: true + - task: UsePythonVersion@0 + inputs: + versionSpec: '3.11' + - task: PowerShell@2 + displayName: 'Install Dependencies' + inputs: + targetType: filePath + filePath: ./CI/windows/install_deps.ps1 + # - task: PowerShell@2 + # inputs: + # targetType: 'filePath' + # filePath: .\CI\build_win.ps1 + # displayName: 'Build' + + -- job: macOSBuilds - workspace: - clean: all - strategy: - matrix: - macOS_11: - poolName: 'Azure Pipelines' - vmImage: 'macOS-11' - agentName: 'Azure Pipelines 4' - artifactName: 'macOS-11' - macOS_12: - poolName: 'Azure Pipelines' - vmImage: 'macOS-12' - agentName: 'Azure Pipelines 3' - artifactName: 'macOS-12' - macOS_13_x64: - poolName: 'Azure Pipelines' - vmImage: 'macOS-13' - agentName: 'Azure Pipelines 2' - artifactName: 'macOS-13-x64' - # TODO: discuss with DevOps team how to setup ARM agent - # macOS_13_arm64: - # poolName: 'Default' - # vmImage: - # agentName: 'macOS_arm64' - # artifactName: 'macOS-13-arm64' - pool: - name: $(poolName) - vmImage: $(vmImage) - demands: - - agent.name -equals $(agentName) - variables: - PACKAGE_TO_INSTALL: 'build/*.pkg' - steps: - - checkout: self - fetchDepth: 1 - clean: true - - script: ./CI/macOS/install_deps - displayName: "Install Dependencies" - condition: ne(variables['agentName'],'macOS_arm64') - - script: ./CI/macOS/make_macOS - displayName: "Build" - - ${{ each pyVersion in parameters.pythonVersions }}: - - task: UsePythonVersion@0 - displayName: Use Python ${{ pyVersion }} - inputs: - versionSpec: '${{ pyVersion }}' - - script: | - python3 --version - python3 -m pip install wheel twine build virtualenv - cd '$(Agent.BuildDirectory)/s/build/' - mkdir -p wheelhouse - export COMPILE_BINDINGS=True - python3 -m build - export COMPILE_BINDINGS= - cp dist/*.whl wheelhouse - displayName: Wheel Python ${{ pyVersion }} - - task: CopyFiles@2 - inputs: - sourceFolder: '$(Agent.BuildDirectory)/s/build/' - contents: '$(Agent.BuildDirectory)/s/build/?(*.pkg)' - targetFolder: '$(Build.ArtifactStagingDirectory)' - - task: CopyFiles@2 - inputs: - sourceFolder: '$(Agent.BuildDirectory)/s/build/' - contents: '$(Agent.BuildDirectory)/s/build/wheelhouse/?(*.whl)' - targetFolder: '$(Build.ArtifactStagingDirectory)' - - task: CopyFiles@2 - inputs: - sourceFolder: '$(Agent.BuildDirectory)/s/build_tar/' - contents: '$(Agent.BuildDirectory)/s/build_tar/?(*.tar.gz)' - targetFolder: '$(Build.ArtifactStagingDirectory)' - - task: PublishPipelineArtifact@1 - condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) - inputs: - targetPath: '$(Build.ArtifactStagingDirectory)' - artifactName: '$(artifactName)' - - script: | - python -m pip install --upgrade pip twine - cd '$(Agent.BuildDirectory)/s/build/wheelhouse/' - python -m twine upload --repository "testpypi" *.whl - condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/v')) - displayName: "Upload to PyPI" - env: - TWINE_USERNAME: '__token__' - TWINE_PASSWORD: $(TWINE_PASSWORD)