Here's a working wrapper for nghttp2. It will download the code from github, 
build it with `cmake/make` or `configure/make` and link the lib. You can pick 
static or dynamic linking.

To compile and link dynamically: `nim c -d:nghttp2Git nghttp2.nim`

To statically link add: `-d:nghttp2Static`

To pick a specific git tag: `-d:nghttp2SetVer=v1.40.0`
    
    
    import os
    
    import nimterop/[build, cimport]
    
    const
      baseDir = currentSourcePath.parentDir() / "nghttp2Lib"
    
    getHeader(
      header = "nghttp2.h",
      giturl = "https://github.com/nghttp2/nghttp2";,
      outdir = baseDir,
      cmakeFlags = "-DENABLE_LIB_ONLY=ON -DENABLE_STATIC_LIB=ON",
      conFlags = "--enable-lib-only"
    )
    
    static:
      cDebug()
      cSkipSymbol(@["NGHTTP2_PROTO_ALPN"])
    
    cIncludeDir(baseDir / "buildcache" / "lib" / "includes")
    
    when isDefined(nghttp2Static):
      cImport(nghttp2Path)
    else:
      cImport(nghttp2Path, dynlib="nghttp2LPath")
    
    
    Run

I have only tested on Linux but it should work cross-platform if nghttp2 
compiles smoothly on those platforms.

Reply via email to