2020-09-08 06:38:20 +00:00
|
|
|
#!/bin/bash
|
|
|
|
root=$(dirname "$0")
|
|
|
|
|
|
|
|
# install nimterop, if not already installed
|
|
|
|
if ! [ -x "$(command -v toast)" ]; then
|
2024-08-16 11:35:36 +00:00
|
|
|
nimble install -y nimterop@2532ce0
|
2020-09-08 06:38:20 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# run cmake on ngtcp2 sources
|
|
|
|
cmake -S "${root}/sources" -B "${root}/build"
|
|
|
|
|
2020-09-10 15:09:14 +00:00
|
|
|
# add prelude
|
|
|
|
cat "${root}/prelude.nim" > "${root}/ngtcp2.nim"
|
2020-09-08 06:38:20 +00:00
|
|
|
|
|
|
|
# dividing line
|
|
|
|
echo >> "${root}/ngtcp2.nim"
|
|
|
|
|
2020-09-08 06:47:23 +00:00
|
|
|
# assemble list of C files to be compiled
|
|
|
|
for file in `ls "${root}/sources/lib"/*.c`; do
|
|
|
|
compile="${compile} --compile=${file}"
|
|
|
|
done
|
|
|
|
|
2020-09-08 06:38:20 +00:00
|
|
|
# generate nim wrapper with nimterop
|
|
|
|
toast \
|
2020-09-08 06:47:23 +00:00
|
|
|
$compile \
|
2020-09-08 06:38:20 +00:00
|
|
|
--pnim \
|
|
|
|
--preprocess \
|
2020-09-08 07:38:41 +00:00
|
|
|
--noHeader \
|
2020-09-08 07:42:52 +00:00
|
|
|
--defines=NGTCP2_STATICLIB \
|
2024-08-16 11:35:36 +00:00
|
|
|
--replace=sockaddr=SockAddr,SockAddr_storage=Sockaddr_storage,socklen_t=SockLen \
|
2020-09-08 06:38:20 +00:00
|
|
|
--includeDirs="${root}/sources/lib/includes" \
|
|
|
|
--includeDirs="${root}/build/lib/includes" \
|
|
|
|
"${root}/sources/lib/includes/ngtcp2/ngtcp2.h" >> "${root}/ngtcp2.nim"
|
2022-08-26 10:03:55 +00:00
|
|
|
|
|
|
|
sed -i 's/\bpassC\b/passc/g' ngtcp2.nim
|