Skip to content

Commit 56aeba7

Browse files
authored
Merge pull request #3882 from masatake/enhance--check-genfile
builds-sys/test: enhance check-genfile target
2 parents 3a62ddb + 5573cfa commit 56aeba7

File tree

1 file changed

+116
-19
lines changed

1 file changed

+116
-19
lines changed

makefiles/testing.mak

Lines changed: 116 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -309,70 +309,167 @@ clean-man-test:
309309
chkgen_verbose = $(chkgen_verbose_@AM_V@)
310310
chkgen_verbose_ = $(chkgen_verbose_@AM_DEFAULT_V@)
311311
chkgen_verbose_0 = @echo CHKGEN " $@";
312-
check-genfile:
313-
if BUILD_IN_GIT_REPO
312+
313+
cgok = echo "<ok> $@:"
314+
cgerr = echo "<ERROR> $@:"
315+
cgskip = echo "<skip> $@:"
316+
317+
recover_side_effects = cg-force-optlib2c-srcs cg-force-txt2cstr-srcs cg-force-man-docs
318+
314319
# OPTLIB2C_SRCS : committed for win32 build
320+
.PHONY: cg-clean-optlib2c-srcs cg-force-optlib2c-srcs check-genfile-optlib2c-srcs
321+
cg-clean-optlib2c-srcs:
322+
if BUILD_IN_GIT_REPO
315323
$(chkgen_verbose)rm -f $(OPTLIB2C_SRCS)
324+
endif
325+
cg-force-optlib2c-srcs: cg-clean-optlib2c-srcs
326+
if BUILD_IN_GIT_REPO
316327
$(chkgen_verbose)$(MAKE) $(OPTLIB2C_SRCS)
328+
endif
329+
check-genfile-optlib2c-srcs: $(recover_side_effects) cg-force-optlib2c-srcs
330+
if BUILD_IN_GIT_REPO
317331
$(chkgen_verbose)if ! git diff --exit-code $(OPTLIB2C_DIR); then \
318-
echo "Files under $(OPTLIB2C_DIR) are not up to date." ; \
319-
echo "If you change $(OPTLIB2C_DIR)/foo.ctags, don't forget to add $(OPTLIB2C_DIR)/foo.c to your commit." ; \
332+
$(cgerr) "Files under $(OPTLIB2C_DIR) are not up to date." ; \
333+
$(cgerr) "If you change $(OPTLIB2C_DIR)/foo.ctags, don't forget to add $(OPTLIB2C_DIR)/foo.c to your commit." ; \
320334
exit 1 ; \
321335
else \
322-
echo "Files under $(OPTLIB2C_DIR) are up to date." ; \
336+
$(cgok) "Files under $(OPTLIB2C_DIR) are up to date." ; \
323337
fi
338+
endif
339+
324340
# TXT2CSTR_SRCS : committed for win32 build
341+
.PHONY: cg-clean-txt2cstr-srcs cg-force-txt2cstr-srcs check-genfile-txt2cstr-srcs
342+
cg-clean-txt2cstr-srcs:
343+
if BUILD_IN_GIT_REPO
325344
$(chkgen_verbose)rm -f $(TXT2CSTR_SRCS)
345+
endif
346+
cg-force-txt2cstr-srcs: cg-clean-txt2cstr-srcs
347+
if BUILD_IN_GIT_REPO
326348
$(chkgen_verbose)$(MAKE) $(TXT2CSTR_SRCS)
349+
endif
350+
check-genfile-txt2cstr-srcs: $(recover_side_effects) cg-force-txt2cstr-srcs
351+
if BUILD_IN_GIT_REPO
327352
$(chkgen_verbose)if ! git diff --exit-code $(TXT2CSTR_DIR); then \
328-
echo "Files under $(TXT2CSTR_DIR) are not up to date." ; \
329-
echo "If you change $(TXT2CSTR_DIR)/foo.ps, don't forget to add $(TXT2CSTR_DIR)/foo.c to your commit." ; \
353+
$(cgerr) "Files under $(TXT2CSTR_DIR) are not up to date." ; \
354+
$(cgerr) "If you change $(TXT2CSTR_DIR)/foo.ps, don't forget to add $(TXT2CSTR_DIR)/foo.c to your commit." ; \
330355
exit 1 ; \
331356
else \
332-
echo "Files under $(TXT2CSTR_DIR) are up to date." ; \
357+
$(cgok) "Files under $(TXT2CSTR_DIR) are up to date." ; \
333358
fi
334-
if HAVE_RST2MAN
359+
endif
360+
335361
# man/*.in : committed for man pages to be genrated without rst2man
336362
# make clean-docs remove both man/*.in and docs/man/*.rst
363+
.PHONY: cg-clean-man-docs cg-force-man-docs check-genfile-man-docs
364+
cg-clean-man-docs:
365+
if BUILD_IN_GIT_REPO
366+
if HAVE_RST2MAN
337367
$(chkgen_verbose)$(MAKE) -C man clean-docs
368+
endif
369+
endif
370+
cg-force-man-docs: cg-clean-man-docs
371+
if BUILD_IN_GIT_REPO
372+
if HAVE_RST2MAN
338373
$(chkgen_verbose)$(MAKE) -C man man-in
374+
endif
375+
endif
376+
check-genfile-man-docs: $(recover_side_effects) cg-force-man-docs
377+
if BUILD_IN_GIT_REPO
378+
if HAVE_RST2MAN
339379
$(chkgen_verbose)if ! git diff --exit-code -- man; then \
340-
echo "Files under man/ are not up to date." ; \
341-
echo "Please execute 'make -C man man-in' and commit them." ; \
380+
$(cgerr) "Files under man/ are not up to date." ; \
381+
$(cgerr) "Please execute 'make -C man man-in' and commit them." ; \
342382
exit 1 ; \
343383
else \
344-
echo "Files under man are up to date." ; \
384+
$(cgok) "Files under man are up to date." ; \
345385
fi
386+
endif
387+
endif
388+
346389
# docs/man/*.rst : committed for Read the Docs
390+
.PHONY: cg-force-update-docs check-genfile-update-docs
391+
cg-force-update-docs: check-genfile-man-docs
392+
if BUILD_IN_GIT_REPO
393+
if HAVE_RST2MAN
347394
$(chkgen_verbose)$(MAKE) -C man update-docs
395+
endif
396+
endif
397+
398+
check-genfile-update-docs: cg-force-update-docs $(recover_side_effects)
399+
if BUILD_IN_GIT_REPO
400+
if HAVE_RST2MAN
348401
$(chkgen_verbose)if ! git diff --exit-code -- docs/man; then \
349-
echo "Files under docs/man/ are not up to date." ; \
350-
echo "Please execute 'make -C man update-docs' and commit them." ; \
402+
$(cgerr) "Files under docs/man/ are not up to date." ; \
403+
$(cgerr) "Please execute 'make -C man update-docs' and commit them." ; \
351404
exit 1 ; \
352405
else \
353-
echo "Files under docs/man are up to date." ; \
406+
$(cgok) "Files under docs/man are up to date." ; \
354407
fi
355408
endif
409+
endif
410+
356411
# win32/ctags_vs2013.vcxproj* : committed for win32 build without POSIX tools
357412
# regenerate files w/o out-of-source build and w/ GNU make
413+
.PHONY: cg-force-win32 check-genfile-win32
414+
cg-force-win32:
415+
if BUILD_IN_GIT_REPO
358416
$(chkgen_verbose)if test "$(top_srcdir)" = "$(top_builddir)" \
359417
&& ($(MAKE) --version) 2>/dev/null | grep -q GNU ; then \
360418
$(MAKE) -BC win32 ; \
361419
fi
420+
endif
421+
check-genfile-win32: cg-force-win32 $(recover_side_effects)
422+
if BUILD_IN_GIT_REPO
362423
$(chkgen_verbose)if ! git diff --exit-code -- win32; then \
363424
if test "$(SKIP_CHECKGEN_WIN32)" = "yes"; then \
364-
echo "Skip checking the files under win32." ; \
425+
$(cgskip) "Skip checking the files under win32." ; \
365426
exit 0 ; \
366427
else \
367-
echo "Files under win32/ are not up to date." ; \
368-
echo "Please execute 'make -BC win32' and commit them." ; \
428+
$(cgerr) "Files under win32/ are not up to date." ; \
429+
$(cgerr) "Please execute 'make -BC win32' and commit them." ; \
369430
exit 1 ; \
370431
fi \
371432
else \
372-
echo "Files under win32 are up to date." ; \
433+
$(cgok) "Files under win32 are up to date." ; \
373434
fi
374435
endif
375436

