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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
|
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- This file is generated by Nim. -->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Favicon -->
<link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>
<link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QQQEwksSS9ZWwAAAk1JREFUWMPtll2ITVEUx39nn/O7Y5qR8f05wtCUUr6ZIS++8pEnkZInPImneaCQ5METNdOkeFBKUhMPRIkHKfEuUZSUlGlKPN2TrgfncpvmnntnmlEyq1Z7t89/rf9a6+y99oZxGZf/XeIq61EdtgKXgdXA0xrYAvBjOIF1AI9zvjcC74BSpndrJPkBWDScTF8Aa4E3wDlgHbASaANmVqlcCnwHvgDvgVfAJ+AikAAvgfVZwLnSVZHZaOuKoQi3ZOMi4NkYkpe1p4J7A8BpYAD49hfIy/oqG0+hLomiKP2L5L+1ubn5115S+3OAn4EnwBlgMzCjyt6ZAnQCJ4A7wOs88iRJHvw50HoujuPBoCKwHWiosy8MdfZnAdcHk8dxXFJ3VQbQlCTJvRBCGdRbD4M6uc5glpY3eAihpN5S5w12diSEcCCEcKUO4ljdr15T76ur1FDDLIQQ3qv71EdDOe3Kxj3leRXyk+pxdWnFWod6Wt2bY3de3aSuUHcPBVimHs7mK9WrmeOF6lR1o9qnzskh2ar2qm1qizpfXaPeVGdlmGN5pb09qMxz1Xb1kLqgzn1RyH7JUXW52lr5e/Kqi9qpto7V1atuUzfnARrV7jEib1T76gG2qxdGmXyiekkt1GswPTtek0aBfJp6YySGBfWg2tPQ0FAYgf1stUfdmdcjarbYJEniKIq6gY/Aw+zWHAC+p2labGpqiorFYgGYCEzN7oQdQClN07O1/EfDyGgC0ALMBdYAi4FyK+4H3gLPsxfR1zRNi+NP7nH5J+QntnXe5B5mpfQAAAAASUVORK5CYII=">
<!-- Google fonts -->
<link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
<link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
<!-- CSS -->
<title>build</title>
<link rel="stylesheet" type="text/css" href="nimdoc.out.css">
<script type="text/javascript" src="dochack.js"></script>
<script type="text/javascript">
function main() {
var pragmaDots = document.getElementsByClassName("pragmadots");
for (var i = 0; i < pragmaDots.length; i++) {
pragmaDots[i].onclick = function(event) {
// Hide tease
event.target.parentNode.style.display = "none";
// Show actual
event.target.parentNode.nextElementSibling.style.display = "inline";
}
}
const toggleSwitch = document.querySelector('.theme-switch input[type="checkbox"]');
function switchTheme(e) {
if (e.target.checked) {
document.documentElement.setAttribute('data-theme', 'dark');
localStorage.setItem('theme', 'dark');
} else {
document.documentElement.setAttribute('data-theme', 'light');
localStorage.setItem('theme', 'light');
}
}
toggleSwitch.addEventListener('change', switchTheme, false);
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
document.documentElement.setAttribute('data-theme', "dark");
toggleSwitch.checked = true;
} else if (window.matchMedia && window.matchMedia('(prefers-color-scheme: light)').matches) {
document.documentElement.setAttribute('data-theme', "light");
toggleSwitch.checked = false;
} else {
const currentTheme = localStorage.getItem('theme') ? localStorage.getItem('theme') : null;
if (currentTheme) {
document.documentElement.setAttribute('data-theme', currentTheme);
if (currentTheme === 'dark') {
toggleSwitch.checked = true;
}
}
}
}
</script>
</head>
<body onload="main()">
<div class="document" id="documentId">
<div class="container">
<h1 class="title">build</h1>
<div class="row">
<div class="three columns">
<div class="theme-switch-wrapper">
<label class="theme-switch" for="checkbox">
<input type="checkbox" id="checkbox" />
<div class="slider round"></div>
</label>
<em>Dark Mode</em>
</div>
<div id="global-links">
<ul class="simple">
</ul>
</div>
<div id="searchInputDiv">
Search: <input type="text" id="searchInput"
onkeyup="search()" />
</div>
<div>
Group by:
<select onchange="groupBy(this.value)">
<option value="section">Section</option>
<option value="type">Type</option>
</select>
</div>
<ul class="simple simple-toc" id="toc-list">
<li>
<a class="reference reference-toplevel" href="#7" id="57">Types</a>
<ul class="simple simple-toc-section">
<li><a class="reference" href="#BuildType"
title="BuildType = enum
btAutoconf, btCmake"><wbr />Build<wbr />Type<span class="attachedType"></span></a></li>
<li><a class="reference" href="#Config"
title="Config = ref object
NimMajor*: int
NimMinor*: int
NimPatch*: int
paths*: OrderedSet[string]
nimblePaths*: OrderedSet[string]
nimcacheDir*: string"><wbr />Config<span class="attachedType"></span></a></li>
</ul>
</li>
<li>
<a class="reference reference-toplevel" href="#8" id="58">Vars</a>
<ul class="simple simple-toc-section">
<li><a class="reference" href="#gDebug"
title="gDebug = false"><wbr />g<wbr />Debug<span class="attachedType"></span></a></li>
<li><a class="reference" href="#gDebugCT"
title="gDebugCT = false"><wbr />g<wbr />Debug<wbr />CT<span class="attachedType"></span></a></li>
</ul>
</li>
<li>
<a class="reference reference-toplevel" href="#12" id="62">Procs</a>
<ul class="simple simple-toc-section">
<li><a class="reference" href="#sanitizePath%2Cstring"
title="sanitizePath(path: string; noQuote = false; sep = $'/'): string"><wbr />sanitize<wbr />Path<span class="attachedType"></span></a></li>
<li><a class="reference" href="#getProjectDir"
title="getProjectDir(): string"><wbr />get<wbr />Project<wbr />Dir<span class="attachedType"></span></a></li>
<li><a class="reference" href="#getNimcacheDir%2Cstring"
title="getNimcacheDir(projectDir = ""): string"><wbr />get<wbr />Nimcache<wbr />Dir<span class="attachedType"></span></a></li>
<li><a class="reference" href="#getNimConfig%2Cstring"
title="getNimConfig(projectDir = ""): Config"><wbr />get<wbr />Nim<wbr />Config<span class="attachedType">Config</span></a></li>
<li><a class="reference" href="#getNimConfigFlags%2Cstring"
title="getNimConfigFlags(projectDir = ""): string"><wbr />get<wbr />Nim<wbr />Config<wbr />Flags<span class="attachedType"></span></a></li>
<li><a class="reference" href="#writeNimConfig%2Cstring%2Cstring"
title="writeNimConfig(cfgFile: string; projectDir = "")"><wbr />write<wbr />Nim<wbr />Config<span class="attachedType"></span></a></li>
<li><a class="reference" href="#sleep%2Cint"
title="sleep(milsecs: int)"><wbr />sleep<span class="attachedType"></span></a></li>
<li><a class="reference" href="#getCurrentNimCompiler"
title="getCurrentNimCompiler(): string"><wbr />get<wbr />Current<wbr />Nim<wbr />Compiler<span class="attachedType"></span></a></li>
<li><a class="reference" href="#execAction%2Cstring%2Cint%2Cstring"
title="execAction(cmd: string; retry = 0; die = true; cache = false; cacheKey = ""): tuple[
output: string, ret: int]"><wbr />exec<wbr />Action<span class="attachedType"></span></a></li>
<li><a class="reference" href="#findExe%2Cstring"
title="findExe(exe: string): string"><wbr />find<wbr />Exe<span class="attachedType"></span></a></li>
<li><a class="reference" href="#mkDir%2Cstring"
title="mkDir(dir: string)"><wbr />mk<wbr />Dir<span class="attachedType"></span></a></li>
<li><a class="reference" href="#cpFile%2Cstring%2Cstring"
title="cpFile(source, dest: string; move = false)"><wbr />cp<wbr />File<span class="attachedType"></span></a></li>
<li><a class="reference" href="#mvFile%2Cstring%2Cstring"
title="mvFile(source, dest: string)"><wbr />mv<wbr />File<span class="attachedType"></span></a></li>
<li><a class="reference" href="#rmFile%2Cstring"
title="rmFile(source: string; dir = false)"><wbr />rm<wbr />File<span class="attachedType"></span></a></li>
<li><a class="reference" href="#rmDir%2Cstring"
title="rmDir(dir: string)"><wbr />rm<wbr />Dir<span class="attachedType"></span></a></li>
<li><a class="reference" href="#getProjectCacheDir%2Cstring"
title="getProjectCacheDir(name: string; forceClean = true): string"><wbr />get<wbr />Project<wbr />Cache<wbr />Dir<span class="attachedType"></span></a></li>
<li><a class="reference" href="#extractZip%2Cstring%2Cstring"
title="extractZip(zipfile, outdir: string)"><wbr />extract<wbr />Zip<span class="attachedType"></span></a></li>
<li><a class="reference" href="#extractTar%2Cstring%2Cstring"
title="extractTar(tarfile, outdir: string)"><wbr />extract<wbr />Tar<span class="attachedType"></span></a></li>
<li><a class="reference" href="#downloadUrl%2Cstring%2Cstring"
title="downloadUrl(url, outdir: string)"><wbr />download<wbr />Url<span class="attachedType"></span></a></li>
<li><a class="reference" href="#gitReset%2Cstring"
title="gitReset(outdir: string)"><wbr />git<wbr />Reset<span class="attachedType"></span></a></li>
<li><a class="reference" href="#gitCheckout%2Cstring%2Cstring"
title="gitCheckout(file, outdir: string)"><wbr />git<wbr />Checkout<span class="attachedType"></span></a></li>
<li><a class="reference" href="#gitPull%2Cstring%2Cstring%2Cstring%2Cstring"
title="gitPull(url: string; outdir = ""; plist = ""; checkout = "")"><wbr />git<wbr />Pull<span class="attachedType"></span></a></li>
<li><a class="reference" href="#findFile%2Cstring%2Cstring"
title="findFile(file: string; dir: string; recurse = true; first = false; regex = false): string"><wbr />find<wbr />File<span class="attachedType"></span></a></li>
<li><a class="reference" href="#flagBuild%2Cstring%2CopenArray%5Bstring%5D"
title="flagBuild(base: string; flags: openArray[string]): string"><wbr />flag<wbr />Build<span class="attachedType"></span></a></li>
<li><a class="reference" href="#linkLibs%2CopenArray%5Bstring%5D"
title="linkLibs(names: openArray[string]; staticLink = true): string"><wbr />link<wbr />Libs<span class="attachedType"></span></a></li>
<li><a class="reference" href="#configure%2Cstring%2Cstring%2Cstring"
title="configure(path, check: string; flags = "")"><wbr />configure<span class="attachedType"></span></a></li>
<li><a class="reference" href="#getCmakeIncludePath%2CopenArray%5Bstring%5D"
title="getCmakeIncludePath(paths: openArray[string]): string"><wbr />get<wbr />Cmake<wbr />Include<wbr />Path<span class="attachedType"></span></a></li>
<li><a class="reference" href="#setCmakeProperty%2Cstring%2Cstring%2Cstring%2Cstring"
title="setCmakeProperty(outdir, name, property, value: string)"><wbr />set<wbr />Cmake<wbr />Property<span class="attachedType"></span></a></li>
<li><a class="reference" href="#setCmakeLibName%2Cstring%2Cstring%2Cstring%2Cstring%2Cstring"
title="setCmakeLibName(outdir, name, prefix = ""; oname = ""; suffix = "")"><wbr />set<wbr />Cmake<wbr />Lib<wbr />Name<span class="attachedType"></span></a></li>
<li><a class="reference" href="#setCmakePositionIndependentCode%2Cstring"
title="setCmakePositionIndependentCode(outdir: string)"><wbr />set<wbr />Cmake<wbr />Position<wbr />Independent<wbr />Code<span class="attachedType"></span></a></li>
<li><a class="reference" href="#cmake%2Cstring%2Cstring%2Cstring"
title="cmake(path, check, flags: string)"><wbr />cmake<span class="attachedType"></span></a></li>
<li><a class="reference" href="#make%2Cstring%2Cstring%2Cstring"
title="make(path, check: string; flags = ""; regex = false)"><wbr />make<span class="attachedType"></span></a></li>
<li><a class="reference" href="#getCompilerMode%2Cstring"
title="getCompilerMode(path: string): string"><wbr />get<wbr />Compiler<wbr />Mode<span class="attachedType"></span></a></li>
<li><a class="reference" href="#getGccModeArg%2Cstring"
title="getGccModeArg(mode: string): string"><wbr />get<wbr />Gcc<wbr />Mode<wbr />Arg<span class="attachedType"></span></a></li>
<li><a class="reference" href="#getCompiler"
title="getCompiler(): string"><wbr />get<wbr />Compiler<span class="attachedType"></span></a></li>
<li><a class="reference" href="#getGccPaths%2Cstring"
title="getGccPaths(mode: string): seq[string]"><wbr />get<wbr />Gcc<wbr />Paths<span class="attachedType"></span></a></li>
<li><a class="reference" href="#getGccLibPaths%2Cstring"
title="getGccLibPaths(mode: string): seq[string]"><wbr />get<wbr />Gcc<wbr />Lib<wbr />Paths<span class="attachedType"></span></a></li>
</ul>
</li>
<li>
<a class="reference reference-toplevel" href="#17" id="67">Macros</a>
<ul class="simple simple-toc-section">
<li><a class="reference" href="#setDefines.m"
title="setDefines(defs: static openArray[string]): untyped"><wbr />set<wbr />Defines<span class="attachedType"></span></a></li>
<li><a class="reference" href="#clearDefines.m"
title="clearDefines(): untyped"><wbr />clear<wbr />Defines<span class="attachedType"></span></a></li>
<li><a class="reference" href="#isDefined.m%2Cuntyped"
title="isDefined(def: untyped): untyped"><wbr />is<wbr />Defined<span class="attachedType"></span></a></li>
<li><a class="reference" href="#getHeader.m%2Cstatic%5Bstring%5D%2Cstatic%5Bstring%5D%2Cstatic%5Bstring%5D%2Cstatic%5Bstring%5D%2Cstatic%5Bstring%5D%2Cstatic%5Bstring%5D%2Cstatic%5Bstring%5D%2Cstatic%5Bstring%5D%2Cstatic%5BopenArray%5BBuildType%5D%5D"
title="getHeader(header: static[string]; giturl: static[string] = "";
dlurl: static[string] = ""; outdir: static[string] = "";
conFlags: static[string] = ""; cmakeFlags: static[string] = "";
makeFlags: static[string] = ""; altNames: static[string] = "";
buildTypes: static[openArray[BuildType]] = [btCmake, btAutoconf]): untyped"><wbr />get<wbr />Header<span class="attachedType">BuildType</span></a></li>
</ul>
</li>
</ul>
</div>
<div class="nine columns" id="content">
<div id="tocRoot"></div>
<p class="module-desc"></p>
<div class="section" id="7">
<h1><a class="toc-backref" href="#7">Types</a></h1>
<dl class="item">
<a id="BuildType"></a>
<dt><pre><a href="build.html#BuildType"><span class="Identifier">BuildType</span></a> <span class="Other">=</span> <span class="Keyword">enum</span>
<span class="Identifier">btAutoconf</span><span class="Other">,</span> <span class="Identifier">btCmake</span></pre></dt>
<dd>
</dd>
<a id="Config"></a>
<dt><pre><a href="build.html#Config"><span class="Identifier">Config</span></a> <span class="Other">=</span> <span class="Keyword">ref</span> <span class="Keyword">object</span>
<span class="Identifier">NimMajor</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">int</span>
<span class="Identifier">NimMinor</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">int</span>
<span class="Identifier">NimPatch</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">int</span>
<span class="Identifier">paths</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">OrderedSet</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">]</span>
<span class="Identifier">nimblePaths</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">OrderedSet</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">]</span>
<span class="Identifier">nimcacheDir</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">string</span>
</pre></dt>
<dd>
</dd>
</dl></div>
<div class="section" id="8">
<h1><a class="toc-backref" href="#8">Vars</a></h1>
<dl class="item">
<a id="gDebug"></a>
<dt><pre><a href="build.html#gDebug"><span class="Identifier">gDebug</span></a> <span class="Other">=</span> <span class="Identifier">false</span></pre></dt>
<dd>
</dd>
<a id="gDebugCT"></a>
<dt><pre><a href="build.html#gDebugCT"><span class="Identifier">gDebugCT</span></a> <span class="Other">=</span> <span class="DecNumber">false</span></pre></dt>
<dd>
</dd>
</dl></div>
<div class="section" id="12">
<h1><a class="toc-backref" href="#12">Procs</a></h1>
<dl class="item">
<a id="sanitizePath,string"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#sanitizePath%2Cstring"><span class="Identifier">sanitizePath</span></a><span class="Other">(</span><span class="Identifier">path</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">noQuote</span> <span class="Other">=</span> <span class="Identifier">false</span><span class="Other">;</span> <span class="Identifier">sep</span> <span class="Other">=</span> <span class="Operator">$</span><span class="CharLit">'/'</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
</dd>
<a id="getProjectDir"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#getProjectDir"><span class="Identifier">getProjectDir</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
Get project directory for this compilation - returns <tt class="docutils literal"><span class="pre">""</span></tt> at runtime
</dd>
<a id="getNimcacheDir,string"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#getNimcacheDir%2Cstring"><span class="Identifier">getNimcacheDir</span></a><span class="Other">(</span><span class="Identifier">projectDir</span> <span class="Other">=</span> <span class="StringLit">""</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma">
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">,</span> <span class="Identifier">OSError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">IOError</span><span class="Other">,</span> <span class="Identifier">Defect</span><span class="Other">,</span> <span class="Identifier">KeyError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span>
<span class="Identifier">ExecIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">,</span> <span class="Identifier">RootEffect</span><span class="Other">,</span> <span class="Identifier">WriteIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadEnvEffect</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
Get nimcache directory for current compilation or specified <tt class="docutils literal"><span class="pre">projectDir</span></tt>
</dd>
<a id="getNimConfig,string"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#getNimConfig%2Cstring"><span class="Identifier">getNimConfig</span></a><span class="Other">(</span><span class="Identifier">projectDir</span> <span class="Other">=</span> <span class="StringLit">""</span><span class="Other">)</span><span class="Other">:</span> <a href="build.html#Config"><span class="Identifier">Config</span></a> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">,</span> <span class="Identifier">OSError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">,</span>
<span class="Identifier">IOError</span><span class="Other">,</span> <span class="Identifier">Defect</span><span class="Other">,</span> <span class="Identifier">KeyError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ExecIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">,</span> <span class="Identifier">RootEffect</span><span class="Other">,</span>
<span class="Identifier">WriteIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadEnvEffect</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
</dd>
<a id="getNimConfigFlags,string"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#getNimConfigFlags%2Cstring"><span class="Identifier">getNimConfigFlags</span></a><span class="Other">(</span><span class="Identifier">projectDir</span> <span class="Other">=</span> <span class="StringLit">""</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma">
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">,</span> <span class="Identifier">OSError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">IOError</span><span class="Other">,</span> <span class="Identifier">Defect</span><span class="Other">,</span> <span class="Identifier">KeyError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span>
<span class="Identifier">ExecIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">,</span> <span class="Identifier">RootEffect</span><span class="Other">,</span> <span class="Identifier">WriteIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadEnvEffect</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
<p>Get Nim command line configuration flags for <tt class="docutils literal"><span class="pre">projectDir</span></tt></p>
<p>If <tt class="docutils literal"><span class="pre">projectDir</span></tt> is not specified, it is detected if compile time or current directory is used.</p>
</dd>
<a id="writeNimConfig,string,string"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#writeNimConfig%2Cstring%2Cstring"><span class="Identifier">writeNimConfig</span></a><span class="Other">(</span><span class="Identifier">cfgFile</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">projectDir</span> <span class="Other">=</span> <span class="StringLit">""</span><span class="Other">)</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma">
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">,</span> <span class="Identifier">OSError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">IOError</span><span class="Other">,</span> <span class="Identifier">Defect</span><span class="Other">,</span> <span class="Identifier">KeyError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span>
<span class="Identifier">ExecIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">,</span> <span class="Identifier">RootEffect</span><span class="Other">,</span> <span class="Identifier">WriteIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadEnvEffect</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
<p>Write Nim configuration for <tt class="docutils literal"><span class="pre">projectDir</span></tt> to specified <tt class="docutils literal"><span class="pre">cfgFile</span></tt></p>
<p>If <tt class="docutils literal"><span class="pre">projectDir</span></tt> is not specified, it is detected if compile time or current directory is used.</p>
</dd>
<a id="sleep,int"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#sleep%2Cint"><span class="Identifier">sleep</span></a><span class="Other">(</span><span class="Identifier">milsecs</span><span class="Other">:</span> <span class="Identifier">int</span><span class="Other">)</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
Sleep at compile time
</dd>
<a id="getCurrentNimCompiler"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#getCurrentNimCompiler"><span class="Identifier">getCurrentNimCompiler</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
</dd>
<a id="execAction,string,int,string"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#execAction%2Cstring%2Cint%2Cstring"><span class="Identifier">execAction</span></a><span class="Other">(</span><span class="Identifier">cmd</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">retry</span> <span class="Other">=</span> <span class="DecNumber">0</span><span class="Other">;</span> <span class="Identifier">die</span> <span class="Other">=</span> <span class="Identifier">true</span><span class="Other">;</span> <span class="Identifier">cache</span> <span class="Other">=</span> <span class="Identifier">false</span><span class="Other">;</span> <span class="Identifier">cacheKey</span> <span class="Other">=</span> <span class="StringLit">""</span><span class="Other">)</span><span class="Other">:</span> <span class="Keyword">tuple</span><span class="Other">[</span>
<span class="Identifier">output</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">,</span> <span class="Identifier">ret</span><span class="Other">:</span> <span class="Identifier">int</span><span class="Other">]</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">,</span> <span class="Identifier">OSError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">IOError</span><span class="Other">,</span> <span class="Identifier">Defect</span><span class="Other">,</span>
<span class="Identifier">KeyError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ExecIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">,</span>
<span class="Identifier">RootEffect</span><span class="Other">,</span> <span class="Identifier">WriteIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadEnvEffect</span><span class="Other">,</span> <span class="Identifier">ReadDirEffect</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
<p>Execute an external command - supported at compile time</p>
<p>Checks if command exits successfully before returning. If not, an error is raised. Always caches results to be used in nimsuggest or nimcheck mode.</p>
<p><tt class="docutils literal"><span class="pre">retry</span></tt> - number of times command should be retried before error <tt class="docutils literal"><span class="pre">die = false</span></tt> - return on errors <tt class="docutils literal"><span class="pre">cache = true</span></tt> - cache results unless cleared with -f <tt class="docutils literal"><span class="pre">cacheKey</span></tt> - key to create unique cache entry</p>
</dd>
<a id="findExe,string"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#findExe%2Cstring"><span class="Identifier">findExe</span></a><span class="Other">(</span><span class="Identifier">exe</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">,</span> <span class="Identifier">OSError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">IOError</span><span class="Other">,</span>
<span class="Identifier">Defect</span><span class="Other">,</span> <span class="Identifier">KeyError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ExecIOEffect</span><span class="Other">,</span>
<span class="Identifier">ReadIOEffect</span><span class="Other">,</span> <span class="Identifier">RootEffect</span><span class="Other">,</span> <span class="Identifier">WriteIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadEnvEffect</span><span class="Other">,</span> <span class="Identifier">ReadDirEffect</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
Find the specified executable using the <tt class="docutils literal"><span class="pre">which</span></tt>/<tt class="docutils literal"><span class="pre">where</span></tt> command - supported at compile time
</dd>
<a id="mkDir,string"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#mkDir%2Cstring"><span class="Identifier">mkDir</span></a><span class="Other">(</span><span class="Identifier">dir</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">,</span> <span class="Identifier">OSError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">IOError</span><span class="Other">,</span> <span class="Identifier">Defect</span><span class="Other">,</span>
<span class="Identifier">KeyError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadDirEffect</span><span class="Other">,</span> <span class="Identifier">ExecIOEffect</span><span class="Other">,</span>
<span class="Identifier">ReadIOEffect</span><span class="Other">,</span> <span class="Identifier">RootEffect</span><span class="Other">,</span> <span class="Identifier">WriteIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadEnvEffect</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
<p>Create a directory at compile time</p>
<p>The <tt class="docutils literal"><span class="pre">os</span></tt> module is not available at compile time so a few crucial helper functions are included with nimterop.</p>
</dd>
<a id="cpFile,string,string"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#cpFile%2Cstring%2Cstring"><span class="Identifier">cpFile</span></a><span class="Other">(</span><span class="Identifier">source</span><span class="Other">,</span> <span class="Identifier">dest</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">move</span> <span class="Other">=</span> <span class="Identifier">false</span><span class="Other">)</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma">
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">,</span> <span class="Identifier">OSError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">IOError</span><span class="Other">,</span> <span class="Identifier">Defect</span><span class="Other">,</span> <span class="Identifier">KeyError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span>
<span class="Identifier">ExecIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">,</span> <span class="Identifier">RootEffect</span><span class="Other">,</span> <span class="Identifier">WriteIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadEnvEffect</span><span class="Other">,</span>
<span class="Identifier">ReadDirEffect</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
Copy a file from <tt class="docutils literal"><span class="pre">source</span></tt> to <tt class="docutils literal"><span class="pre">dest</span></tt> at compile time
</dd>
<a id="mvFile,string,string"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#mvFile%2Cstring%2Cstring"><span class="Identifier">mvFile</span></a><span class="Other">(</span><span class="Identifier">source</span><span class="Other">,</span> <span class="Identifier">dest</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">,</span> <span class="Identifier">OSError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">IOError</span><span class="Other">,</span>
<span class="Identifier">Defect</span><span class="Other">,</span> <span class="Identifier">KeyError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ExecIOEffect</span><span class="Other">,</span>
<span class="Identifier">ReadIOEffect</span><span class="Other">,</span> <span class="Identifier">RootEffect</span><span class="Other">,</span> <span class="Identifier">WriteIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadEnvEffect</span><span class="Other">,</span> <span class="Identifier">ReadDirEffect</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
Move a file from <tt class="docutils literal"><span class="pre">source</span></tt> to <tt class="docutils literal"><span class="pre">dest</span></tt> at compile time
</dd>
<a id="rmFile,string"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#rmFile%2Cstring"><span class="Identifier">rmFile</span></a><span class="Other">(</span><span class="Identifier">source</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">dir</span> <span class="Other">=</span> <span class="Identifier">false</span><span class="Other">)</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">,</span> <span class="Identifier">OSError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">,</span>
<span class="Identifier">IOError</span><span class="Other">,</span> <span class="Identifier">Defect</span><span class="Other">,</span> <span class="Identifier">KeyError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadDirEffect</span><span class="Other">,</span> <span class="Identifier">ExecIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">,</span>
<span class="Identifier">RootEffect</span><span class="Other">,</span> <span class="Identifier">WriteIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadEnvEffect</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
Remove a file or pattern at compile time
</dd>
<a id="rmDir,string"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#rmDir%2Cstring"><span class="Identifier">rmDir</span></a><span class="Other">(</span><span class="Identifier">dir</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">,</span> <span class="Identifier">OSError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">IOError</span><span class="Other">,</span> <span class="Identifier">Defect</span><span class="Other">,</span>
<span class="Identifier">KeyError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadDirEffect</span><span class="Other">,</span> <span class="Identifier">ExecIOEffect</span><span class="Other">,</span>
<span class="Identifier">ReadIOEffect</span><span class="Other">,</span> <span class="Identifier">RootEffect</span><span class="Other">,</span> <span class="Identifier">WriteIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadEnvEffect</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
Remove a directory or pattern at compile time
</dd>
<a id="getProjectCacheDir,string"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#getProjectCacheDir%2Cstring"><span class="Identifier">getProjectCacheDir</span></a><span class="Other">(</span><span class="Identifier">name</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">forceClean</span> <span class="Other">=</span> <span class="Identifier">true</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma">
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">,</span> <span class="Identifier">OSError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">IOError</span><span class="Other">,</span> <span class="Identifier">Defect</span><span class="Other">,</span> <span class="Identifier">KeyError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span>
<span class="Identifier">ExecIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">,</span> <span class="Identifier">RootEffect</span><span class="Other">,</span> <span class="Identifier">WriteIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadEnvEffect</span><span class="Other">,</span>
<span class="Identifier">ReadDirEffect</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
<p>Get a cache directory where all nimterop artifacts can be stored</p>
<p>Projects can use this location to download source code and build binaries that can be then accessed by multiple apps. This is created under the per-user Nim cache directory.</p>
<p>Use <tt class="docutils literal"><span class="pre">name</span></tt> to specify the subdirectory name for a project.</p>
<p><tt class="docutils literal"><span class="pre">forceClean</span></tt> is enabled by default and effectively deletes the folder if Nim is compiled with the <tt class="docutils literal"><span class="pre">-f</span></tt> or <tt class="docutils literal"><span class="pre">--forceBuild</span></tt> flag. This allows any project to start out with a clean cache dir on a forced build.</p>
<p>NOTE: avoid calling <tt class="docutils literal"><span class="pre">getProjectCacheDir()</span></tt> multiple times on the same <tt class="docutils literal"><span class="pre">name</span></tt> when <tt class="docutils literal"><span class="pre">forceClean = true</span></tt> else checked out source might get deleted at the wrong time during build.</p>
<dl class="docutils"><dt>E.g.</dt>
<dd><p><tt class="docutils literal"><span class="pre">nimgit2</span></tt> downloads <tt class="docutils literal"><span class="pre">libgit2</span></tt> source so <tt class="docutils literal"><span class="pre">name = "libgit2"</span></tt></p>
<p><tt class="docutils literal"><span class="pre">nimarchive</span></tt> downloads <tt class="docutils literal"><span class="pre">libarchive</span></tt>, <tt class="docutils literal"><span class="pre">bzlib</span></tt>, <tt class="docutils literal"><span class="pre">liblzma</span></tt> and <tt class="docutils literal"><span class="pre">zlib</span></tt> so <tt class="docutils literal"><span class="pre">name = "nimarchive" / "libarchive"</span></tt> for <tt class="docutils literal"><span class="pre">libarchive</span></tt>, etc.</p>
</dd>
</dl>
</dd>
<a id="extractZip,string,string"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#extractZip%2Cstring%2Cstring"><span class="Identifier">extractZip</span></a><span class="Other">(</span><span class="Identifier">zipfile</span><span class="Other">,</span> <span class="Identifier">outdir</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">,</span> <span class="Identifier">OSError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">,</span>
<span class="Identifier">IOError</span><span class="Other">,</span> <span class="Identifier">Defect</span><span class="Other">,</span> <span class="Identifier">KeyError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ExecIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">,</span> <span class="Identifier">RootEffect</span><span class="Other">,</span>
<span class="Identifier">WriteIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadEnvEffect</span><span class="Other">,</span> <span class="Identifier">ReadDirEffect</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
Extract a zip file using <tt class="docutils literal"><span class="pre">powershell</span></tt> on Windows and <tt class="docutils literal"><span class="pre">unzip</span></tt> on other systems to the specified output directory
</dd>
<a id="extractTar,string,string"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#extractTar%2Cstring%2Cstring"><span class="Identifier">extractTar</span></a><span class="Other">(</span><span class="Identifier">tarfile</span><span class="Other">,</span> <span class="Identifier">outdir</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">,</span> <span class="Identifier">OSError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">,</span>
<span class="Identifier">IOError</span><span class="Other">,</span> <span class="Identifier">Defect</span><span class="Other">,</span> <span class="Identifier">KeyError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ExecIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">,</span> <span class="Identifier">RootEffect</span><span class="Other">,</span>
<span class="Identifier">WriteIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadEnvEffect</span><span class="Other">,</span> <span class="Identifier">ReadDirEffect</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
Extract a tar file using <tt class="docutils literal"><span class="pre">tar</span></tt>, <tt class="docutils literal"><span class="pre">7z</span></tt> or <tt class="docutils literal"><span class="pre">7za</span></tt> to the specified output directory
</dd>
<a id="downloadUrl,string,string"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#downloadUrl%2Cstring%2Cstring"><span class="Identifier">downloadUrl</span></a><span class="Other">(</span><span class="Identifier">url</span><span class="Other">,</span> <span class="Identifier">outdir</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">,</span> <span class="Identifier">OSError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">,</span>
<span class="Identifier">IOError</span><span class="Other">,</span> <span class="Identifier">Defect</span><span class="Other">,</span> <span class="Identifier">KeyError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadDirEffect</span><span class="Other">,</span> <span class="Identifier">ExecIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">,</span>
<span class="Identifier">RootEffect</span><span class="Other">,</span> <span class="Identifier">WriteIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadEnvEffect</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
<p>Download a file using <tt class="docutils literal"><span class="pre">curl</span></tt> or <tt class="docutils literal"><span class="pre">wget</span></tt> (or <tt class="docutils literal"><span class="pre">powershell</span></tt> on Windows) to the specified directory</p>
<p>If an archive file, it is automatically extracted after download.</p>
</dd>
<a id="gitReset,string"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#gitReset%2Cstring"><span class="Identifier">gitReset</span></a><span class="Other">(</span><span class="Identifier">outdir</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">,</span> <span class="Identifier">OSError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">IOError</span><span class="Other">,</span>
<span class="Identifier">Defect</span><span class="Other">,</span> <span class="Identifier">KeyError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ExecIOEffect</span><span class="Other">,</span>
<span class="Identifier">ReadIOEffect</span><span class="Other">,</span> <span class="Identifier">RootEffect</span><span class="Other">,</span> <span class="Identifier">WriteIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadEnvEffect</span><span class="Other">,</span> <span class="Identifier">ReadDirEffect</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
Hard reset the git repository at the specified directory
</dd>
<a id="gitCheckout,string,string"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#gitCheckout%2Cstring%2Cstring"><span class="Identifier">gitCheckout</span></a><span class="Other">(</span><span class="Identifier">file</span><span class="Other">,</span> <span class="Identifier">outdir</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">ValueError</span><span class="Other">,</span> <span class="Identifier">OSError</span><span class="Other">,</span>
<span class="Identifier">IOError</span><span class="Other">,</span> <span class="Identifier">Defect</span><span class="Other">,</span> <span class="Identifier">KeyError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">,</span> <span class="Identifier">ExecIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">,</span>
<span class="Identifier">WriteIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadEnvEffect</span><span class="Other">,</span> <span class="Identifier">ReadDirEffect</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
<p>Checkout the specified <tt class="docutils literal"><span class="pre">file</span></tt> in the git repository at <tt class="docutils literal"><span class="pre">outdir</span></tt></p>
<p>This effectively resets all changes in the file and can be used to undo any changes that were made to source files to enable successful wrapping with <tt class="docutils literal"><span class="pre">cImport()</span></tt> or <tt class="docutils literal"><span class="pre">c2nImport()</span></tt>.</p>
</dd>
<a id="gitPull,string,string,string,string"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#gitPull%2Cstring%2Cstring%2Cstring%2Cstring"><span class="Identifier">gitPull</span></a><span class="Other">(</span><span class="Identifier">url</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">outdir</span> <span class="Other">=</span> <span class="StringLit">""</span><span class="Other">;</span> <span class="Identifier">plist</span> <span class="Other">=</span> <span class="StringLit">""</span><span class="Other">;</span> <span class="Identifier">checkout</span> <span class="Other">=</span> <span class="StringLit">""</span><span class="Other">)</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma">
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">,</span> <span class="Identifier">OSError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">IOError</span><span class="Other">,</span> <span class="Identifier">Defect</span><span class="Other">,</span> <span class="Identifier">KeyError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span>
<span class="Identifier">ReadDirEffect</span><span class="Other">,</span> <span class="Identifier">ExecIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">,</span> <span class="Identifier">RootEffect</span><span class="Other">,</span> <span class="Identifier">WriteIOEffect</span><span class="Other">,</span>
<span class="Identifier">ReadEnvEffect</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
<p>Pull the specified git repository to the output directory</p>
<p><tt class="docutils literal"><span class="pre">plist</span></tt> is the list of specific files and directories or wildcards to sparsely checkout. Multiple values can be specified one entry per line. It is optional and if omitted, the entire repository will be checked out.</p>
<p><tt class="docutils literal"><span class="pre">checkout</span></tt> is the git tag, branch or commit hash to checkout once the repository is downloaded. This allows for pinning to a specific version of the code.</p>
</dd>
<a id="findFile,string,string"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#findFile%2Cstring%2Cstring"><span class="Identifier">findFile</span></a><span class="Other">(</span><span class="Identifier">file</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">dir</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">recurse</span> <span class="Other">=</span> <span class="Identifier">true</span><span class="Other">;</span> <span class="Identifier">first</span> <span class="Other">=</span> <span class="Identifier">false</span><span class="Other">;</span> <span class="Identifier">regex</span> <span class="Other">=</span> <span class="Identifier">false</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma">
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">,</span> <span class="Identifier">OSError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">IOError</span><span class="Other">,</span> <span class="Identifier">Defect</span><span class="Other">,</span> <span class="Identifier">KeyError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span>
<span class="Identifier">ExecIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">,</span> <span class="Identifier">RootEffect</span><span class="Other">,</span> <span class="Identifier">WriteIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadEnvEffect</span><span class="Other">,</span>
<span class="Identifier">ReadDirEffect</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
<p>Find the file in the specified directory</p>
<p><tt class="docutils literal"><span class="pre">file</span></tt> is a regular expression if <tt class="docutils literal"><span class="pre">regex</span></tt> is true</p>
<p>Turn off recursive search with <tt class="docutils literal"><span class="pre">recurse</span></tt> and stop on first match with <tt class="docutils literal"><span class="pre">first</span></tt>. Without it, the shortest match is returned.</p>
</dd>
<a id="flagBuild,string,openArray[string]"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#flagBuild%2Cstring%2CopenArray%5Bstring%5D"><span class="Identifier">flagBuild</span></a><span class="Other">(</span><span class="Identifier">base</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">flags</span><span class="Other">:</span> <span class="Identifier">openArray</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
<p>Simple helper proc to generate flags for <tt class="docutils literal"><span class="pre">configure</span></tt>, <tt class="docutils literal"><span class="pre">cmake</span></tt>, etc.</p>
<p>Every entry in <tt class="docutils literal"><span class="pre">flags</span></tt> is replaced into the <tt class="docutils literal"><span class="pre">base</span></tt> string and concatenated to the result.</p>
<dl class="docutils"><dt>E.g.</dt>
<dd><tt class="docutils literal"><span class="pre">base = "--disable-$#"</span></tt> <tt class="docutils literal"><span class="pre">flags = @["one", "two"]</span></tt></dd>
</dl>
<p><tt class="docutils literal"><span class="pre">flagBuild(base, flags) => " --disable-one --disable-two"</span></tt></p>
</dd>
<a id="linkLibs,openArray[string]"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#linkLibs%2CopenArray%5Bstring%5D"><span class="Identifier">linkLibs</span></a><span class="Other">(</span><span class="Identifier">names</span><span class="Other">:</span> <span class="Identifier">openArray</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">staticLink</span> <span class="Other">=</span> <span class="Identifier">true</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma">
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">,</span> <span class="Identifier">OSError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">IOError</span><span class="Other">,</span> <span class="Identifier">Defect</span><span class="Other">,</span> <span class="Identifier">KeyError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span>
<span class="Identifier">ExecIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">,</span> <span class="Identifier">RootEffect</span><span class="Other">,</span> <span class="Identifier">WriteIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadEnvEffect</span><span class="Other">,</span>
<span class="Identifier">ReadDirEffect</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
<p>Create linker flags for specified libraries</p>
<p>Prepends <tt class="docutils literal"><span class="pre">lib</span></tt> to the name so you only need <tt class="docutils literal"><span class="pre">ssl</span></tt> for <tt class="docutils literal"><span class="pre">libssl</span></tt>.</p>
</dd>
<a id="configure,string,string,string"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#configure%2Cstring%2Cstring%2Cstring"><span class="Identifier">configure</span></a><span class="Other">(</span><span class="Identifier">path</span><span class="Other">,</span> <span class="Identifier">check</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">flags</span> <span class="Other">=</span> <span class="StringLit">""</span><span class="Other">)</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma">
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">,</span> <span class="Identifier">OSError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">IOError</span><span class="Other">,</span> <span class="Identifier">Defect</span><span class="Other">,</span> <span class="Identifier">KeyError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span>
<span class="Identifier">ReadDirEffect</span><span class="Other">,</span> <span class="Identifier">ExecIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">,</span> <span class="Identifier">RootEffect</span><span class="Other">,</span> <span class="Identifier">WriteIOEffect</span><span class="Other">,</span>
<span class="Identifier">ReadEnvEffect</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
<p>Run the GNU <tt class="docutils literal"><span class="pre">configure</span></tt> command to generate all Makefiles or other build scripts in the specified path</p>
<p>If a <tt class="docutils literal"><span class="pre">configure</span></tt> script is not present and an <tt class="docutils literal"><span class="pre">autogen.sh</span></tt> script is present, it will be run before attempting <tt class="docutils literal"><span class="pre">configure</span></tt>.</p>
<p>Next, if <tt class="docutils literal"><span class="pre">configure.ac</span></tt> or <tt class="docutils literal"><span class="pre">configure.in</span></tt> exist, <tt class="docutils literal"><span class="pre">autoreconf</span></tt> will be executed.</p>
<p><tt class="docutils literal"><span class="pre">check</span></tt> is a file that will be generated by the <tt class="docutils literal"><span class="pre">configure</span></tt> command. This is required to prevent configure from running on every build. It is relative to the <tt class="docutils literal"><span class="pre">path</span></tt> and should not be an absolute path.</p>
<p><tt class="docutils literal"><span class="pre">flags</span></tt> are any flags that should be passed to the <tt class="docutils literal"><span class="pre">configure</span></tt> command.</p>
</dd>
<a id="getCmakeIncludePath,openArray[string]"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#getCmakeIncludePath%2CopenArray%5Bstring%5D"><span class="Identifier">getCmakeIncludePath</span></a><span class="Other">(</span><span class="Identifier">paths</span><span class="Other">:</span> <span class="Identifier">openArray</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
<p>Create a <tt class="docutils literal"><span class="pre">cmake</span></tt> flag to specify custom include paths</p>
<p>Result can be included in the <tt class="docutils literal"><span class="pre">flag</span></tt> parameter for <tt class="docutils literal"><span class="pre">cmake()</span></tt> or the <tt class="docutils literal"><span class="pre">cmakeFlags</span></tt> parameter for <tt class="docutils literal"><span class="pre">getHeader()</span></tt>.</p>
</dd>
<a id="setCmakeProperty,string,string,string,string"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#setCmakeProperty%2Cstring%2Cstring%2Cstring%2Cstring"><span class="Identifier">setCmakeProperty</span></a><span class="Other">(</span><span class="Identifier">outdir</span><span class="Other">,</span> <span class="Identifier">name</span><span class="Other">,</span> <span class="Identifier">property</span><span class="Other">,</span> <span class="Identifier">value</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma">
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">IOError</span><span class="Other">,</span> <span class="Identifier">ValueError</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadDirEffect</span><span class="Other">,</span> <span class="Identifier">WriteIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
<p>Set a <tt class="docutils literal"><span class="pre">cmake</span></tt> property in <tt class="docutils literal"><span class="pre">outdir / CMakeLists.txt</span></tt> - usable in the <tt class="docutils literal"><span class="pre">xxxPreBuild</span></tt> hook for <tt class="docutils literal"><span class="pre">getHeader()</span></tt></p>
<p><tt class="docutils literal"><span class="pre">set_target_properties(name PROPERTIES property "value")</span></tt></p>
</dd>
<a id="setCmakeLibName,string,string,string,string,string"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#setCmakeLibName%2Cstring%2Cstring%2Cstring%2Cstring%2Cstring"><span class="Identifier">setCmakeLibName</span></a><span class="Other">(</span><span class="Identifier">outdir</span><span class="Other">,</span> <span class="Identifier">name</span><span class="Other">,</span> <span class="Identifier">prefix</span> <span class="Other">=</span> <span class="StringLit">""</span><span class="Other">;</span> <span class="Identifier">oname</span> <span class="Other">=</span> <span class="StringLit">""</span><span class="Other">;</span> <span class="Identifier">suffix</span> <span class="Other">=</span> <span class="StringLit">""</span><span class="Other">)</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma">
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">,</span> <span class="Identifier">IOError</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadDirEffect</span><span class="Other">,</span> <span class="Identifier">WriteIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
<p>Set a <tt class="docutils literal"><span class="pre">cmake</span></tt> property in <tt class="docutils literal"><span class="pre">outdir / CMakeLists.txt</span></tt> to specify a custom library output name - usable in the <tt class="docutils literal"><span class="pre">xxxPreBuild</span></tt> hook for <tt class="docutils literal"><span class="pre">getHeader()</span></tt></p>
<p><tt class="docutils literal"><span class="pre">prefix</span></tt> is typically <tt class="docutils literal"><span class="pre">lib</span></tt> <tt class="docutils literal"><span class="pre">oname</span></tt> is the library name <tt class="docutils literal"><span class="pre">suffix</span></tt> is typically <tt class="docutils literal"><span class="pre">.a</span></tt></p>
<p>Sometimes, <tt class="docutils literal"><span class="pre">cmake</span></tt> generates non-standard library names - e.g. zlib compiles to <tt class="docutils literal"><span class="pre">libzlibstatic.a</span></tt> on Windows. This proc can help rename it to <tt class="docutils literal"><span class="pre">libzlib.a</span></tt> so that <tt class="docutils literal"><span class="pre">getHeader()</span></tt> can find it after the library is compiled.</p>
<p><pre class="listing">
set_target_properties(name PROPERTIES PREFIX "prefix")
set_target_properties(name PROPERTIES OUTPUT_NAME "oname")
set_target_properties(name PROPERTIES SUFFIX "suffix")
</pre></p>
</dd>
<a id="setCmakePositionIndependentCode,string"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#setCmakePositionIndependentCode%2Cstring"><span class="Identifier">setCmakePositionIndependentCode</span></a><span class="Other">(</span><span class="Identifier">outdir</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">IOError</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadDirEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">,</span> <span class="Identifier">WriteIOEffect</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
Set a <tt class="docutils literal"><span class="pre">cmake</span></tt> directive to create libraries with -fPIC enabled
</dd>
<a id="cmake,string,string,string"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#cmake%2Cstring%2Cstring%2Cstring"><span class="Identifier">cmake</span></a><span class="Other">(</span><span class="Identifier">path</span><span class="Other">,</span> <span class="Identifier">check</span><span class="Other">,</span> <span class="Identifier">flags</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">,</span> <span class="Identifier">OSError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">,</span>
<span class="Identifier">IOError</span><span class="Other">,</span> <span class="Identifier">Defect</span><span class="Other">,</span> <span class="Identifier">KeyError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadDirEffect</span><span class="Other">,</span> <span class="Identifier">ExecIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">,</span>
<span class="Identifier">RootEffect</span><span class="Other">,</span> <span class="Identifier">WriteIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadEnvEffect</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
<p>Run the <tt class="docutils literal"><span class="pre">cmake</span></tt> command to generate all Makefiles or other build scripts in the specified path</p>
<p><tt class="docutils literal"><span class="pre">path</span></tt> will be created since typically <tt class="docutils literal"><span class="pre">cmake</span></tt> is run in an empty directory.</p>
<p><tt class="docutils literal"><span class="pre">check</span></tt> is a file that will be generated by the <tt class="docutils literal"><span class="pre">cmake</span></tt> command. This is required to prevent <tt class="docutils literal"><span class="pre">cmake</span></tt> from running on every build. It is relative to the <tt class="docutils literal"><span class="pre">path</span></tt> and should not be an absolute path.</p>
<p><tt class="docutils literal"><span class="pre">flags</span></tt> are any flags that should be passed to the <tt class="docutils literal"><span class="pre">cmake</span></tt> command. Unlike <tt class="docutils literal"><span class="pre">configure</span></tt>, it is required since typically it will be the path to the repository, typically <tt class="docutils literal"><span class="pre">..</span></tt> when <tt class="docutils literal"><span class="pre">path</span></tt> is a subdir.</p>
</dd>
<a id="make,string,string,string"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#make%2Cstring%2Cstring%2Cstring"><span class="Identifier">make</span></a><span class="Other">(</span><span class="Identifier">path</span><span class="Other">,</span> <span class="Identifier">check</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">flags</span> <span class="Other">=</span> <span class="StringLit">""</span><span class="Other">;</span> <span class="Identifier">regex</span> <span class="Other">=</span> <span class="Identifier">false</span><span class="Other">)</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma">
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">,</span> <span class="Identifier">OSError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">IOError</span><span class="Other">,</span> <span class="Identifier">Defect</span><span class="Other">,</span> <span class="Identifier">KeyError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span>
<span class="Identifier">ExecIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">,</span> <span class="Identifier">RootEffect</span><span class="Other">,</span> <span class="Identifier">WriteIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadEnvEffect</span><span class="Other">,</span>
<span class="Identifier">ReadDirEffect</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
<p>Run the <tt class="docutils literal"><span class="pre">make</span></tt> command to build all binaries in the specified path</p>
<p><tt class="docutils literal"><span class="pre">check</span></tt> is a file that will be generated by the <tt class="docutils literal"><span class="pre">make</span></tt> command. This is required to prevent <tt class="docutils literal"><span class="pre">make</span></tt> from running on every build. It is relative to the <tt class="docutils literal"><span class="pre">path</span></tt> and should not be an absolute path.</p>
<p><tt class="docutils literal"><span class="pre">flags</span></tt> are any flags that should be passed to the <tt class="docutils literal"><span class="pre">make</span></tt> command.</p>
<p><tt class="docutils literal"><span class="pre">regex</span></tt> can be set to true if <tt class="docutils literal"><span class="pre">check</span></tt> is a regular expression.</p>
<p>If <tt class="docutils literal"><span class="pre">make.exe</span></tt> is missing and <tt class="docutils literal"><span class="pre">mingw32-make.exe</span></tt> is available, it will be copied over to make.exe in the same location.</p>
</dd>
<a id="getCompilerMode,string"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#getCompilerMode%2Cstring"><span class="Identifier">getCompilerMode</span></a><span class="Other">(</span><span class="Identifier">path</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
Determines a target language mode from an input filename, if one is not already specified.
</dd>
<a id="getGccModeArg,string"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#getGccModeArg%2Cstring"><span class="Identifier">getGccModeArg</span></a><span class="Other">(</span><span class="Identifier">mode</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
Produces a GCC argument that explicitly sets the language mode to be used by the compiler.
</dd>
<a id="getCompiler"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#getCompiler"><span class="Identifier">getCompiler</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
</dd>
<a id="getGccPaths,string"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#getGccPaths%2Cstring"><span class="Identifier">getGccPaths</span></a><span class="Other">(</span><span class="Identifier">mode</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">]</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma">
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">,</span> <span class="Identifier">OSError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">IOError</span><span class="Other">,</span> <span class="Identifier">Defect</span><span class="Other">,</span> <span class="Identifier">KeyError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span>
<span class="Identifier">ExecIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">,</span> <span class="Identifier">RootEffect</span><span class="Other">,</span> <span class="Identifier">WriteIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadEnvEffect</span><span class="Other">,</span>
<span class="Identifier">ReadDirEffect</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
</dd>
<a id="getGccLibPaths,string"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#getGccLibPaths%2Cstring"><span class="Identifier">getGccLibPaths</span></a><span class="Other">(</span><span class="Identifier">mode</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">]</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma">
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">,</span> <span class="Identifier">OSError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">IOError</span><span class="Other">,</span> <span class="Identifier">Defect</span><span class="Other">,</span> <span class="Identifier">KeyError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span>
<span class="Identifier">ExecIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">,</span> <span class="Identifier">RootEffect</span><span class="Other">,</span> <span class="Identifier">WriteIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadEnvEffect</span><span class="Other">,</span>
<span class="Identifier">ReadDirEffect</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
</dd>
</dl></div>
<div class="section" id="17">
<h1><a class="toc-backref" href="#17">Macros</a></h1>
<dl class="item">
<a id="setDefines.m"></a>
<dt><pre><span class="Keyword">macro</span> <a href="#setDefines.m"><span class="Identifier">setDefines</span></a><span class="Other">(</span><span class="Identifier">defs</span><span class="Other">:</span> <span class="Identifier">static</span> <span class="Identifier">openArray</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">untyped</span></pre></dt>
<dd>
<p>Specify <tt class="docutils literal"><span class="pre">-d:xxx</span></tt> values in code instead of having to rely on the command line or <tt class="docutils literal"><span class="pre">cfg</span></tt> or <tt class="docutils literal"><span class="pre">nims</span></tt> files.</p>
<p>At this time, Nim does not allow creation of <tt class="docutils literal"><span class="pre">-d:xxx</span></tt> defines in code. In addition, Nim only loads config files for the module being compiled but not for imported packages. This becomes a challenge when wanting to ship a wrapper library that wants to control <tt class="docutils literal"><span class="pre">getHeader()</span></tt> for an underlying package.</p>
<blockquote><p>E.g. nimarchive wanting to set <tt class="docutils literal"><span class="pre">-d:lzmaStatic</span></tt></p></blockquote>
<p>The consumer of nimarchive would need to set such defines as part of their project, making it inconvenient.</p>
<p>By calling this proc with the defines preferred before importing such a module, the caller can set the behavior in code instead.</p>
<pre class="listing"><span class="Identifier">setDefines</span><span class="Punctuation">(</span><span class="Operator">@</span><span class="Punctuation">[</span><span class="StringLit">"lzmaStatic"</span><span class="Punctuation">,</span> <span class="StringLit">"lzmaDL"</span><span class="Punctuation">,</span> <span class="StringLit">"lzmaSetVer=5.2.4"</span><span class="Punctuation">]</span><span class="Punctuation">)</span>
<span class="Keyword">import</span> <span class="Identifier">lzma</span></pre>
</dd>
<a id="clearDefines.m"></a>
<dt><pre><span class="Keyword">macro</span> <a href="#clearDefines.m"><span class="Identifier">clearDefines</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">untyped</span></pre></dt>
<dd>
Clear all defines set using <tt class="docutils literal"><span class="pre">setDefines()</span></tt>.
</dd>
<a id="isDefined.m,untyped"></a>
<dt><pre><span class="Keyword">macro</span> <a href="#isDefined.m%2Cuntyped"><span class="Identifier">isDefined</span></a><span class="Other">(</span><span class="Identifier">def</span><span class="Other">:</span> <span class="Identifier">untyped</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">untyped</span></pre></dt>
<dd>
Check if <tt class="docutils literal"><span class="pre">-d:xxx</span></tt> is set globally or via <tt class="docutils literal"><span class="pre">setDefines()</span></tt>
</dd>
<a id="getHeader.m,static[string],static[string],static[string],static[string],static[string],static[string],static[string],static[string],static[openArray[BuildType]]"></a>
<dt><pre><span class="Keyword">macro</span> <a href="#getHeader.m%2Cstatic%5Bstring%5D%2Cstatic%5Bstring%5D%2Cstatic%5Bstring%5D%2Cstatic%5Bstring%5D%2Cstatic%5Bstring%5D%2Cstatic%5Bstring%5D%2Cstatic%5Bstring%5D%2Cstatic%5Bstring%5D%2Cstatic%5BopenArray%5BBuildType%5D%5D"><span class="Identifier">getHeader</span></a><span class="Other">(</span><span class="Identifier">header</span><span class="Other">:</span> <span class="Identifier">static</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">giturl</span><span class="Other">:</span> <span class="Identifier">static</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">]</span> <span class="Other">=</span> <span class="StringLit">""</span><span class="Other">;</span>
<span class="Identifier">dlurl</span><span class="Other">:</span> <span class="Identifier">static</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">]</span> <span class="Other">=</span> <span class="StringLit">""</span><span class="Other">;</span> <span class="Identifier">outdir</span><span class="Other">:</span> <span class="Identifier">static</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">]</span> <span class="Other">=</span> <span class="StringLit">""</span><span class="Other">;</span>
<span class="Identifier">conFlags</span><span class="Other">:</span> <span class="Identifier">static</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">]</span> <span class="Other">=</span> <span class="StringLit">""</span><span class="Other">;</span> <span class="Identifier">cmakeFlags</span><span class="Other">:</span> <span class="Identifier">static</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">]</span> <span class="Other">=</span> <span class="StringLit">""</span><span class="Other">;</span>
<span class="Identifier">makeFlags</span><span class="Other">:</span> <span class="Identifier">static</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">]</span> <span class="Other">=</span> <span class="StringLit">""</span><span class="Other">;</span> <span class="Identifier">altNames</span><span class="Other">:</span> <span class="Identifier">static</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">]</span> <span class="Other">=</span> <span class="StringLit">""</span><span class="Other">;</span>
<span class="Identifier">buildTypes</span><span class="Other">:</span> <span class="Identifier">static</span><span class="Other">[</span><span class="Identifier">openArray</span><span class="Other">[</span><a href="build.html#BuildType"><span class="Identifier">BuildType</span></a><span class="Other">]</span><span class="Other">]</span> <span class="Other">=</span> <span class="Other">[</span><span class="Identifier">btCmake</span><span class="Other">,</span> <span class="Identifier">btAutoconf</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">untyped</span></pre></dt>
<dd>
<p>Get the path to a header file for wrapping with <a class="reference external" href="cimport.html#cImport.m%2C%2Cstring%2Cstring%2Cstring">cImport()</a> or <a class="reference external" href="cimport.html#c2nImport.m%2C%2Cstring%2Cstring%2Cstring">c2nImport()</a>.</p>
<p>This proc checks <tt class="docutils literal"><span class="pre">-d:xxx</span></tt> defines based on the header name (e.g. lzma from lzma.h), and accordingly employs different ways to obtain the source.</p>
<p><tt class="docutils literal"><span class="pre">-d:xxxStd</span></tt> - search standard system paths. E.g. <tt class="docutils literal"><span class="pre">/usr/include</span></tt> and <tt class="docutils literal"><span class="pre">/usr/lib</span></tt> on Linux <tt class="docutils literal"><span class="pre">-d:xxxGit</span></tt> - clone source from a git repo specified in <tt class="docutils literal"><span class="pre">giturl</span></tt> <tt class="docutils literal"><span class="pre">-d:xxxDL</span></tt> - download source from <tt class="docutils literal"><span class="pre">dlurl</span></tt> and extract if required</p>
<p>This allows a single wrapper to be used in different ways depending on the user's needs. If no <tt class="docutils literal"><span class="pre">-d:xxx</span></tt> defines are specified, <tt class="docutils literal"><span class="pre">outdir</span></tt> will be searched for the header as is.</p>
<p>If multiple <tt class="docutils literal"><span class="pre">-d:xxx</span></tt> defines are specified, precedence is <tt class="docutils literal"><span class="pre">Std</span></tt> and then <tt class="docutils literal"><span class="pre">Git</span></tt> or <tt class="docutils literal"><span class="pre">DL</span></tt>. This allows using a system installed library if available before falling back to manual building.</p>
<p><tt class="docutils literal"><span class="pre">-d:xxxSetVer=x.y.z</span></tt> can be used to specify which version to use. It is used as a tag name for Git whereas for DL, it replaces <tt class="docutils literal"><span class="pre">$1</span></tt> in the URL defined.</p>
<p>All defines can also be set in code using <tt class="docutils literal"><span class="pre">setDefines()</span></tt>.</p>
<p>The library is then configured (with <tt class="docutils literal"><span class="pre">cmake</span></tt> or <tt class="docutils literal"><span class="pre">autotools</span></tt> if possible) and built using <tt class="docutils literal"><span class="pre">make</span></tt>, unless using <tt class="docutils literal"><span class="pre">-d:xxxStd</span></tt> which presumes that the system package manager was used to install prebuilt headers and binaries.</p>
<p>The header path is stored in <tt class="docutils literal"><span class="pre">const xxxPath</span></tt> and can be used in a <tt class="docutils literal"><span class="pre">cImport()</span></tt> call in the calling wrapper. The dynamic library path is stored in <tt class="docutils literal"><span class="pre">const xxxLPath</span></tt> and can be used for the <tt class="docutils literal"><span class="pre">dynlib</span></tt> parameter (within quotes) or with <tt class="docutils literal"><span class="pre">{.passL.}</span></tt>.</p>
<p><tt class="docutils literal"><span class="pre">-d:xxxStatic</span></tt> can be specified to statically link with the library instead. This will automatically add a <tt class="docutils literal"><span class="pre">{.passL.}</span></tt> call to the static library for convenience.</p>
<p><tt class="docutils literal"><span class="pre">conFlags</span></tt>, <tt class="docutils literal"><span class="pre">cmakeFlags</span></tt> and <tt class="docutils literal"><span class="pre">makeFlags</span></tt> allow sending custom parameters to <tt class="docutils literal"><span class="pre">configure</span></tt>, <tt class="docutils literal"><span class="pre">cmake</span></tt> and <tt class="docutils literal"><span class="pre">make</span></tt> in case additional configuration is required as part of the build process.</p>
<p><tt class="docutils literal"><span class="pre">altNames</span></tt> is a list of alternate names for the library - e.g. zlib uses <tt class="docutils literal"><span class="pre">zlib.h</span></tt> for the header but the typical lib name is <tt class="docutils literal"><span class="pre">libz.so</span></tt> and not <tt class="docutils literal"><span class="pre">libzlib.so</span></tt>. However, it is libzlib.dll on Windows if built with cmake. In this case, <tt class="docutils literal"><span class="pre">altNames = "z,zlib"</span></tt>. Comma separate for multiple alternate names without spaces.</p>
<p><tt class="docutils literal"><span class="pre">buildTypes</span></tt> specifies a list of in order build strategies to use when building the downloaded source files. Default is [btCmake, btAutoconf]</p>
<p>The original header name is not included by default if <tt class="docutils literal"><span class="pre">altNames</span></tt> is set since it could cause the wrong lib to be selected. E.g. <tt class="docutils literal"><span class="pre">SDL2/SDL.h</span></tt> could pick <tt class="docutils literal"><span class="pre">libSDL.so</span></tt> even if <tt class="docutils literal"><span class="pre">altNames = "SDL2"</span></tt>. Explicitly include it in <tt class="docutils literal"><span class="pre">altNames</span></tt> like the <tt class="docutils literal"><span class="pre">zlib</span></tt> example when required.</p>
<p><tt class="docutils literal"><span class="pre">xxxPreBuild</span></tt> is a hook that is called after the source code is pulled from Git or downloaded but before the library is built. This might be needed if some initial prep needs to be done before compilation. A few values are provided to the hook to help provide context:</p>
<p><tt class="docutils literal"><span class="pre">outdir</span></tt> is the same <tt class="docutils literal"><span class="pre">outdir</span></tt> passed in and <tt class="docutils literal"><span class="pre">header</span></tt> is the discovered header path in the downloaded source code.</p>
<p>Simply define <tt class="docutils literal"><span class="pre">proc xxxPreBuild(outdir, header: string)</span></tt> in the wrapper and it will get called prior to the build process.</p>
</dd>
</dl></div>
</div>
</div>
<div class="row">
<div class="twelve-columns footer">
<span class="nim-sprite"></span>
<br/>
<small style="color: var(--hint);">Made with Nim. Generated: 2020-05-11 03:35:45 UTC</small>
</div>
</div>
</div>
</div>
</body>
</html>
|