Skip to content

Commit 8650c62

Browse files
avargitster
authored andcommitted
doc lint: make "lint-docs" non-.PHONY
Speed up the "lint-docs" target by making it non-.PHONY. Similar to my c234e8a (Makefile: make the "sparse" target non-.PHONY, 2021-09-23). We'll now create empty files corresponding to a dependency graph for each of these lint scripts. This speeds things up a bit[1], and makes the output correspond to any in-tree changes we have: $ touch git-add.txt; make lint-docs; make lint-docs GEN cmd-list.made GEN doc.dep LINT GITLINK git-add.txt LINT MAN END git-add.txt LINT MAN SEC git-add.txt make: Nothing to be done for 'lint-docs'. As with the "sparse" target changes this has a hard dependency on the use of ".DELETE_ON_ERROR" in the Makefile, added here in db10fc6 (doc: simplify Makefile using .DELETE_ON_ERROR, 2021-05-21). This method also depends on the output for us emitting any errors on STDERR (fixed in a preceding commit), as well us these scripts exiting with non-zero on any errors (which they were already doing). 1. $ git show HEAD~:Documentation/Makefile >Makefile.old $ hyperfine --warmup 2 -L f ",.old" 'make -j1 -f Makefile{f} lint-docs' Benchmark #1: make -j1 -f Makefile lint-docs Time (mean ± σ): 60.8 ms ± 1.4 ms [User: 58.7 ms, System: 2.5 ms] Range (min … max): 58.9 ms … 64.0 ms 48 runs Benchmark #2: make -j1 -f Makefile.old lint-docs Time (mean ± σ): 84.0 ms ± 1.5 ms [User: 78.6 ms, System: 5.7 ms] Range (min … max): 81.8 ms … 87.8 ms 35 runs Summary 'make -j1 -f Makefile lint-docs' ran 1.38 ± 0.04 times faster than 'make -j1 -f Makefile.old lint-docs' Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8cc804d commit 8650c62

File tree

3 files changed

+64
-8
lines changed

3 files changed

+64
-8
lines changed

Documentation/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ manpage-base-url.xsl
1414
SubmittingPatches.txt
1515
tmp-doc-diff/
1616
GIT-ASCIIDOCFLAGS
17+
/.build/
1718
/GIT-EXCLUDED-PROGRAMS

Documentation/Makefile

Lines changed: 59 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -223,18 +223,23 @@ endif
223223

224224
ifneq ($(findstring $(MAKEFLAGS),s),s)
225225
ifndef V
226+
QUIET = @
226227
QUIET_ASCIIDOC = @echo ' ' ASCIIDOC $@;
227228
QUIET_XMLTO = @echo ' ' XMLTO $@;
228229
QUIET_DB2TEXI = @echo ' ' DB2TEXI $@;
229230
QUIET_MAKEINFO = @echo ' ' MAKEINFO $@;
230231
QUIET_DBLATEX = @echo ' ' DBLATEX $@;
231232
QUIET_XSLTPROC = @echo ' ' XSLTPROC $@;
232233
QUIET_GEN = @echo ' ' GEN $@;
233-
QUIET_LINT = @echo ' ' LINT $@;
234234
QUIET_STDERR = 2> /dev/null
235235
QUIET_SUBDIR0 = +@subdir=
236236
QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \
237237
$(MAKE) $(PRINT_DIR) -C $$subdir
238+
239+
QUIET_LINT_GITLINK = @echo ' ' LINT GITLINK $<;
240+
QUIET_LINT_MANSEC = @echo ' ' LINT MAN SEC $<;
241+
QUIET_LINT_MANEND = @echo ' ' LINT MAN END $<;
242+
238243
export V
239244
endif
240245
endif
@@ -344,6 +349,7 @@ GIT-ASCIIDOCFLAGS: FORCE
344349
fi
345350

346351
clean:
352+
$(RM) -rf .build/
347353
$(RM) *.xml *.xml+ *.html *.html+ *.1 *.5 *.7
348354
$(RM) *.texi *.texi+ *.texi++ git.info gitman.info
349355
$(RM) *.pdf
@@ -478,14 +484,61 @@ quick-install-html: require-htmlrepo
478484
print-man1:
479485
@for i in $(MAN1_TXT); do echo $$i; done
480486

