Skip to content

Commit 193279d

Browse files
committed
Refactor the doc building rules a bit, sensitize them to the presence or absence of xetex and luatex (for now).
1 parent 5ac57d1 commit 193279d

File tree

3 files changed

+73
-60
lines changed

3 files changed

+73
-60
lines changed

Makefile.in

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -133,39 +133,6 @@ ifdef CFG_BAD_VALGRIND
133133
CFG_VALGRIND :=
134134
endif
135135

136-
DOCS :=
137-
ifeq ($(CFG_PANDOC),)
138-
$(info cfg: no pandoc found, omitting doc/rust.html)
139-
else
140-
DOCS += doc/rust.html
141-
endif
142-
143-
ifeq ($(CFG_PANDOC),)
144-
$(info cfg: no pandoc found, omitting doc/rust.pdf)
145-
else
146-
ifeq ($(CFG_PDFLATEX),)
147-
$(info cfg: no pdflatex found, omitting doc/rust.pdf)
148-
else
149-
DOCS += doc/rust.pdf
150-
endif
151-
endif
152-
153-
ifeq ($(CFG_NODE),)
154-
$(info cfg: no node found, omitting doc/tutorial/web)
155-
else
156-
DOCS += doc/tutorial/web/index.html
157-
endif
158-
159-
ifeq ($(CFG_NATURALDOCS),)
160-
$(info cfg: no naturaldocs found, omitting library doc build)
161-
else
162-
DOCS += doc/core/index.html doc/std/index.html
163-
endif
164-
165-
ifdef CFG_DISABLE_DOCS
166-
$(info cfg: disabling doc build (CFG_DISABLE_DOCS))
167-
DOCS :=
168-
endif
169136

170137
######################################################################
171138
# Target-and-rule "utility variables"
@@ -431,7 +398,7 @@ CFG_INFO := $(info cfg: *** compiler is in snapshot transition ***)
431398
CFG_INFO := $(info cfg: *** stage2 and later will not be built ***)
432399
CFG_INFO := $(info cfg:)
433400

434-
all: $(SREQ1$(CFG_HOST_TRIPLE)) $(GENERATED) $(DOCS)
401+
all: $(SREQ1$(CFG_HOST_TRIPLE)) $(GENERATED) docs
435402

436403
else
437404

@@ -442,7 +409,7 @@ FUZZ := $(HBIN3_H_$(CFG_HOST_TRIPLE))/fuzzer$(X)
442409
CARGO := $(HBIN3_H_$(CFG_HOST_TRIPLE))/cargo$(X)
443410
RUSTDOC := $(HBIN3_H_$(CFG_HOST_TRIPLE))/rustdoc$(X)
444411

445-
all: rustc $(GENERATED) $(DOCS) $(FUZZ) $(CARGO) $(RUSTDOC)
412+
all: rustc $(GENERATED) docs $(FUZZ) $(CARGO) $(RUSTDOC)
446413

447414
endif
448415

configure

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,8 @@ probe CFG_NATURALDOCS naturaldocs
289289
probe CFG_LLNEXTGEN LLnextgen
290290
probe CFG_PANDOC pandoc
291291
probe CFG_PDFLATEX pdflatex
292+
probe CFG_XETEX xetex
293+
probe CFG_LUATEX luatex
292294
probe CFG_NODE node
293295

294296
if [ -z "$CFG_NODE" ]

mk/docs.mk

Lines changed: 69 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@
22
# Doc variables and rules
33
######################################################################
44

5-
doc/version.md: $(MKFILE_DEPS) rust.md
6-
@$(call E, version-stamp: $@)
7-
$(Q)echo "$(CFG_VERSION)" >>$@
5+
DOCS :=
86

9-
doc/keywords.md: $(MKFILE_DEPS) rust.md
10-
@$(call E, grep -v: $$@)
11-
$(Q)grep -v '^#' $< >$@
127

13-
ifdef CFG_PANDOC
8+
######################################################################
9+
# Pandoc (reference-manual related)
10+
######################################################################
11+
ifeq ($(CFG_PANDOC),)
12+
$(info cfg: no pandoc found, omitting doc/rust.pdf)
13+
else
1414

15+
DOCS += doc/rust.html
1516
doc/rust.html: rust.md doc/version.md doc/keywords.md
1617
@$(call E, pandoc: $@)
1718
$(Q)$(CFG_PANDOC) \
@@ -26,8 +27,17 @@ doc/rust.html: rust.md doc/version.md doc/keywords.md
2627
-$(Q)cp -a $(S)doc/rust.css doc/rust.css 2> /dev/null
2728

2829

