2022-10-27 10:49:53 +00:00
|
|
|
#!/bin/bash
|
|
|
|
root=$(dirname "$0")
|
2022-10-28 12:35:56 +00:00
|
|
|
outputFile="${root}/webrtc/usrsctp.nim"
|
2022-10-27 10:49:53 +00:00
|
|
|
|
|
|
|
# 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
|
2022-10-28 12:35:56 +00:00
|
|
|
cd "${root}/usrsctp" && ./bootstrap && ./configure && make && cd -
|
2022-10-27 10:49:53 +00:00
|
|
|
|
|
|
|
# add prelude
|
2022-10-28 12:35:56 +00:00
|
|
|
cat "${root}/prelude.nim" > "${outputFile}"
|
2022-10-27 10:49:53 +00:00
|
|
|
|
|
|
|
# assemble list of C files to be compiled
|
|
|
|
for file in `find ${root}/usrsctp/usrsctplib -name '*.c'`; do
|
|
|
|
compile="${compile} --compile=${file}"
|
|
|
|
done
|
|
|
|
|
2022-11-03 16:27:01 +00:00
|
|
|
# TODO: Make something more reliable, aka remove this LIBCFLAGS
|
|
|
|
# and put the different flags on prelude.nim depending on the
|
|
|
|
# OS we're currently on
|
2022-10-28 12:35:56 +00:00
|
|
|
LIBCFLAGS="$(grep "^LIBCFLAGS = " "${root}/usrsctp/Makefile" | cut -d' ' -f3- | sed 's/-D/--defines=/g')"
|
|
|
|
|
2022-10-27 10:49:53 +00:00
|
|
|
# generate nim wrapper with nimterop
|
|
|
|
toast \
|
|
|
|
$compile \
|
|
|
|
--pnim \
|
|
|
|
--preprocess \
|
|
|
|
--noHeader \
|
2022-10-28 12:35:56 +00:00
|
|
|
$LIBCFLAGS \
|
2022-10-27 10:49:53 +00:00
|
|
|
--replace=sockaddr=SockAddr \
|
|
|
|
--replace=SockAddr_storage=Sockaddr_storage \
|
2022-10-28 12:35:56 +00:00
|
|
|
--replace=SockAddr_in=Sockaddr_in \
|
|
|
|
--replace=SockAddr_conn=Sockaddr_conn \
|
2022-10-27 10:49:53 +00:00
|
|
|
--replace=socklen_t=SockLen \
|
|
|
|
--includeDirs="${root}/usrsctp/usrsctplib" \
|
2022-10-28 12:35:56 +00:00
|
|
|
"${root}/usrsctp/usrsctplib/usrsctp.h" >> "${outputFile}"
|
|
|
|
|
|
|
|
sed -i 's/\bpassC\b/passc/g' "${outputFile}"
|