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
|
# Package
version = "0.1.0"
author = "genotrance"
description = "C/C++ interop for Nim"
license = "MIT"
# this gives Warning: Binary 'nimterop/toast' was already installed from source directory
# when running `nimble install --verbose -y`
bin = @["nimterop/toast"]
installDirs = @["nimterop"]
installFiles = @["config.nims"]
# Dependencies
requires "nim >= 0.19.2", "regex >= 0.10.0", "cligen >= 0.9.17"
import strformat
proc execCmd(cmd: string) =
echo "execCmd:" & cmd
exec cmd
proc execTest(test: string) =
execCmd "nim c -r " & test
execCmd "nim cpp -r " & test
proc tsoloud() =
execTest "tests/tsoloud.nim"
task buildToast, "build toast":
# If need to manually rebuild (automatically built on 1st need)
execCmd(&"nim c -d:release nimterop/toast.nim")
proc testAll() =
execTest "tests/tnimterop_c.nim"
execCmd "nim cpp -r tests/tnimterop_cpp.nim"
execTest "tests/tpcre.nim"
## platform specific tests
when defined(Windows):
execTest "tests/tmath.nim"
if defined(OSX) or defined(Windows) or not existsEnv("TRAVIS"):
tsoloud() # requires some libraries on linux, need them installed in TRAVIS
const htmldocsDir = "build/htmldocs"
when (NimMajor, NimMinor, NimPatch) >= (0, 19, 9):
import os
proc getNimRootDir(): string =
#[
hack, but works
alternatively (but more complex), use (from a nim file, not nims otherwise
you get Error: ambiguous call; both system.fileExists):
import "$nim/testament/lib/stdtest/specialpaths.nim"
nimRootDir
]#
fmt"{currentSourcePath}".parentDir.parentDir.parentDir
proc runNimDoc() =
execCmd &"nim doc -o:{htmldocsDir} --project --index:on nimterop/all.nim"
execCmd &"nim buildIndex -o:{htmldocsDir}/theindex.html {htmldocsDir}"
when declared(getNimRootDir):
#[
this enables doc search, works at least locally with:
cd {htmldocsDir} && python -m SimpleHTTPServer 9009
]#
execCmd &"nim js -o:{htmldocsDir}/dochack.js {getNimRootDir()}/tools/dochack/dochack.nim"
task test, "Test":
buildToastTask()
testAll()
runNimDoc()
task docs, "Generate docs":
runNimDoc()
task docsPublish, "Generate and publish docs":
# Uses: pip install ghp-import
runNimDoc()
execCmd &"ghp-import --no-jekyll -fp {htmldocsDir}"
|