-
Notifications
You must be signed in to change notification settings - Fork 37
/
toolchain.bzl
127 lines (120 loc) · 3.57 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
"""
Definitions related to a LaTeX toolchain
"""
LatexInfo = provider(
doc = "Information about how to invoke the latex compiler",
fields = [
"biber",
"bibtex",
"dvisvgm",
"gsftopk",
"kpsewhich",
"kpsestat",
"luahbtex",
"luatex",
"mktexlsr",
"kpseaccess",
],
)
def _latex_toolchain_info_impl(ctx):
return [
platform_common.ToolchainInfo(
latexinfo = LatexInfo(
biber = ctx.attr.biber,
bibtex = ctx.attr.bibtex,
dvisvgm = ctx.attr.dvisvgm,
gsftopk = ctx.attr.gsftopk,
kpsewhich = ctx.attr.kpsewhich,
kpsestat = ctx.attr.kpsestat,
luahbtex = ctx.attr.luahbtex,
luatex = ctx.attr.luatex,
mktexlsr = ctx.attr.mktexlsr,
kpseaccess = ctx.attr.kpseaccess,
),
),
]
_latex_toolchain_info = rule(
attrs = {
"biber": attr.label(
allow_single_file = True,
cfg = "exec",
executable = True,
),
"bibtex": attr.label(
allow_single_file = True,
cfg = "exec",
executable = True,
),
"dvisvgm": attr.label(
allow_single_file = True,
cfg = "exec",
executable = True,
),
"gsftopk": attr.label(
allow_single_file = True,
cfg = "exec",
executable = True,
),
"kpseaccess": attr.label(
allow_single_file = True,
cfg = "exec",
executable = True,
),
"kpsestat": attr.label(
allow_single_file = True,
cfg = "exec",
executable = True,
),
"kpsewhich": attr.label(
allow_single_file = True,
cfg = "exec",
executable = True,
),
"luahbtex": attr.label(
allow_single_file = True,
cfg = "exec",
executable = True,
),
"luatex": attr.label(
allow_single_file = True,
cfg = "exec",
executable = True,
),
"mktexlsr": attr.label(
allow_single_file = True,
cfg = "exec",
executable = True,
),
},
implementation = _latex_toolchain_info_impl,
)
def latex_toolchain(platform, exec_compatible_with, name = None):
"""
Defines a LaTeX toolchain.
Args:
name: optional name for the toolchain, defaults to latex_toolchain_{platform}.
platform: name of the platform as named by TeXLive.
exec_compatible_with: execution constraints passed to the toolchain.
"""
_toolchain_name = name if name != None else "latex_toolchain_%s" % platform
stem = "@texlive_bin__" + platform + "//:"
_latex_toolchain_info(
name = "%s_info" % _toolchain_name,
biber = stem + "biber",
bibtex = stem + "bibtex",
dvisvgm = stem + "dvisvgm",
gsftopk = stem + "gsftopk",
kpseaccess = stem + "kpseaccess",
kpsestat = stem + "kpsestat",
kpsewhich = stem + "kpsewhich",
luahbtex = stem + "luahbtex",
luatex = stem + "luatex",
mktexlsr = "@texlive_texmf__texmf-dist__scripts__texlive//:" + "mktexlsr",
visibility = ["//visibility:public"],
)
native.toolchain(
name = _toolchain_name,
exec_compatible_with = exec_compatible_with,
toolchain = ":%s_info" % _toolchain_name,
toolchain_type = ":latex_toolchain_type",
)