forked from thought-machine/pleasings
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnim.build_defs
48 lines (41 loc) · 1.42 KB
/
nim.build_defs
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
def nim_binary(name:str, main:str, srcs:list=[], out:str=None, test_only:bool=False, visibility:list=None, deps:list=[]):
out = out or name
cmd = ' && '.join([
_nimble_path(),
"$TOOL --verbosity:2 --NimblePath:$NIMBLE_PATH/pkgs -o:" + out + " c $PKG_DIR/" + main,
])
return build_rule(
name = name,
srcs = srcs + [main],
outs = [out],
tools = [CONFIG.NIM_TOOL],
cmd = cmd,
deps = deps,
requires = ["nim"],
test_only = test_only,
binary = True,
visibility = visibility,
)
def nimble_install(name:str, pkg_name:str=None, revision:str=None, test_only:bool=False, visibility:list=None, deps:list=[]):
pkg_name = pkg_name or name
revision = revision or "#head"
pkg = pkg_name + "@" + revision
cmd = ' && '.join([
_nimble_path(),
"$TOOL --accept --verbose --nimbleDir:$NIMBLE_PATH install " + pkg,
"ln -s $NIMBLE_PATH/pkgs/" + pkg_name + "* ./",
])
return build_rule(
name = name,
tools = [CONFIG.NIMBLE_TOOL],
cmd = cmd,
deps = deps,
outs = [pkg_name + "-" + revision],
requires = ["nimble"],
test_only = test_only,
visibility = visibility,
)
def _nimble_path():
return "NIMBLE_PATH=$(pwd | awk -F'plz-out' '{print $1}')\"plz-out/.nimble\""
CONFIG.setdefault('NIM_TOOL', 'nim')
CONFIG.setdefault('NIMBLE_TOOL', 'nimble')