-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathnimterop.nimble
109 lines (79 loc) · 2.8 KB
/
nimterop.nimble
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# Package
version = "0.6.13"
author = "genotrance"
description = "C/C++ interop for Nim"
license = "MIT"
bin = @["nimterop/toast", "nimterop/loaf"]
installDirs = @["nimterop"]
# Dependencies
requires "nim >= 0.20.2", "regex >= 0.15.0", "cligen >= 1.0.0"
import nimterop/docs
import os
proc execCmd(cmd: string) =
exec "tests/timeit " & cmd
proc execTest(test: string, flags = "", runDocs = true) =
execCmd "nim c --hints:off -f -d:checkAbi " & flags & " -r " & test
let
# -d:checkAbi broken in cpp mode until post 1.2.0
cppAbi = when (NimMajor, NimMinor) >= (1, 3): "-d:checkAbi " else: ""
execCmd "nim cpp --hints:off " & cppAbi & flags & " -r " & test
if runDocs:
let docPath = "build/html_" & test.extractFileName.changeFileExt("") & "_docs"
rmDir docPath
mkDir docPath
buildDocs(@[test], docPath, nimArgs = "--hints:off " & flags)
task buildTimeit, "build timer":
exec "nim c --hints:off -d:danger tests/timeit"
task buildLoaf, "build loaf":
execCmd("nim c --hints:off -d:danger nimterop/loaf.nim")
task buildToast, "build toast":
execCmd("nim c --hints:off -d:danger nimterop/toast.nim")
task bt, "build toast":
buildToastTask()
task btd, "build toast":
execCmd("nim c -g nimterop/toast.nim")
task docs, "Generate docs":
buildDocs(@["nimterop/all.nim"], "build/htmldocs")
task minitest, "Test for Nim CI":
exec "nim c -f -d:danger nimterop/loaf.nim"
exec "nim c -f -d:danger nimterop/toast"
exec "nim c -f -d:checkAbi -r tests/tast2.nim"
exec "nim c -f -d:checkAbi -d:zlibJBB -d:zlibSetVer=1.2.11 -r tests/zlib.nim"
task basic, "Basic tests":
execTest "tests/tast2.nim"
execTest "tests/tast2.nim", "-d:NOHEADER"
execTest "tests/tast2.nim", "-d:NOHEADER -d:WRAPPED"
execTest "tests/tnimterop_c.nim"
execTest "tests/tnimterop_c.nim", "-d:FLAGS=\"-H\""
execCmd "nim cpp --hints:off -f -r tests/tnimterop_cpp.nim"
execCmd "./nimterop/toast tests/toast.cfg tests/include/toast.h"
task wrapper, "Wrapper tests":
execTest "tests/tpcre.nim"
when defined(Linux):
execTest "tests/rsa.nim"
execTest "tests/rsa.nim", "-d:FLAGS=\"-H\""
# Platform specific tests
when defined(Windows):
execTest "tests/tmath.nim"
execTest "tests/tmath.nim", "-d:FLAGS=\"-H\""
if defined(OSX) or defined(Windows) or not existsEnv("TRAVIS"):
execTest "tests/tsoloud.nim"
execTest "tests/tsoloud.nim", "-d:FLAGS=\"-H\""
task getheader, "getHeader tests":
withDir("tests"):
exec "nim e getheader.nims"
task package, "Wrapper package tests":
if not existsEnv("APPVEYOR"):
withDir("tests"):
exec "nim e wrappers.nims"
task test, "Test":
rmFile("tests/timeit.txt")
buildTimeitTask()
buildLoafTask()
buildToastTask()
basicTask()
wrapperTask()
getheaderTask()
packageTask()
docsTask()
echo readFile("tests/timeit.txt")