forked from Clonkk/duckdb_wrapper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
duckdb_wrapper.nim
36 lines (26 loc) · 1.11 KB
/
duckdb_wrapper.nim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import nimterop/cimport
import nimterop/build
import os
when defined(Linux):
const duckdbUrl = "https://github.com/cwida/duckdb/releases/download/v0.2.3/libduckdb-linux-amd64.zip"
when defined(Windows):
when defined(cpu64):
const duckdbUrl = "https://github.com/cwida/duckdb/releases/download/v0.2.3/libduckdb-windows-amd64.zip"
when defined(cpu32):
const duckdbUrl = "https://github.com/cwida/duckdb/releases/download/v0.2.3/libduckdb-windows-i386.zip"
const baseDir = getProjectCacheDir("duckdb") & "/"
static:
# Uncomment to see output
cDebug()
const duckdbZip = lastPathPart(duckdbUrl)
downloadUrl(duckdbUrl, baseDir)
const outdir = "."
extractZip(normalizedPath(baseDir & duckdbzip), outdir)
# Workaround due to nimterop and #include <stdbool.h> not being compatible
# See https://github.com/nimterop/nimterop/issues/260
cPlugin:
proc onSymbol*(sym: var Symbol) {.exportc, dynlib.} =
if sym.name == "_Bool": sym.name = "bool"
const duckDbH = normalizedPath(baseDir & "duckdb.h")
const duckDbLib = normalizedPath(baseDir & "libduckdb.so")
cImport(duckDbH, recurse = true, dynlib = duckDbLib)