Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of SWIG with C# bindings #2577

Open
wants to merge 34 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
c0fcf24
SRT SWIG
lewk2 Dec 6, 2022
cee3a35
Srt1.5.1 swig (#8)
lewk2 Dec 6, 2022
e73b119
-docker lin build now uses ubuntu 22.04 base
Dec 6, 2022
2ea30af
SWIG Linux improvements, C# type mapping fixes
lewk2 Dec 8, 2022
3191862
Scripts update
BlackGad Feb 25, 2023
7971f28
-swig off by default (breaks older CI builds)
lewk2 Feb 26, 2023
4961728
-explicit call to run linux build in pwsh (CI fix)
lewk2 Feb 26, 2023
ae46ba8
-compile up-to-date swig within linux container
lewk2 Feb 28, 2023
85f38a4
WIP
BlackGad Mar 18, 2023
741c3ca
Added options handling
BlackGad Mar 18, 2023
40357d3
Marshaler fix
BlackGad Mar 18, 2023
0972dd3
Fixed delegates, a lot of modifications
BlackGad Mar 18, 2023
5a761af
-SWIG on in teamcity if VS2019+
Mar 23, 2023
02c9634
-update cmake to 3.25.3 (VS2022 support)
Mar 23, 2023
e0e20d7
-remove use of span (fails with netstandard2.0)
Mar 23, 2023
57c0df6
-fix cmake download
Mar 28, 2023
464dec3
Fixed callback delegates associated with socket GC lifetime
BlackGad Apr 8, 2023
3103108
Added EPOLL mappings
BlackGad Apr 29, 2023
efa8fa2
-clear null-forgiveness flag (not C# 8)
May 4, 2023
571c07c
-change ordering of SWIG cmake policies inclusion
May 5, 2023
e7ab2f2
Merge pull request #11 from Cinegy/vshkolka_swig_upgrade
lewk2 May 5, 2023
7583958
-added missed () from cmake else
May 5, 2023
671a2ee
Merge pull request #12 from Cinegy/vshkolka_swig_upgrade
lewk2 May 5, 2023
319d933
Merge branch 'Haivision:master' into master-swig
lewk2 May 8, 2023
0afb40b
-skip enum define due to conditionals
lewk2 May 8, 2023
661cc37
Fixed ps1 file permission
BlackGad Jun 17, 2023
7eb250d
Merge branch 'master-swig' of https://github.com/Cinegy/srt into mast…
BlackGad Jun 17, 2023
2b57581
Merged with upstream
BlackGad Jan 6, 2024
44a548d
Nuget package configuration update
BlackGad Jan 7, 2024
cd30b74
Added readme file
BlackGad Jan 7, 2024
f29b2eb
Added proper readme file
BlackGad Jan 7, 2024
97bd170
Fixed Nuget readme metadata
BlackGad Jan 7, 2024
e9fbd51
Fixed .NET 8 SocketAddress internal fields access issue
BlackGad Jan 13, 2024
33a150c
Fixed Dispose call on sockets
BlackGad Jun 1, 2024
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
22 changes: 11 additions & 11 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,29 @@ configuration:
- Debug

image:
- Ubuntu
- Visual Studio 2019
- Visual Studio 2015
- Visual Studio 2013

platform:
- x64
- x86

build_script:
- ps: $VSIMG = $Env:APPVEYOR_BUILD_WORKER_IMAGE; $CNFG = $Env:CONFIGURATION
- ps: $VSIMG = $Env:APPVEYOR_BUILD_WORKER_IMAGE; $CNFG = $Env:CONFIGURATION
# use a few differing arguments depending on VS version to exercise different options during builds
- ps: if ($VSIMG -match '2019' -and $CNFG -eq "Release") { .\scripts\build-windows.ps1 -STATIC_LINK_SSL ON -BUILD_APPS ON -UNIT_TESTS ON -BONDING ON }
- ps: if ($VSIMG -match '2019' -and $CNFG -eq "Debug") { .\scripts\build-windows.ps1 -STATIC_LINK_SSL ON -BUILD_APPS ON }
- ps: if ($VSIMG -match '2019' -and $CNFG -eq "Release") { .\scripts\build-windows.ps1 -STATIC_LINK_SSL ON -BUILD_APPS ON -UNIT_TESTS ON -BONDING ON -ENABLE_SWIG ON}
- ps: if ($VSIMG -match '2019' -and $CNFG -eq "Debug") { .\scripts\build-windows.ps1 -STATIC_LINK_SSL ON -BUILD_APPS ON -ENABLE_SWIG ON}
- ps: if ($VSIMG -match '2015' -and $CNFG -eq "Release") { .\scripts\build-windows.ps1 -STATIC_LINK_SSL ON -BUILD_APPS ON -UNIT_TESTS ON -BONDING ON}
- ps: if ($VSIMG -match '2015' -and $CNFG -eq "Debug") { .\scripts\build-windows.ps1 -STATIC_LINK_SSL ON -BUILD_APPS OFF }
- ps: if ($VSIMG -match '2013' -and $CNFG -eq "Release") { .\scripts\build-windows.ps1 -CXX11 OFF -BUILD_APPS ON }
- ps: if ($VSIMG -match '2013' -and $CNFG -eq "Debug") { Exit-AppveyorBuild } # just skip 2013 debug build for speed
- sh: pwsh ./scripts/build-lin-docker.ps1 -ENABLE_SWIG ON

test_script:
- ps: if ( $Env:RUN_UNIT_TESTS ) { cd ./_build; ctest -E "TestIPv6.v6_calls_v4" --extra-verbose -C $Env:CONFIGURATION; cd ../ }

after_build:
- cmd: >-
scripts/gather-package.bat
7z a SRT-%APPVEYOR_REPO_BRANCH%-%CONFIGURATION%-Win%PLATFORM%-%VS_VERSION%-%APPVEYOR_BUILD_VERSION%.zip %APPVEYOR_BUILD_FOLDER%\package\*
appveyor PushArtifact SRT-%APPVEYOR_REPO_BRANCH%-%CONFIGURATION%-Win%PLATFORM%-%VS_VERSION%-%APPVEYOR_BUILD_VERSION%.zip
- cmd: cd %APPVEYOR_BUILD_FOLDER%
- cmd: scripts/gather-package.bat
- cmd: scripts/create-win64-nuget.bat
- cmd: 7z a SRT-%APPVEYOR_REPO_BRANCH%-%CONFIGURATION%-Win%PLATFORM%-%VS_VERSION%-%APPVEYOR_BUILD_VERSION%.zip %APPVEYOR_BUILD_FOLDER%\package\*
- cmd: appveyor PushArtifact SRT-%APPVEYOR_REPO_BRANCH%-%CONFIGURATION%-Win%PLATFORM%-%VS_VERSION%-%APPVEYOR_BUILD_VERSION%.zip
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,11 @@ vcpkg/

# LSP
compile_commands.json

# Nuget packages
packages/
package/
*.nupkg

# Swig bindings
/srtcore/swig_bindings
36 changes: 36 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ option(USE_BUSY_WAITING "Enable more accurate sending times at a cost of potenti
option(USE_GNUSTL "Get c++ library/headers from the gnustl.pc" OFF)
option(ENABLE_SOCK_CLOEXEC "Enable setting SOCK_CLOEXEC on a socket" ON)
option(ENABLE_SHOW_PROJECT_CONFIG "Enable show Project Configuration" OFF)
option(ENABLE_SWIG "Enable SWIG, used to generate alternative language bindings" OFF)
option(ENABLE_SWIG_CSHARP "Enable SWIG binding generation for CSharp language (only effective if ENABLE_SWIG is ON)" ON)

option(ENABLE_CLANG_TSA "Enable Clang Thread Safety Analysis" OFF)

Expand Down Expand Up @@ -1401,6 +1403,40 @@ endif()
endif()


#SWIG support - adding bindings for other languages into a new library that statically include the main SRT lib
if(ENABLE_SWIG)

#older cmakes do not understand SWIG in a trusted manner (e.g. VS2015 AppVeyor cmake is too old, and Travis Xenial)
if (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.21)
cmake_policy(SET CMP0078 NEW)
cmake_policy(SET CMP0086 NEW)
cmake_policy(SET CMP0122 NEW)
else()
message(FATAL_ERROR "ENABLE_SWIG is set, but cmake version is not at least 3.21 and SWIG support may be broken on earlier editions")
endif()

#on windows, there is no swig just in the path - nuget / scripted downloads must be pointed at (linux it just works)
if(MICROSOFT)
#if nuget has been used to install swig in the project packages, bind to that
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/packages/swig/swigwin-4.1.1/swig.exe")
set(SWIG_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}/packages/swig/swigwin-4.1.1/swig.exe")
endif()
endif()

FIND_PACKAGE(SWIG REQUIRED)
INCLUDE(${SWIG_USE_FILE})

if(UNIX AND NOT APPLE)
list(APPEND CMAKE_SWIG_FLAGS "-DSWIGWORDSIZE64")
endif()

if(ENABLE_SWIG_CSHARP)
swig_add_library(srt_swig_csharp LANGUAGE csharp SOURCES srtcore/srt.i OUTPUT_DIR ${CMAKE_BINARY_DIR}/swig_bindings/csharp)
swig_link_libraries(srt_swig_csharp ${srt_link_library} ${DEPENDS_srt})
set_property(TARGET srt_swig_csharp PROPERTY SWIG_COMPILE_OPTIONS -namespace SrtSharp)
endif()
endif()

if (ENABLE_UNITTESTS AND ENABLE_CXX11)

if (${CMAKE_VERSION} VERSION_LESS "3.10.0")
Expand Down
1 change: 1 addition & 0 deletions googletest/googletest-src
Submodule googletest-src added at 703bd9
39 changes: 39 additions & 0 deletions scripts/Dockerfile.linux
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
FROM debian:bullseye

LABEL maintainer="Lewis Kirkaldie <lewis@cinegy.com>"

ENV TZ=Europe/Berlin
ENV APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
ENV DEBIAN_FRONTEND=noninteractive
ENV DOTNET_CLI_TELEMETRY_OPTOUT=1

RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

#base dev packages and OS tools, including mono and boost other library dependencies
RUN apt-get update && apt-get upgrade -y && apt-get install -y \
build-essential git nano gnupg apt-utils unzip sudo bzip2 \
apt-transport-https curl wget ca-certificates cpio \
libssl-dev software-properties-common \
p7zip-full libpcre2-dev bison automake && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# add powershell core & dotnet 6.0
# RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - && \
# sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-debian-bullseye-prod bullseye main" > /etc/apt/sources.list.d/microsoft.list' && \
# apt update && sudo apt install -y powershell && \
# apt-get install -y dotnet-sdk-6.0 && \
# apt-get clean && \
# rm -rf /var/lib/apt/lists/*

#add cmake 3.24.1
RUN mkdir -p /usr/src/cmake \
&& curl -L https://github.com/Kitware/CMake/releases/download/v3.24.1/cmake-3.24.1-linux-x86_64.tar.gz -o /usr/src/cmake/cmake.tar.gz -sS \
&& tar -C /usr/src/cmake -xzf /usr/src/cmake/cmake.tar.gz \
&& ln -s /usr/src/cmake/cmake-3.24.1-linux-x86_64/bin/cmake /usr/bin/cmake \
&& rm /usr/src/cmake/cmake.tar.gz

#add swig 4.1
RUN cd /usr/src && git clone https://github.com/swig/swig.git && cd swig && git checkout release-4.1 \
&& ./autogen.sh && ./configure && make && make install && cd ../ && rm -rf /usr/src/swig
3 changes: 3 additions & 0 deletions scripts/build-lin-docker.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@ECHO OFF
%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\PowerShell.exe -Command "& '%~dpn0.ps1'"
pause
62 changes: 62 additions & 0 deletions scripts/build-lin-docker.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#! /usr/bin/pwsh

################################################################################
# Linux SRT Build Script
#============================
# Usable on a Linux machine (or container), or called by CI systems like AppVeyor
#
# By default produces a 64-bit Release binary using C++11 threads, without
# encryption or unit tests enabled, but including test apps.
################################################################################

param (
[Parameter()][String]$CONFIGURATION = "Release",
[Parameter()][String]$BUILDCONTAINER = "srtselfbuildcontainer",
[Parameter()][String]$DEVENV_PLATFORM = "x64",
[Parameter()][String]$ENABLE_ENCRYPTION = "OFF",
[Parameter()][String]$STATIC_LINK_SSL = "OFF",
[Parameter()][String]$CXX11 = "ON",
[Parameter()][String]$BUILD_APPS = "ON",
[Parameter()][String]$UNIT_TESTS = "OFF",
[Parameter()][String]$BUILD_DIR = "_build-linux",
[Parameter()][String]$BONDING = "ON",
[Parameter()][String]$ENABLE_SWIG = "ON",
[Parameter()][String]$ENABLE_SWIG_CSHARP = "ON"
)

$projectRoot = Join-Path $PSScriptRoot "/.." -Resolve

if($BUILDCONTAINER -eq "srtselfbuildcontainer") {
# the default build container name was passed - so rebuild this self-contained build environment first
# on a CI system, there may be a known-suitable build container already existing, so this can speed up builds
# but if this is on default, we can just self-serve
$execVar = "docker build -t $BUILDCONTAINER -f $($projectRoot)/scripts/Dockerfile.linux ."
Write-Output $execVar
Invoke-Expression "& $execVar"
}

# clear any previous build and create & enter the build directory
$buildDir = Join-Path "$projectRoot" "$BUILD_DIR"
Write-Output "Creating (or cleaning if already existing) the folder $buildDir for project files and outputs"
Remove-Item -Path $buildDir -Recurse -Force -ErrorAction SilentlyContinue | Out-Null
New-Item -ItemType Directory -Path $buildDir -ErrorAction SilentlyContinue | Out-Null

# build the cmake command flags from arguments
$cmakeFlags = "-DCMAKE_BUILD_TYPE=$CONFIGURATION " +
"-DENABLE_STDCXX_SYNC=$CXX11 " +
"-DENABLE_APPS=$BUILD_APPS " +
"-DENABLE_ENCRYPTION=$ENABLE_ENCRYPTION " +
"-DENABLE_UNITTESTS=$UNIT_TESTS " +
"-DENABLE_BONDING=$BONDING " +
"-DENABLE_SWIG=$ENABLE_SWIG " +
"-DENABLE_SWIG_CSHARP=$ENABLE_SWIG_CSHARP"

# generate command for docker run of cmake generation step
$execVar = "docker run --rm -v $($projectRoot):/srt -w /srt/$BUILD_DIR $BUILDCONTAINER cmake -S ../ $cmakeFlags"
Write-Output $execVar
Invoke-Expression "& $execVar"

# generate command for docker run of cmake build
$execVar = "docker run --rm -v $($projectRoot):/srt -w /srt/$BUILD_DIR $BUILDCONTAINER cmake --build ./"
Write-Output $execVar
Invoke-Expression "& $execVar"
14 changes: 14 additions & 0 deletions scripts/build-linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#! /usr/bin/bash

set -e
set -o pipefail

if [ -d Release.linux ]; then
rm -rf ./Release.linux
fi

printf "\nBuilding Release\n"
mkdir Release.linux
cd Release.linux
cmake -S ../ -DENABLE_STDCXX_SYNC=ON -DENABLE_UNITTESTS=ON -DENABLE_EXPERIMENTAL_BONDING=ON -DENABLE_SWIG=ON
cmake --build ./
76 changes: 55 additions & 21 deletions scripts/build-windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
# Usable on a Windows PC with Powershell and Visual studio,
# or called by CI systems like AppVeyor
#
# By default produces a VS2019 64-bit Release binary using C++11 threads, without
# By default produces a VS2022 64-bit Release binary using C++11 threads, without
# encryption or unit tests enabled, but including test apps.
# Before enabling any encryption options, install OpenSSL or set VCKPG flag to build
################################################################################

param (
[Parameter()][String]$VS_VERSION = "2019",
[Parameter()][String]$VS_VERSION = "2022",
[Parameter()][String]$CONFIGURATION = "Release",
[Parameter()][String]$DEVENV_PLATFORM = "x64",
[Parameter()][String]$ENABLE_ENCRYPTION = "OFF",
Expand All @@ -20,13 +20,15 @@ param (
[Parameter()][String]$UNIT_TESTS = "OFF",
[Parameter()][String]$BUILD_DIR = "_build",
[Parameter()][String]$VCPKG_OPENSSL = "OFF",
[Parameter()][String]$BONDING = "OFF"
[Parameter()][String]$BONDING = "OFF",
[Parameter()][String]$ENABLE_SWIG = "OFF",
[Parameter()][String]$ENABLE_SWIG_CSHARP = "ON"
)

# cmake can be optionally installed (useful when running interactively on a developer station).
# The URL for automatic download is defined later in the script, but it should be possible to just vary the
# specific version set below and the URL should be stable enough to still work - you have been warned.
$cmakeVersion = "3.23.2"
$cmakeVersion = "3.25.3"

# make all errors trigger a script stop, rather than just carry on
$ErrorActionPreference = "Stop"
Expand All @@ -36,9 +38,9 @@ $projectRoot = Join-Path $PSScriptRoot "/.." -Resolve
# if running within AppVeyor, use environment variables to set params instead of passed-in values
if ( $Env:APPVEYOR ) {
if ( $Env:PLATFORM -eq 'x86' ) { $DEVENV_PLATFORM = 'Win32' } else { $DEVENV_PLATFORM = 'x64' }
if ( $Env:APPVEYOR_BUILD_WORKER_IMAGE -eq 'Visual Studio 2022' ) { $VS_VERSION='2022' }
if ( $Env:APPVEYOR_BUILD_WORKER_IMAGE -eq 'Visual Studio 2019' ) { $VS_VERSION='2019' }
if ( $Env:APPVEYOR_BUILD_WORKER_IMAGE -eq 'Visual Studio 2015' ) { $VS_VERSION='2015' }
if ( $Env:APPVEYOR_BUILD_WORKER_IMAGE -eq 'Visual Studio 2013' ) { $VS_VERSION='2013' }

#if not statically linking OpenSSL, set flag to gather the specific openssl package from the build server into package
if ( $STATIC_LINK_SSL -eq 'OFF' ) { $Env:GATHER_SSL_INTO_PACKAGE = $true }
Expand All @@ -48,24 +50,28 @@ if ( $Env:APPVEYOR ) {

$CONFIGURATION = $Env:CONFIGURATION

#appveyor has many openssl installations - place the latest one in the default location unless VS2013
if( $VS_VERSION -ne '2013' ) {
Remove-Item -Path "C:\OpenSSL-Win32" -Recurse -Force -ErrorAction SilentlyContinue | Out-Null
Remove-Item -Path "C:\OpenSSL-Win64" -Recurse -Force -ErrorAction SilentlyContinue | Out-Null
Copy-Item -Path "C:\OpenSSL-v111-Win32" "C:\OpenSSL-Win32" -Recurse | Out-Null
Copy-Item -Path "C:\OpenSSL-v111-Win64" "C:\OpenSSL-Win64" -Recurse | Out-Null
}
#appveyor has many openssl installations - place the latest v111 edition in the default location
Remove-Item -Path "C:\OpenSSL-Win32" -Recurse -Force -ErrorAction SilentlyContinue | Out-Null
Remove-Item -Path "C:\OpenSSL-Win64" -Recurse -Force -ErrorAction SilentlyContinue | Out-Null
Copy-Item -Path "C:\OpenSSL-v111-Win32" "C:\OpenSSL-Win32" -Recurse | Out-Null
Copy-Item -Path "C:\OpenSSL-v111-Win64" "C:\OpenSSL-Win64" -Recurse | Out-Null
}

# if running within TeamCity and VS2022 compilation, force SWIG and BONDING to ON (to avoid changing default behaviour on pre-existing CI systems)
# this should be removable ones master branch is merged to always have these params available (so CI can set them reliably itself)
if($Env:TEAMCITY_VERSION -and ($VS_VERSION -eq "2022")){
$ENABLE_SWIG = "ON"
$BONDING = "ON"
}

# persist VS_VERSION so it can be used in an artifact name later
$Env:VS_VERSION = $VS_VERSION

# select the appropriate cmake generator string given the environment
if ( $VS_VERSION -eq '2022' ) { $CMAKE_GENERATOR = 'Visual Studio 17 2022'; $MSBUILDVER = "17.0"; }
if ( $VS_VERSION -eq '2019' ) { $CMAKE_GENERATOR = 'Visual Studio 16 2019'; $MSBUILDVER = "16.0"; }
if ( $VS_VERSION -eq '2015' -and $DEVENV_PLATFORM -eq 'Win32' ) { $CMAKE_GENERATOR = 'Visual Studio 14 2015'; $MSBUILDVER = "14.0"; }
if ( $VS_VERSION -eq '2015' -and $DEVENV_PLATFORM -eq 'x64' ) { $CMAKE_GENERATOR = 'Visual Studio 14 2015 Win64'; $MSBUILDVER = "14.0"; }
if ( $VS_VERSION -eq '2013' -and $DEVENV_PLATFORM -eq 'Win32' ) { $CMAKE_GENERATOR = 'Visual Studio 12 2013'; $MSBUILDVER = "12.0"; }
if ( $VS_VERSION -eq '2013' -and $DEVENV_PLATFORM -eq 'x64' ) { $CMAKE_GENERATOR = 'Visual Studio 12 2013 Win64'; $MSBUILDVER = "12.0"; }

# clear any previous build and create & enter the build directory
$buildDir = Join-Path "$projectRoot" "$BUILD_DIR"
Expand Down Expand Up @@ -132,13 +138,32 @@ if ( $VCPKG_OPENSSL -eq "ON" ) {
}
}

# check to see if SWIG is marked to be used - if so, download swig into packages folder so cmake can find it
if ( $ENABLE_SWIG -eq "ON" ) {
if ( Test-Path "$projectRoot/packages/swig/swigwin-4.1.1" ) {
Write-Output "Found pre-existing copy of Swigwin 4.1.1 - using this binary"
}
else {
#originally, script downloaded from sourceforge from link below, but this was flakey
#and therefore was copied to a Cinegy-controlled S3 mirror bucket
#original source URL: https://deac-fra.dl.sourceforge.net/project/swig/swigwin/swigwin-4.1.1/swigwin-4.1.1.zip
Write-Output "Swigwin 4.1.1 not found - downloading and unpacking..."
Remove-Item -LiteralPath $projectRoot/packages/swig/ -Force -Recurse -ErrorAction Ignore
Invoke-WebRequest 'https://caas-deploy.s3.eu-central-1.amazonaws.com/v1/Thirdparty-Swig-v4.x/swigwin-4.1.1.zip' -OutFile swig.zip
Expand-Archive swig.zip -DestinationPath $projectRoot/packages/swig
Remove-Item swig.zip
}
}

# build the cmake command flags from arguments
$cmakeFlags = "-DCMAKE_BUILD_TYPE=$CONFIGURATION " +
"-DENABLE_STDCXX_SYNC=$CXX11 " +
"-DENABLE_APPS=$BUILD_APPS " +
"-DENABLE_ENCRYPTION=$ENABLE_ENCRYPTION " +
"-DENABLE_BONDING=$BONDING " +
"-DENABLE_UNITTESTS=$UNIT_TESTS"
"-DENABLE_STDCXX_SYNC=$CXX11 " +
"-DENABLE_APPS=$BUILD_APPS " +
"-DENABLE_ENCRYPTION=$ENABLE_ENCRYPTION " +
"-DENABLE_BONDING=$BONDING " +
"-DENABLE_UNITTESTS=$UNIT_TESTS " +
"-DENABLE_SWIG=$ENABLE_SWIG " +
"-DENABLE_SWIG_CSHARP=$ENABLE_SWIG_CSHARP"

# if VCPKG is flagged to provide OpenSSL, checkout VCPKG and install package
if ( $VCPKG_OPENSSL -eq 'ON' ) {
Expand Down Expand Up @@ -181,8 +206,8 @@ else {
$cmakeFlags += " -DOPENSSL_USE_STATIC_LIBS=$STATIC_LINK_SSL "
}

# cmake uses a flag for architecture from vs2019, so add that as a suffix
if ( $VS_VERSION -eq '2019' ) {
# cmake uses a flag for architecture from vs2019 onwards, so add that as a suffix
if ( $VS_VERSION -eq '2019' -or $VS_VERSION -eq '2022') {
$cmakeFlags += " -A `"$DEVENV_PLATFORM`""
}

Expand Down Expand Up @@ -229,6 +254,15 @@ if ( $null -eq $msBuildPath ) {

& $msBuildPath SRT.sln -m /p:Configuration=$CONFIGURATION /p:Platform=$DEVENV_PLATFORM

# if CSharp SWIG is on, now trigger compilation of these elements (cmake for dotnet is very new, and not available in older versions)
if(($ENABLE_SWIG -eq "ON") -and ($ENABLE_SWIG_CSHARP -eq "ON")){
Push-Location "$buildDir/swig_bindings/csharp"
Copy-Item "$projectRoot/srtcore/swig_bindings/csharp/*.csproj" .
& dotnet build -c $CONFIGURATION
Copy-Item "bin/$CONFIGURATION/netstandard2.0/*.dll" "$buildDir/$CONFIGURATION"
Pop-Location
}

# return to the directory previously occupied before running the script
Pop-Location

Expand Down
Loading