29-
ifdef CFG_PDFLATEX
30+
ifeq ($(CFG_PDFLATEX),)
31+
$(info cfg: no pdflatex found, omitting doc/rust.pdf)
32+
else
33+
ifeq ($(CFG_XETEX),)
34+
$(info cfg: no xetex found, disabling doc/rust.pdf)
35+
else
36+
ifeq ($(CFG_LUATEX),)
37+
$(info cfg: lacking luatex, disabling pdflatex)
38+
else
3039

40+
DOCS += doc/rust.pdf
3141
doc/rust.tex: rust.md doc/version.md doc/keywords.md
3242
@$(call E, pandoc: $@)
3343
$(Q)$(CFG_PANDOC) \
@@ -44,13 +54,39 @@ doc/rust.pdf: doc/rust.tex
4454
-output-directory=doc \
4555
$<
4656

57+
endif
58+
endif
59+
endif
4760
endif
4861

62+
63+
######################################################################
64+
# LLnextgen (grammar analysis from refman)
65+
######################################################################
66+
ifeq ($(CFG_LLNEXTGEN),)
67+
$(info cfg: no llnextgen found, omitting grammar-verification)
68+
else
69+
.PHONY: verify-grammar
70+
71+
doc/rust.g: rust.md $(S)src/etc/extract_grammar.py
72+
@$(call E, extract_grammar: $@)
73+
$(Q)$(S)src/etc/extract_grammar.py $< >$@
74+
75+
verify-grammar: doc/rust.g
76+
@$(call E, LLnextgen: $<)
77+
$(Q)$(CFG_LLNEXTGEN) --generate-lexer-wrapper=no $< >$@
78+
$(Q)rm -f doc/rust.c doc/rust.h
4979
endif
5080

5181

52-
ifdef CFG_NODE
82+
######################################################################
83+
# Node (tutorial related)
84+
######################################################################
85+
ifeq ($(CFG_NODE),)
86+
$(info cfg: no node found, omitting doc/tutorial/web)
87+
else
5388

89+
DOCS += doc/tutorial/web/index.html
5490
doc/tutorial/web/index.html: \
5591
$(wildcard $(S)doc/tutorial/*.md)
5692
@$(call E, cp: $(S)doc/tutorial)
@@ -61,23 +97,14 @@ doc/tutorial/web/index.html: \
6197
endif
6298

6399

64-
ifdef CFG_LLNEXTGEN
65-
doc/rust.g: rust.md $(S)src/etc/extract_grammar.py
66-
@$(call E, extract_grammar: $@)
67-
$(Q)$(S)src/etc/extract_grammar.py $< >$@
68100

69-
verify-grammar: doc/rust.g
70-
@$(call E, LLnextgen: $<)
71-
$(Q)$(CFG_LLNEXTGEN) --generate-lexer-wrapper=no $< >$@
72-
$(Q)rm -f doc/rust.c doc/rust.h
73-
endif
74-
75-
76-
GENERATED += doc/keywords.md doc/version.md
101+
######################################################################
102+
# Naturaldocs (library reference related)
103+
######################################################################
77104

78-
docsnap: doc/rust.pdf
79-
@$(call E, snap: doc/rust-$(shell date +"%Y-%m-%d")-snap.pdf)
80-
$(Q)mv $< doc/rust-$(shell date +"%Y-%m-%d")-snap.pdf
105+
ifeq ($(CFG_NATURALDOCS),)
106+
$(info cfg: no naturaldocs found, omitting library doc build)
107+
else
81108

82109
define libdoc
83110
doc/$(1)/index.html: nd/$(1)/Languages.txt nd/$(1)/Topics.txt \
@@ -103,10 +130,27 @@ GENERATED += nd/$(1)/Languages.txt \
103130
nd/$(1)/Data
104131

105132
DOCS += doc/$(1)/index.html nd/$(1)/lib.css
106-
107133
endef
108134

109135
$(eval $(call libdoc,core,$(CORELIB_CRATE) $(CORELIB_INPUTS)))
110136
$(eval $(call libdoc,std,$(STDLIB_CRATE) $(STDLIB_INPUTS)))
137+
endif
138+
139+
140+
ifdef CFG_DISABLE_DOCS
141+
$(info cfg: disabling doc build (CFG_DISABLE_DOCS))
142+
DOCS :=
143+
endif
144+
145+
146+
doc/version.md: $(MKFILE_DEPS) rust.md
147+
@$(call E, version-stamp: $@)
148+
$(Q)echo "$(CFG_VERSION)" >>$@
149+
150+
doc/keywords.md: $(MKFILE_DEPS) rust.md
151+
@$(call E, grep -v: $$@)
152+
$(Q)grep -v '^#' $< >$@
153+
154+
GENERATED += doc/keywords.md doc/version.md
111155

112156
docs: $(DOCS)

0 commit comments

Comments
 (0)