2015-09-25 21:28:27 +08:00
|
|
|
NAME=zsh-syntax-highlighting
|
|
|
|
|
2015-10-19 14:44:02 +08:00
|
|
|
INSTALL?=install -c
|
2015-09-25 21:28:27 +08:00
|
|
|
PREFIX?=/usr/local
|
2015-11-17 03:14:19 +08:00
|
|
|
SHARE_DIR?=$(DESTDIR)$(PREFIX)/share/$(NAME)
|
2015-11-17 03:49:36 +08:00
|
|
|
DOC_DIR?=$(DESTDIR)$(PREFIX)/share/doc/$(NAME)
|
tests: Set ZSH explicitly make sure PATH is exported
'env -i' clears the complete environment, including PATH. In that
case, on most platforms, when excuting commands without PATH being
set, /usr/bin and /bin are searched, e.g. on Linux:
$ strace env -i asdf |& grep asdf
execve("/usr/bin/env", ["env", "-i", "asdf"], 0x7ffc3e3c0890 /* 27 vars */) = 0
execve("/bin/asdf", ["asdf"], 0x55be2da090d0 /* 0 vars */) = -1 ENOENT (No such file or directory)
execve("/usr/bin/asdf", ["asdf"], 0x55be2da090d0 /* 0 vars */) = -1 ENOENT (No such file or directory)
write(2, "\342\200\230asdf\342\200\231", 10‘asdf’) = 10
Howver, this does not hold on every platform. E.g. on Cygwin, so
such fallback paths are searched:
$ strace env -i asdf |& grep asdf
37 25736 [main] env 3516 build_argv: argv[2] = 'asdf'
643 30373 [main] env 3516 find_exec: find_exec (asdf)
35 30408 [main] env 3516 find_exec: (null) = find_exec (asdf)
36 30444 [main] env 3516 spawnve: spawnve (, asdf, 0x10040B000)
‘asdf’ 199 53601 [main] env 3516 write: 10 = write(2, 0x10040B040, 10)
$ env -i zsh
env: ‘zsh’: No such file or directory
Therefore, we need to make sure that the default PATH is exported
from tests/test-highlighting.zsh.
2020-08-10 03:55:43 +08:00
|
|
|
ZSH?="`which zsh`" # zsh binary to run tests with
|
2015-09-25 21:28:27 +08:00
|
|
|
|
2015-10-19 15:08:21 +08:00
|
|
|
all:
|
2015-11-17 13:58:42 +08:00
|
|
|
cd docs && \
|
|
|
|
cp highlighters.md all.md && \
|
|
|
|
printf '\n\nIndividual highlighters documentation\n=====================================' >> all.md && \
|
|
|
|
for doc in highlighters/*.md; do printf '\n\n'; cat "$$doc"; done >> all.md
|
2015-10-19 15:08:21 +08:00
|
|
|
|
2015-11-17 13:58:42 +08:00
|
|
|
install: all
|
2015-09-25 21:28:27 +08:00
|
|
|
$(INSTALL) -d $(SHARE_DIR)
|
2015-11-17 03:49:36 +08:00
|
|
|
$(INSTALL) -d $(DOC_DIR)
|
2015-11-18 10:14:03 +08:00
|
|
|
cp .version zsh-syntax-highlighting.zsh $(SHARE_DIR)
|
|
|
|
cp COPYING.md README.md changelog.md $(DOC_DIR)
|
2017-08-01 07:16:37 +08:00
|
|
|
sed -e '1s/ .*//' -e '/^\[build-status-[a-z]*\]: /d' < README.md > $(DOC_DIR)/README.md
|
2015-10-19 15:35:12 +08:00
|
|
|
if [ x"true" = x"`git rev-parse --is-inside-work-tree 2>/dev/null`" ]; then \
|
|
|
|
git rev-parse HEAD; \
|
|
|
|
else \
|
|
|
|
cat .revision-hash; \
|
|
|
|
fi > $(SHARE_DIR)/.revision-hash
|
2015-11-17 03:49:36 +08:00
|
|
|
:
|
|
|
|
# The [ -e ] check below is to because sh evaluates this with (the moral
|
|
|
|
# equivalent of) NONOMATCH in effect, and highlighters/*.zsh has no matches.
|
|
|
|
for dirname in highlighters highlighters/*/ ; do \
|
2015-11-18 09:48:53 +08:00
|
|
|
$(INSTALL) -d $(SHARE_DIR)/"$$dirname"; \
|
2015-11-18 10:14:03 +08:00
|
|
|
for fname in "$$dirname"/*.zsh ; do [ -e "$$fname" ] && cp "$$fname" $(SHARE_DIR)"/$$dirname"; done; \
|
2015-11-17 03:49:36 +08:00
|
|
|
done
|
2015-11-17 13:58:42 +08:00
|
|
|
cp -R docs/* $(DOC_DIR)
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -f docs/all.md
|
2015-09-26 10:29:51 +08:00
|
|
|
|
|
|
|
test:
|
2017-08-10 02:42:35 +08:00
|
|
|
@$(ZSH) -fc 'echo ZSH_PATCHLEVEL=$$ZSH_PATCHLEVEL'
|
2015-10-20 08:31:40 +08:00
|
|
|
@result=0; \
|
|
|
|
for test in highlighters/*; do \
|
2015-09-26 10:29:51 +08:00
|
|
|
if [ -d $$test/test-data ]; then \
|
|
|
|
echo "Running test $${test##*/}"; \
|
2020-03-16 02:10:18 +08:00
|
|
|
env -i QUIET=$$QUIET $${TERM:+"TERM=$$TERM"} $(ZSH) -f tests/test-highlighting.zsh "$${test##*/}"; \
|
2015-10-19 14:36:42 +08:00
|
|
|
: $$(( result |= $$? )); \
|
2015-09-26 10:29:51 +08:00
|
|
|
fi \
|
2015-10-27 17:55:36 +08:00
|
|
|
done; \
|
2015-10-20 08:31:40 +08:00
|
|
|
exit $$result
|
2015-10-20 08:26:43 +08:00
|
|
|
|
2016-01-03 05:22:01 +08:00
|
|
|
quiet-test:
|
|
|
|
$(MAKE) test QUIET=y
|
|
|
|
|
2015-10-27 15:46:51 +08:00
|
|
|
perf:
|
|
|
|
@result=0; \
|
|
|
|
for test in highlighters/*; do \
|
|
|
|
if [ -d $$test/test-data ]; then \
|
|
|
|
echo "Running test $${test##*/}"; \
|
|
|
|
$(ZSH) -f tests/test-perfs.zsh "$${test##*/}"; \
|
|
|
|
: $$(( result |= $$? )); \
|
|
|
|
fi \
|
|
|
|
done; \
|
|
|
|
exit $$result
|
|
|
|
|
2015-11-17 13:58:42 +08:00
|
|
|
.PHONY: all install clean test perf
|