mirror of https://github.com/vacp2p/nim-ngtcp2.git
Add build script that converts C headers to a single nim source
Removes the need to have CMake when requiring this package.
This commit is contained in:
parent
f297f97045
commit
b1f9dd4ab1
|
@ -1,3 +1,4 @@
|
|||
*
|
||||
!*/
|
||||
!*.*
|
||||
build
|
||||
|
|
|
@ -2,5 +2,4 @@ ngtcp2 for Nim
|
|||
==============
|
||||
|
||||
Wrapper around the [ngtcp2](https://github.com/ngtcp2/ngtcp2) C library for
|
||||
[Nim](https://nim-lang.org/). Requires [CMake](https://cmake.org/) to be
|
||||
installed.
|
||||
[Nim](https://nim-lang.org/).
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
#!/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 cmake on ngtcp2 sources
|
||||
cmake -S "${root}/sources" -B "${root}/build"
|
||||
|
||||
# socket definitions
|
||||
cat "${root}/sockets.nim" > "${root}/ngtcp2.nim"
|
||||
|
||||
# dividing line
|
||||
echo >> "${root}/ngtcp2.nim"
|
||||
|
||||
# generate nim wrapper with nimterop
|
||||
toast \
|
||||
--pnim \
|
||||
--preprocess \
|
||||
--includeDirs="${root}/sources/lib/includes" \
|
||||
--includeDirs="${root}/build/lib/includes" \
|
||||
"${root}/sources/lib/includes/ngtcp2/ngtcp2.h" >> "${root}/ngtcp2.nim"
|
|
@ -5,9 +5,3 @@ description = "Nim wrapper around the ngtcp2 library"
|
|||
license = "MIT"
|
||||
|
||||
requires "nim >= 1.2.6"
|
||||
requires "nimterop >= 0.6.11 & < 0.7.0"
|
||||
|
||||
import os
|
||||
|
||||
after install:
|
||||
exec "nim c -r " & currentSourcePath.parentDir/"ngtcp2"/"make.nim"
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
import nimterop/build
|
||||
import sources
|
||||
|
||||
static:
|
||||
gitPull(
|
||||
"https://github.com/ngtcp2/ngtcp2",
|
||||
checkout="d234d50",
|
||||
outdir=ngtcp2src
|
||||
)
|
||||
cmake(
|
||||
ngtcp2src,
|
||||
check="lib"/"includes"/"ngtcp2"/"version.h",
|
||||
flags="."
|
||||
)
|
|
@ -1,3 +0,0 @@
|
|||
import nimterop/build
|
||||
|
||||
const ngtcp2src* = getProjectCacheDir("ngtcp2")
|
|
@ -0,0 +1,13 @@
|
|||
# Import socket definitions from system
|
||||
|
||||
when defined(windows):
|
||||
{.passL: "-lws2_32".}
|
||||
const socketheader = "<winsock2.h>"
|
||||
else:
|
||||
const socketheader = "<sys/socket.h>"
|
||||
|
||||
type
|
||||
sockaddr*
|
||||
{.header: socketheader, importc: "sockaddr".} = object
|
||||
sockaddr_storage*
|
||||
{.header: socketheader, importc: "sockaddr_storage".} = object
|
Loading…
Reference in New Issue