|
1 | 1 | load("@pypi//:requirements.bzl", "requirement") |
2 | | -load("@bazel_latex//:latex.bzl", "latex_document") |
3 | | - |
4 | | -PY_DEPS = [ |
5 | | - requirement("loguru"), |
6 | | - requirement("mypy"), |
7 | | - requirement("pytest"), |
8 | | -] |
9 | | - |
| 2 | +load("@rules_latex//latex:defs.bzl", "latex_document", "latex_test") |
| 3 | +load("@rules_python//python:defs.bzl", "py_binary") |
10 | 4 |
|
11 | 5 | py_binary( |
12 | 6 | name = "main", |
13 | 7 | srcs = glob(["src/**/*.py"]), |
14 | | - deps = PY_DEPS, |
| 8 | + deps = [requirement("loguru")], |
15 | 9 | ) |
16 | 10 |
|
| 11 | +# Shared preamble, references and images used by both documents. allow_empty |
| 12 | +# keeps the optional image patterns (e.g. *.jpeg) from failing the build when a |
| 13 | +# given format isn't present under common/. |
| 14 | +_COMMON = glob( |
| 15 | + [ |
| 16 | + "common/**/*.tex", |
| 17 | + "common/**/*.png", |
| 18 | + "common/**/*.jpeg", |
| 19 | + "common/**/*.bib", |
| 20 | + ], |
| 21 | + allow_empty = True, |
| 22 | +) |
17 | 23 |
|
18 | | -TEX_DEPS = [ |
19 | | - "@bazel_latex//packages:amsmath", |
20 | | - "@bazel_latex//packages:babel_english", |
21 | | - "@bazel_latex//packages:biblatex", |
22 | | - "@bazel_latex//packages:calc", |
23 | | - "@bazel_latex//packages:csquotes", |
24 | | - "@bazel_latex//packages:enumitem", |
25 | | - "@bazel_latex//packages:float", |
26 | | - "@bazel_latex//packages:geometry", |
27 | | - "@bazel_latex//packages:grfext", |
28 | | - "@bazel_latex//packages:hyperref", |
29 | | - "@bazel_latex//packages:l3keys2e", |
30 | | - "@bazel_latex//packages:listings", |
31 | | - "@bazel_latex//packages:longtable", |
32 | | - "@bazel_latex//packages:tikz", |
33 | | - "@bazel_latex//packages:titling", |
34 | | - "@bazel_latex//packages:upquote", |
35 | | - "@bazel_latex//packages:xcolor", |
36 | | - "@bazel_latex//packages:xkeyval", |
37 | | - "@texlive_texmf__texmf-dist__tex__generic__hyph-utf8__loadhyph", #lipsum |
38 | | - "@texlive_texmf__texmf-dist__tex__generic__hyph-utf8__patterns__tex", #lipsum |
39 | | - "@texlive_texmf__texmf-dist__tex__latex__appendix", |
40 | | - "@texlive_texmf__texmf-dist__tex__latex__biblatex-ieee", |
41 | | - "@texlive_texmf__texmf-dist__tex__latex__braket", |
42 | | - "@texlive_texmf__texmf-dist__tex__latex__lipsum", |
43 | | - "@texlive_texmf__texmf-dist__tex__latex__lstaddons", # lstautogobble |
44 | | - "@texlive_texmf__texmf-dist__tex__latex__mathtools", |
45 | | - "@texlive_texmf__texmf-dist__tex__latex__multirow", |
46 | | - "@texlive_texmf__texmf-dist__tex__latex__pdflscape", |
47 | | - "@texlive_texmf__texmf-dist__tex__latex__tocbibind", |
48 | | - "@texlive_texmf__texmf-dist__tex__latex__todonotes", |
49 | | -] |
| 24 | +# The document entry points live at the repository root (proposal.tex, |
| 25 | +# thesis.tex) so rules_latex's main-rooted staging mirrors the workspace |
| 26 | +# layout: every `\input`/`\include` path is written relative to the repo root, |
| 27 | +# which is also what keeps the template buildable on Overleaf unchanged. |
| 28 | +_PROPOSAL_SRCS = ["proposal.tex"] + glob(["proposal/**/*.tex"]) + _COMMON |
50 | 29 |
|
| 30 | +_THESIS_SRCS = ["thesis.tex"] + glob(["thesis/**/*.tex"]) + _COMMON |
51 | 31 |
|
52 | 32 | latex_document( |
53 | 33 | name = "proposal", |
54 | | - srcs = glob( |
55 | | - [ |
56 | | - "proposal/**/*.tex", |
57 | | - "common/**/*.tex", |
58 | | - "common/**/*.png", |
59 | | - "common/**/*.jpeg", |
60 | | - "common/**/*.bib", |
61 | | - ], |
62 | | - ) + TEX_DEPS, |
63 | | - format = "pdf", |
64 | | - cmd_flags = ["--bibtex-cmd=biber"], |
65 | | - main = "proposal/main.tex", |
| 34 | + srcs = _PROPOSAL_SRCS, |
| 35 | + biber = True, |
| 36 | + main = "proposal.tex", |
66 | 37 | ) |
67 | 38 |
|
| 39 | +# timeout = "long": the first compile primes Tectonic's cache online (~2 min); |
| 40 | +# subsequent runs are action-cache hits. |
| 41 | +latex_test( |
| 42 | + name = "proposal_compiles", |
| 43 | + timeout = "long", |
| 44 | + srcs = _PROPOSAL_SRCS, |
| 45 | + biber = True, |
| 46 | + main = "proposal.tex", |
| 47 | +) |
68 | 48 |
|
69 | 49 | latex_document( |
70 | 50 | name = "thesis", |
71 | | - srcs = glob( |
72 | | - [ |
73 | | - "thesis/**/*.tex", |
74 | | - "common/**/*.tex", |
75 | | - "common/**/*.png", |
76 | | - "common/**/*.jpeg", |
77 | | - "common/**/*.bib", |
78 | | - ], |
79 | | - ) + TEX_DEPS, |
80 | | - format = "pdf", |
81 | | - cmd_flags = ["--bibtex-cmd=biber"], |
82 | | - main = "thesis/main.tex", |
| 51 | + srcs = _THESIS_SRCS, |
| 52 | + biber = True, |
| 53 | + main = "thesis.tex", |
| 54 | +) |
| 55 | + |
| 56 | +latex_test( |
| 57 | + name = "thesis_compiles", |
| 58 | + timeout = "long", |
| 59 | + srcs = _THESIS_SRCS, |
| 60 | + biber = True, |
| 61 | + main = "thesis.tex", |
83 | 62 | ) |
0 commit comments