aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGanesh Viswanathan <dev@genotrance.com>2019-05-08 23:24:15 -0500
committerGanesh Viswanathan <dev@genotrance.com>2019-05-08 23:24:15 -0500
commit7611093750685332944953600eb989272cbf428c (patch)
tree93978bf73839da410a9b4f150560974ab701e2d5 /tests
parentdef527ae6052a707bb61c0cd5e3cdc8be55130a5 (diff)
downloadnimterop-7611093750685332944953600eb989272cbf428c.tar.gz
nimterop-7611093750685332944953600eb989272cbf428c.zip
Add dynlib support
Diffstat (limited to 'tests')
-rw-r--r--tests/tpcre.nim35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/tpcre.nim b/tests/tpcre.nim
new file mode 100644
index 0000000..705525f
--- /dev/null
+++ b/tests/tpcre.nim
@@ -0,0 +1,35 @@
+import os
+
+import nimterop/[cimport, git, paths]
+
+const
+ baseDir = nimteropBuildDir()/"pcre"
+ pcreH = baseDir/"pcre.h.in"
+
+static:
+ if not pcreH.fileExists():
+ downloadUrl("https://github.com/svn2github/pcre/raw/master/pcre.h.in", baseDir)
+ cDebug()
+ cDisableCaching()
+
+const
+ dynpcre =
+ when defined(windows):
+ when defined(cpu64):
+ "pcre64.dll"
+ else:
+ "pcre32.dll"
+ elif hostOS == "macosx":
+ "libpcre(.3|.1|).dylib"
+ else:
+ "libpcre.so(.3|.1|)"
+
+cPlugin:
+ import strutils
+
+ proc onSymbol*(sym: var Symbol) {.exportc, dynlib.} =
+ sym.name = sym.name.replace("pcre_", "")
+
+cImport(pcreH, dynlib="dynpcre")
+
+echo version() \ No newline at end of file