-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathchalk.nimble
75 lines (61 loc) · 2.92 KB
/
chalk.nimble
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import std/[cmdline, strformat, strscans, strutils]
from src/config_version import getChalkVersion
version = getChalkVersion(withSuffix = false)
author = "John Viega"
description = "Software artifact metadata to make it easy to tie " &
"deployments to source code and collect metadata."
license = "GPLv3"
srcDir = "src"
bin = @["chalk"]
# Dependencies
requires "nim >= 2.0.8"
requires "https://github.com/crashappsec/con4m#40da38c73f11c79d56da17a05d094da5293b02d3"
requires "https://github.com/viega/zippy == 0.10.7" # MIT
requires "https://github.com/NimParsers/parsetoml == 0.7.1" # MIT
# this allows us to get version externally
task version, "Show current version":
echo version
task test, "Run the unit tests":
var args = ""
for s in commandLineParams():
discard s.scanf("args=$+", args) # Sets `args` to any user-provided value.
if args == "":
args = "--verbose pattern 'tests/unit/*.nim'" # By default, run all unit tests.
exec "testament " & args
# Add --trace if needed.
after build:
# ideally this should work:
# when not defined(debug):
# however debug symbol doesnt seem to be defined by nimble?
# and it always runs strip
# instead we check env var set by Makefile
if getEnv("DEBUG", "false") != "true":
exec "set -x && strip " & bin[0]
exec "set -x && ./" & bin[0] & " --debug --no-use-external-config --skip-command-report load default"
task debug, "Get a debug build":
# additional flags are configured in config.nims
exec "nimble build --define:debug"
task release, "Package the release build":
exec "nimble build"
task performance, "Get a build that adds execution profiling support":
exec "nimble build --profiler:on --stackTrace:on -d:cprofiling"
task memprofile, "Get a build that adds memory profiling to the binary":
exec "nimble build --profiler:off --stackTrace:on -d:memProfiler -d:cprofiling"
let completion_script_version = version
task mark_completion, "Replace the chalk mark in a completion script, including the articact version":
exec """cat > tmpcfg.c4m << EOF
keyspec.ARTIFACT_VERSION.value = "REPLACE_ME"
keyspec.CHALK_PTR.value = ("This mark determines when to update the script." +
" If there is no mark, or the mark is invalid it will be replaced. " +
" To customize w/o Chalk disturbing it when it can update, add a valid " +
" mark with a version key higher than the current chalk verison, or " +
" use version 0.0.0 to prevent updates")
mark_template.mark_default.key.BRANCH.use = false
mark_template.mark_default.key.CHALK_RAND.use = false
mark_template.mark_default.key.CODE_OWNERS.use = false
mark_template.mark_default.key.COMMIT_ID.use = false
mark_template.mark_default.key.PLATFORM_WHEN_CHALKED.use = false
EOF
""".replace("REPLACE_ME", completion_script_version)
exec "./chalk --use-external-config --config-file=./tmpcfg.c4m --no-use-embedded-config --skip-command-report insert src/autocomplete"
exec "rm ./tmpcfg.c4m"