File: Makefile

package info (click to toggle)
rg-el 2.4.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 700 kB
  • sloc: lisp: 3,746; python: 167; makefile: 106
file content (124 lines) | stat: -rw-r--r-- 3,525 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
EMACS_VERSION=29-4
DOCKER_IMAGE=rg.el-test-emacs-$(EMACS_VERSION)

ifdef USE_DOCKER
DOCKER_WRAPPER=docker run --workdir /app --mount type=bind,source="$(PWD)",target=/app $(DOCKER_IMAGE)
%: run_make
	@:

.PHONY: run_make
run_make:
	$(DOCKER_WRAPPER) $(MAKE) EMACS_VERSION=$(EMACS_VERSION) $(MAKECMDGOALS)

else  # actual Makefile

PKG_NAME = $(shell cask info | head -1 | cut -f2 -d" ")
PKG_VERSION = $(shell cask version)
PKG_FULL_NAME = $(PKG_NAME)-$(PKG_VERSION)
SOURCES = $(shell cask files)
OBJECTS = $(SOURCES:.el=.elc)
STYLE_CHECK= -L test -L . -l test/style-check.el
DISABLE_DEFALIAS_CHECK= --eval "(defun package-lint--check-defalias (prefix def))"

# This setup testing similar to ert-runner for legacy reasons.
# All files under test/ that matches the source files.
TEST_FILES = $(filter $(patsubst %,test/%-test.el, $(SOURCES)), $(wildcard test/*.el))
# Load test-helper.el first, then all test files.
LOAD_TEST_FILES = -L test -l test-helper $(patsubst %,-l %,$(TEST_FILES:test/%.el=%))

SPHINX-BUILD = sphinx-build
DOC_DIR = docs
ORG_DOCS= $(wildcard $(DOC_DIR)/*.org)
RST_OUT_DIR = $(DOC_DIR)/rst
RST_DOCS = $(addprefix $(RST_OUT_DIR)/,$(patsubst %.org,%.rst,$(notdir $(ORG_DOCS))))

all: deps test

docker-build:
	docker build --build-arg EMACS_VERSION=$(EMACS_VERSION) -t $(DOCKER_IMAGE) .

test: ert-test style-check package-lint build-test package-test

build-test: clean build
	cask clean-elc

$(RST_DOCS): | $(RST_OUT_DIR)

$(RST_OUT_DIR):
	mkdir $(RST_OUT_DIR)

$(RST_OUT_DIR)/%.rst: docs/%.org
	RST_OUT_DIR=$(abspath $(RST_OUT_DIR)) cask emacs --batch -Q -L . -l docs/org-bootstrap.el $< --funcall rg-export-to-rst

rst: $(RST_DOCS)

html: rst
	$(SPHINX-BUILD) -b html $(RST_OUT_DIR) $(RST_OUT_DIR)/_build/html

info: rst
	$(SPHINX-BUILD) -b texinfo $(RST_OUT_DIR) $(RST_OUT_DIR)/_build/info
	make -C $(RST_OUT_DIR)/_build/info
	cp $(RST_OUT_DIR)/_build/info/rgel.info .

docs: html

clean-docs:
	rm $(RST_OUT_DIR)/*.rst
	make -C $(RST_OUT_DIR) clean

clean:
	cask clean-elc

build: $(OBJECTS)

%.elc: %.el
	cask emacs -batch -Q -L . -eval "(progn (setq byte-compile-error-on-warn t) (batch-byte-compile))" $<

package-test:
	-@rm -r dist 2> /dev/null || true
	-@rm -r /tmp/$(PKG_FULL_NAME)-elpa 2> /dev/null || true
	cask package
	PKG_FULL_NAME=$(PKG_FULL_NAME) emacs -batch -Q -l test/package-bootstrap.el \
		--eval "(progn (package-install-file (expand-file-name \"dist/$(PKG_FULL_NAME).tar\")) (rg \"rg\" \"elisp\" \"/tmp/$(PKG_FULL_NAME)-elpa\"))"

ifeq ($(findstring 26,$(EMACS_VERSION)), 26)
style-check:
package-lint:
else
style-check:
	cask emacs -batch -Q $(STYLE_CHECK) -f run-emacs-lisp-flycheck-and-exit $(SOURCES)
package-lint:
	cask emacs -batch -Q $(STYLE_CHECK) $(DISABLE_DEFALIAS_CHECK) -f run-package-lint-and-exit rg.el
endif


unit-test:
	cask emacs --batch -l ert $(LOAD_TEST_FILES) --eval="(ert-run-tests-batch-and-exit \"rg-unit\")"

integration-test:
	cask emacs --batch -l ert $(LOAD_TEST_FILES) --eval="(ert-run-tests-batch-and-exit \"rg-integration\")"

ert-test:
	cask emacs --batch -l ert $(LOAD_TEST_FILES) -f ert-run-tests-batch-and-exit

ifeq ($(findstring 26,$(EMACS_VERSION)), 26)
deps_prepare:
	cp Cask /tmp/Cask
	sed -i '/flycheck/d' Cask

deps_cleanup:
	cp /tmp/Cask Cask

else
deps_prepare:
deps_cleanup:
endif

deps_execute:
	cask install

deps: deps_prepare deps_execute deps_cleanup

.PHONY: all test build-test clean clean-docs package-test style-check package-lint unit-test integration-test ert-test deps deps_execute deps_prepare deps_cleanup docs

endif