commit 6fdeaa707a59994978e900a18bcfccff054094ec Author: Mark Spanbroek Date: Mon Sep 7 14:06:44 2020 +0200 Initial version of ngtcp2 wrapper diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..1963f8d --- /dev/null +++ b/.editorconfig @@ -0,0 +1,5 @@ +[*] +indent_style = space +insert_final_newline = true +indent_size = 2 +trim_trailing_whitespace = true \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..becd7f9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +* +!*/ +!*.* diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 0000000..b1180c5 --- /dev/null +++ b/.tool-versions @@ -0,0 +1 @@ +nim 1.2.6 diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000..c51a20e --- /dev/null +++ b/Readme.md @@ -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. diff --git a/ngtcp2.nim b/ngtcp2.nim new file mode 100644 index 0000000..625318c --- /dev/null +++ b/ngtcp2.nim @@ -0,0 +1,20 @@ +import os +import nimterop/cimport +import ngtcp2/sources + +static: + cCompile(ngtcp2src/"lib"/"*.c") + +when defined(windows): + const socketheader = "" +else: + const socketheader = "" + +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") diff --git a/ngtcp2.nimble b/ngtcp2.nimble new file mode 100644 index 0000000..c16a85f --- /dev/null +++ b/ngtcp2.nimble @@ -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" diff --git a/ngtcp2/make.nim b/ngtcp2/make.nim new file mode 100644 index 0000000..cce1830 --- /dev/null +++ b/ngtcp2/make.nim @@ -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="." + ) diff --git a/ngtcp2/sources.nim b/ngtcp2/sources.nim new file mode 100644 index 0000000..e0a4214 --- /dev/null +++ b/ngtcp2/sources.nim @@ -0,0 +1,3 @@ +import nimterop/build + +const ngtcp2src* = getProjectCacheDir("ngtcp2")