Initial version of ngtcp2 wrapper

This commit is contained in:
Mark Spanbroek 2020-09-07 14:06:44 +02:00
commit 6fdeaa707a
8 changed files with 65 additions and 0 deletions

5
.editorconfig Normal file
View File

@ -0,0 +1,5 @@
[*]
indent_style = space
insert_final_newline = true
indent_size = 2
trim_trailing_whitespace = true

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
*
!*/
!*.*

1
.tool-versions Normal file
View File

@ -0,0 +1 @@
nim 1.2.6

6
Readme.md Normal file
View File

@ -0,0 +1,6 @@
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.

20
ngtcp2.nim Normal file
View File

@ -0,0 +1,20 @@
import os
import nimterop/cimport
import ngtcp2/sources
static:
cCompile(ngtcp2src/"lib"/"*.c")
when defined(windows):
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
cIncludeDir(ngtcp2src/"lib"/"includes")
cImport(ngtcp2src/"lib"/"includes"/"ngtcp2"/"ngtcp2.h")

13
ngtcp2.nimble Normal file
View File

@ -0,0 +1,13 @@
packageName = "ngtcp2"
version = "0.1.0"
author = "Status Research & Development GmbH"
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"

14
ngtcp2/make.nim Normal file
View File

@ -0,0 +1,14 @@
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="."
)

3
ngtcp2/sources.nim Normal file
View File

@ -0,0 +1,3 @@
import nimterop/build
const ngtcp2src* = getProjectCacheDir("ngtcp2")