Initial commit

This commit is contained in:
Ludovic Chenut 2022-10-27 12:49:53 +02:00
commit 42ec914844
No known key found for this signature in database
GPG Key ID: D9A59B1907F1D50C
5 changed files with 1351 additions and 0 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "usrsctp"]
path = usrsctp
url = git@github.com:sctplab/usrsctp.git

34
build.sh Executable file
View File

@ -0,0 +1,34 @@
#!/bin/bash
root=$(dirname "$0")
# install nimterop, if not already installed
if ! [ -x "$(command -v toast)" ]; then
nimble install -y nimterop@0.6.11
fi
# run make on usrsctp sources
cd "${root}/usrsctp" && ./bootstrap && ./configure && make && cd "${root}"
# add prelude
cat "${root}/prelude.nim" > "${root}/usrsctp.nim"
# dividing line
echo >> "${root}/usrsctp.nim"
# assemble list of C files to be compiled
for file in `find ${root}/usrsctp/usrsctplib -name '*.c'`; do
compile="${compile} --compile=${file}"
done
# generate nim wrapper with nimterop
toast \
$compile \
--pnim \
--preprocess \
--noHeader \
--defines=NGTCP2_STATICLIB \
--replace=sockaddr=SockAddr \
--replace=SockAddr_storage=Sockaddr_storage \
--replace=socklen_t=SockLen \
--includeDirs="${root}/usrsctp/usrsctplib" \
"${root}/usrsctp/usrsctplib/usrsctp.h" >> "${root}/usrsctp.nim"

15
prelude.nim Normal file
View File

@ -0,0 +1,15 @@
import os
import strformat
# Socket definitions
import nativesockets
when defined(windows):
{.passl: "-lws2_32".}
# C include directories
const root = currentSourcePath.parentDir
const sourceInclude = root/"sources"/"lib"/"includes"
const buildInclude = root/"build"/"lib"/"includes"
{.passc: fmt"-I{sourceInclude} -I{buildInclude}".}

1
usrsctp Submodule

@ -0,0 +1 @@
Subproject commit 01cc4e042e2235b29d9d489d89728a6f9ac063ed

1298
usrsctp.nim Normal file

File diff suppressed because it is too large Load Diff