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
|
load(
"@rules_erlang//private:erlang_build.bzl",
"OtpInfo",
)
load(
":elixir_build.bzl",
"ElixirInfo",
)
def _impl(ctx):
toolchain_info = platform_common.ToolchainInfo(
otpinfo = ctx.attr.elixir[OtpInfo],
elixirinfo = ctx.attr.elixir[ElixirInfo],
)
return [toolchain_info]
elixir_toolchain = rule(
implementation = _impl,
attrs = {
"elixir": attr.label(
mandatory = True,
providers = [OtpInfo, ElixirInfo],
),
},
provides = [platform_common.ToolchainInfo],
)
def _build_info(ctx):
return ctx.toolchains[":toolchain_type"].otpinfo
def erlang_dirs(ctx):
info = _build_info(ctx)
if info.release_dir != None:
runfiles = ctx.runfiles([
info.release_dir,
info.version_file,
])
else:
runfiles = ctx.runfiles([
info.version_file,
])
return (info.erlang_home, info.release_dir, runfiles)
def elixir_dirs(ctx, short_path = False):
info = ctx.toolchains[":toolchain_type"].elixirinfo
if info.elixir_home != None:
return (info.elixir_home, ctx.runfiles([info.version_file]))
else:
p = info.release_dir.short_path if short_path else info.release_dir.path
return (p, ctx.runfiles([info.release_dir, info.version_file]))
def maybe_install_erlang(ctx, short_path = False):
info = _build_info(ctx)
release_dir = info.release_dir
if release_dir == None:
return ""
else:
return """mkdir -p $(dirname "{erlang_home}")
cp -r {erlang_release_dir} "{erlang_home}"
ERTS_DIRNAME="$(basename "$(echo "{erlang_home}"/erts-*)")"
ln -sf ../$ERTS_DIRNAME/bin/epmd "{erlang_home}"/bin/epmd
""".format(
erlang_release_dir = release_dir.short_path if short_path else release_dir.path,
erlang_home = info.erlang_home,
)
|