437+
.PHONY: check-genfile-add-docs-man
438+
check-genfile-add-docs-man: $(recover_side_effects)
439+
$(chkgen_verbose) {\
440+
(cd man; git ls-files .) | grep ctags-lang- | sed -e 's/\.in$$//' > TEMP-MAN-LS; \
441+
(cd docs/man; git ls-files .) | grep ctags-lang- > TEMP-DOCS-MAN-LS; \
442+
if ! diff TEMP-MAN-LS TEMP-DOCS-MAN-LS; then \
443+
$(cgerr) 'See "<" lines above.'; \
444+
$(cgerr) 'docs/man/*rst genereated from man/*rst.in are not in the git repo'; \
445+
$(cgerr) 'Please add the genereated file to the git repo'; \
446+
rm TEMP-MAN-LS TEMP-DOCS-MAN-LS; \
447+
exit 1 ; \
448+
else \
449+
rm TEMP-MAN-LS TEMP-DOCS-MAN-LS; \
450+
$(cgok) 'All rst files under docs/man are in our git repo'; \
451+
fi; \
452+
}
453+
454+
.PHONY: check-genfile-docs-man-pages-rst
455+
check-genfile-docs-man-pages-rst: $(recover_side_effects)
456+
$(chkgen_verbose) for f in $$( (cd docs/man; git ls-files .) | grep ctags-lang- ); do \
457+
if ! grep -q $$f docs/man-pages.rst; then \
458+
$(cgerr) "$$f is not found in docs/man-pages.rst"; \
459+
$(cgerr) "Please add $$f to docs/man-pages.rst"; \
460+
exit 1; \
461+
fi; \
462+
done; \
463+
$(cgok) "docs/man-pages.rst includes all ctags-lang-*.rst"
464+
465+
check-genfile: \
466+
check-genfile-optlib2c-srcs \
467+
check-genfile-txt2cstr-srcs \
468+
check-genfile-update-docs \
469+
check-genfile-add-docs-man \
470+
check-genfile-docs-man-pages-rst \
471+
check-genfile-win32
472+
376473
#
377474
# Test installation
378475
#

0 commit comments

Comments
 (0)