-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.nims
140 lines (106 loc) · 3.81 KB
/
config.nims
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# Build tasks
when fileExists("libtrackerboy.nimble"):
import std/[strutils, strformat]
import std/os
const
binDir = "bin"
flagOutdir = "--outdir:" & binDir
gitRef {.strdefine.} = "develop"
proc vexec(args: varargs[string]) =
exec(quoteShellCommand(args))
template nohints() = --hints:off
# SETUP
task setDev, "Sets this project to develop mode (dev dependencies enabled)":
nohints()
writeFile(".dev", "")
# TESTING
task endianTests, "Runs tests/private/tendian.nim with different configurations":
nohints()
# test matrix
# 0. Native endian w/ builtin bswap
# 1. Native endian w/ reference bswap
# 2. Inverse endian w/ builtin bswap
# 3. Inverse endian w/ reference bswap
const matrix = [
"",
"-d:noIntrinsicsEndians",
"-d:tbEndianInverse",
"-d:noIntrinsicsEndians -d:tbEndianInverse"
]
for defs in matrix:
echo "switches: ", defs
exec &"nim r --hints:off {defs} tests/units/private/tendian.nim"
task buildTests, "Builds the unit tester":
nohints()
vexec("nim", "--hints:off", "--rangeChecks:on", "c", flagOutdir, "tests/tests.nim")
task test, "Runs unit tests":
buildTestsTask()
try:
exec binDir / "tests"
echo "All tests passed."
except OSError:
discard
# DEMO/STANDALONE TEST PROGRAMS
proc standalone(name: string) =
nohints()
vexec "nim", "c", flagOutdir, "--run", "tests/standalones/" & name
task apugen, "Generate demo APU wav files":
standalone("apugen.nim")
task wavegen, "Generate demo synth waveforms":
standalone("wavegen.nim")
task wavexport, "Test the wav exporter":
standalone("wavexport.nim")
task wavutil, "Exports a song from a module to wav":
standalone("wavutil.nim")
# DOCUMENTATION
task docsSpecs, "Generate documentation for file format specifications":
nohints()
for name in [
"tbm-spec-major-0",
"tbm-spec-major-1",
"tbm-spec-major-2"
]:
withDir "docs":
echo &"Generating HTML page for 'docs/{name}.adoc'"
exec &"asciidoctor --failure-level ERROR --trace {name}.adoc -o ../htmldocs/{name}.html"
echo &"Generating PDF document for 'docs/{name}.adoc'"
exec &"asciidoctor-pdf --failure-level ERROR --trace {name}.adoc -o ../htmldocs/{name}.pdf"
proc getGitArgs(): string =
result = &"--git.url:https://github.com/stoneface86/libtrackerboy --git.commit:{gitRef} --git.devel:develop"
proc docsRstImpl(gitargs: string) =
for filename in [
"docs/module-file-format-spec.rst"
]:
echo &"Generating page for '{filename}'"
exec &"nim rst2html --hints:off --index:on --outdir:htmldocs {gitargs} \"{filename}\""
task docsRst, "Generate RST documents":
nohints()
docsRstImpl(getGitArgs())
task docs, "Generate documentation":
nohints()
let gitargs = getGitArgs()
# remove previously generated documentation if exists
rmDir "htmldocs"
# Generate all rst documents
docsRstImpl(gitargs)
echo "Indexing whole project..."
exec "nim doc --hints:off --project --index:only libtrackerboy.nim"
# generate project documentation via libtrackerboy.nim
echo "Generating documentation for whole project..."
exec &"nim doc --hints:off --project --outdir:htmldocs {gitargs} libtrackerboy.nim"
# generate the index
echo "Building index..."
exec &"nim buildIndex --hints:off -o:htmldocs/theindex.html {gitargs} htmldocs"
# remove .idx files
for filename in walkDirRec("htmldocs"):
if filename.endsWith(".idx"):
rmFile(filename)
# MISC
task clean, "Clears the bin and htmldocs folders":
nohints()
rmDir "bin"
rmDir "htmldocs"
# begin Nimble config (version 2)
when withDir(thisDir(), system.fileExists("nimble.paths")):
include "nimble.paths"
# end Nimble config