-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.nims
More file actions
75 lines (65 loc) · 2.99 KB
/
Copy pathconfig.nims
File metadata and controls
75 lines (65 loc) · 2.99 KB
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
# begin Nimble config (version 2)
when withDir(thisDir(), system.fileExists("nimble.paths")):
include "nimble.paths"
# end Nimble config
import std/[os, strutils]
const
tyrCapabilityOverride = "tyrExplicitCapabilities"
var
repoRoot: string = thisDir()
proc addPathIfExists(pathArg: string) =
if dirExists(pathArg):
switch("path", pathArg.replace('\\', '/'))
include "tyr_simd.nims"
## Build presets: configs/default.toml always, plus configs/<name>.toml when
## the build says -d:preset=<name>. The reader is shared by every repo.
when fileExists(thisDir() & "/../Nimble-Tasks/src/preset.nims"):
include "../Nimble-Tasks/src/preset.nims"
elif fileExists(thisDir() & "/submodules/Nimble-Tasks/src/preset.nims"):
include "submodules/Nimble-Tasks/src/preset.nims"
else:
proc presetValue(section, key, fallback: string): string = fallback
proc applyPreset() = echo "config.nims: Nimble-Tasks/src/preset.nims " &
"not found; configs/*.toml are ignored. Update the submodule."
proc applyTyrBuildDefaults() =
## Tyr on its own defaults to `native` (configs/default.toml): its tests
## and benchmarks run on the machine that builds them.
## -d:tyrExplicitCapabilities (or an Otter UI target) means "I pass the
## capability defines myself" and makes the default `scalar`. An explicit
## -d:tyrSimd= always wins; see tyr_simd.nims.
var
fallback: string = "native"
if tyrSimdOption("opt").len == 0:
switch("opt", "speed")
applyPreset()
fallback = presetValue("define", "tyrSimd", fallback)
if tyrSimdDefine(tyrCapabilityOverride).len > 0 or
presetValue("define", tyrCapabilityOverride, "false") == "true" or
tyrSimdDefine("OtterUiTarget").len > 0:
fallback = "scalar"
applyTyrSimd(fallback)
addPathIfExists(joinPath(repoRoot, "src"))
addPathIfExists(joinPath(repoRoot, "tools", "meta"))
addPathIfExists(joinPath(repoRoot, "tools"))
addPathIfExists(joinPath(repoRoot, "submodules", "simd_nexus", "src"))
addPathIfExists(joinPath(repoRoot, "..", "SIMD-Nexus", "src"))
addPathIfExists(joinPath(repoRoot, "..", "Fylgia-Utils", "src"))
if dirExists(joinPath(repoRoot, "..", "Otter-RepoEvaluation", "src")):
addPathIfExists(joinPath(repoRoot, "..", "Otter-RepoEvaluation", "src"))
else:
addPathIfExists(joinPath(repoRoot, "submodules", "otter_repo_evaluation", "src"))
var nimblePkgs: string = joinPath(getHomeDir(), ".nimble", "pkgs2")
if dirExists(nimblePkgs):
for kind, path in walkDir(nimblePkgs):
if kind == pcDir and path.contains("nimsimd-"):
var candidate: string = joinPath(path, "nimsimd")
if dirExists(candidate):
switch("path", path.replace('\\', '/'))
break
applyTyrBuildDefaults()
## Shared pragma module: one file for the whole workspace, so there is no
## per-repository copy to drift or to collide on the Nim path.
if dirExists(thisDir() & "/../Rune-Pragmas/meta"):
switch("path", thisDir() & "/../Rune-Pragmas/meta")
if dirExists(thisDir() & "/submodules/Rune-Pragmas/meta"):
switch("path", thisDir() & "/submodules/Rune-Pragmas/meta")