forked from ProdriveTechnologies/bazel-latex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
toolchain.bzl
59 lines (55 loc) · 1.74 KB
/
toolchain.bzl
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
LatexInfo = provider(
doc = "Information about how to invoke the latex compiler",
fields = ["kpsewhich", "luatex", "bibtex", "biber"],
)
def _latex_toolchain_info_impl(ctx):
return [
platform_common.ToolchainInfo(
latexinfo = LatexInfo(
kpsewhich = ctx.attr.kpsewhich,
luatex = ctx.attr.luatex,
bibtex = ctx.attr.bibtex,
biber = ctx.attr.biber,
),
),
]
_latex_toolchain_info = rule(
attrs = {
"kpsewhich": attr.label(
allow_single_file = True,
cfg = "host",
executable = True,
),
"luatex": attr.label(
allow_single_file = True,
cfg = "host",
executable = True,
),
"bibtex": attr.label(
allow_single_file = True,
cfg = "host",
executable = True,
),
"biber": attr.label(
allow_single_file = True,
cfg = "host",
executable = True,
),
},
implementation = _latex_toolchain_info_impl,
)
def latex_toolchain(platform, exec_compatible_with):
_latex_toolchain_info(
name = "latex_toolchain_info_%s" % platform,
kpsewhich = "@texlive_bin__%s//:kpsewhich" % platform,
luatex = "@texlive_bin__%s//:luatex" % platform,
bibtex = "@texlive_bin__%s//:bibtex" % platform,
biber = "@texlive_bin__%s//:biber" % platform,
visibility = ["//visibility:public"],
)
native.toolchain(
name = "latex_toolchain_%s" % platform,
exec_compatible_with = exec_compatible_with,
toolchain = ":latex_toolchain_info_%s" % platform,
toolchain_type = ":latex_toolchain_type",
)