481-
lint-docs::
482-
$(QUIET_LINT)$(PERL_PATH) lint-gitlink.perl \
487+
## Lint: Common
488+
.build:
489+
$(QUIET)mkdir $@
490+
.build/lint-docs: | .build
491+
$(QUIET)mkdir $@
492+
493+
## Lint: gitlink
494+
.build/lint-docs/gitlink: | .build/lint-docs
495+
$(QUIET)mkdir $@
496+
.build/lint-docs/gitlink/howto: | .build/lint-docs
497+
$(QUIET)mkdir $@
498+
.build/lint-docs/gitlink/config: | .build/lint-docs
499+
$(QUIET)mkdir $@
500+
LINT_DOCS_GITLINK = $(patsubst %.txt,.build/lint-docs/gitlink/%.ok,$(HOWTO_TXT) $(DOC_DEP_TXT))
501+
$(LINT_DOCS_GITLINK): | .build/lint-docs/gitlink
502+
$(LINT_DOCS_GITLINK): | .build/lint-docs/gitlink/howto
503+
$(LINT_DOCS_GITLINK): | .build/lint-docs/gitlink/config
504+
$(LINT_DOCS_GITLINK): lint-gitlink.perl
505+
$(LINT_DOCS_GITLINK): .build/lint-docs/gitlink/%.ok: %.txt
506+
$(QUIET_LINT_GITLINK)$(PERL_PATH) lint-gitlink.perl \
507+
$< \
483508
$(HOWTO_TXT) $(DOC_DEP_TXT) \
484509
--section=1 $(MAN1_TXT) \
485510
--section=5 $(MAN5_TXT) \
486-
--section=7 $(MAN7_TXT) && \
487-
$(PERL_PATH) lint-man-end-blurb.perl $(MAN_TXT) && \
488-
$(PERL_PATH) lint-man-section-order.perl $(MAN_TXT)
511+
--section=7 $(MAN7_TXT) >$@
512+
.PHONY: lint-docs-gitlink
513+
lint-docs-gitlink: $(LINT_DOCS_GITLINK)
514+
515+
## Lint: man-end-blurb
516+
.build/lint-docs/man-end-blurb: | .build/lint-docs
517+
$(QUIET)mkdir $@
518+
LINT_DOCS_MAN_END_BLURB = $(patsubst %.txt,.build/lint-docs/man-end-blurb/%.ok,$(MAN_TXT))
519+
$(LINT_DOCS_MAN_END_BLURB): | .build/lint-docs/man-end-blurb
520+
$(LINT_DOCS_MAN_END_BLURB): lint-man-end-blurb.perl
521+
$(LINT_DOCS_MAN_END_BLURB): .build/lint-docs/man-end-blurb/%.ok: %.txt
522+
$(QUIET_LINT_MANEND)$(PERL_PATH) lint-man-end-blurb.perl $< >$@
523+
.PHONY: lint-docs-man-end-blurb
524+
lint-docs-man-end-blurb: $(LINT_DOCS_MAN_END_BLURB)
525+
526+
## Lint: man-section-order
527+
.build/lint-docs/man-section-order: | .build/lint-docs
528+
$(QUIET)mkdir $@
529+
LINT_DOCS_MAN_SECTION_ORDER = $(patsubst %.txt,.build/lint-docs/man-section-order/%.ok,$(MAN_TXT))
530+
$(LINT_DOCS_MAN_SECTION_ORDER): | .build/lint-docs/man-section-order
531+
$(LINT_DOCS_MAN_SECTION_ORDER): lint-man-section-order.perl
532+
$(LINT_DOCS_MAN_SECTION_ORDER): .build/lint-docs/man-section-order/%.ok: %.txt
533+
$(QUIET_LINT_MANSEC)$(PERL_PATH) lint-man-section-order.perl $< >$@
534+
.PHONY: lint-docs-man-section-order
535+
lint-docs-man-section-order: $(LINT_DOCS_MAN_SECTION_ORDER)
536+
537+
## Lint: list of targets above
538+
.PHONY: lint-docs
539+
lint-docs: lint-docs-gitlink
540+
lint-docs: lint-docs-man-end-blurb
541+
lint-docs: lint-docs-man-section-order
489542

490543
ifeq ($(wildcard po/Makefile),po/Makefile)
491544
doc-l10n install-l10n::

Documentation/lint-gitlink.perl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55

66
# Parse arguments, a simple state machine for input like:
77
#
8-
# howto/*.txt config/*.txt --section=1 git.txt git-add.txt [...] --to-lint git-add.txt a-file.txt [...]
8+
# <file-to-check.txt> <valid-files-to-link-to> --section=1 git.txt git-add.txt [...] --to-lint git-add.txt a-file.txt [...]
99
my %TXT;
1010
my %SECTION;
1111
my $section;
1212
my $lint_these = 0;
13+
my $to_check = shift @ARGV;
1314
for my $arg (@ARGV) {
1415
if (my ($sec) = $arg =~ /^--section=(\d+)$/s) {
1516
$section = $sec;
@@ -36,7 +37,8 @@ sub report {
3637
}
3738

3839
@ARGV = sort values %TXT;
39-
die "BUG: Nothing to process!" unless @ARGV;
40+
die "BUG: No list of valid linkgit:* files given" unless @ARGV;
41+
@ARGV = $to_check;
4042
while (<>) {
4143
my $line = $_;
4244
while ($line =~ m/linkgit:((.*?)\[(\d)\])/g) {

0 commit comments

Comments
 (0)