-
Notifications
You must be signed in to change notification settings - Fork 8
/
Makefile
125 lines (97 loc) · 3.45 KB
/
Makefile
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
125
BUILD_DIR ?= .build
LANGUAGES = fr de it
MO_FILES = $(addprefix c2cgeoform/locale/, $(addsuffix /LC_MESSAGES/c2cgeoform.mo, $(LANGUAGES)))
PO_FILES = $(addprefix c2cgeoform/locale/, $(addsuffix /LC_MESSAGES/c2cgeoform.po, $(LANGUAGES)))
L10N_SOURCE_FILES += c2cgeoform/__init__.py c2cgeoform/models.py c2cgeoform/views/abstract_views.py
L10N_SOURCE_FILES += $(shell find c2cgeoform/templates/ -type f -name '*.pt')
L10N_SOURCE_FILES += $(shell find c2cgeoform/templates/ -type f -name '*.jinja2')
.PHONY: all
all: help
.PHONY: help
help:
@echo "Usage: make <target>"
@echo
@echo "Possible targets:"
@echo
@echo "- build Install c2cgeoform"
@echo "- initdb (Re-)initialize the database"
@echo "- check Check the code with prospector"
@echo "- test Run the unit tests"
@echo "- dist Build a source distribution"
@echo "- compile-catalog Compile message catalog"
@echo
.PHONY: build
build: docker-build-db poetry compile-catalog c2cgeoform/static/dist/index.js
.PHONY: check
check: prospector
.PHONY: poetry
poetry:
poetry install --with=dev --extras=psycopg2-binary
.PHONY: prospector
prospector: poetry
poetry run prospector --output-format=pylint --die-on-tool-error
.build/node_modules.timestamp: c2cgeoform/static/package.json
mkdir -p $(dir $@)
cd c2cgeoform/static/ && npm install
touch $@
c2cgeoform/static/dist/index.js: .build/node_modules.timestamp c2cgeoform/static/src/*
cd c2cgeoform/static/ && npm run build
.PHONY: test
test: test_c2cgeoform test_c2cgeoform_demo
.PHONY: test_c2cgeoform
test_c2cgeoform: build poetry
docker compose up -d db
poetry run pytest -vvv
.PHONY: test_c2cgeoform_demo
test_c2cgeoform_demo: $(BUILD_DIR)/c2cgeoform_demo
docker compose up -d db
make -C $(BUILD_DIR)/c2cgeoform_demo -f ./dev.mk test
$(BUILD_DIR)/c2cgeoform_demo: build c2cgeoform/scaffolds/c2cgeoform c2cgeoform_demo_dev.mk
rm -rf $@
poetry run cookiecutter --no-input --output-dir=$(dir $@) c2cgeoform/scaffolds/c2cgeoform/ \
project=c2cgeoform_demo package=c2cgeoform_demo \
package_logger=c2cgeoform_demo pyramid_docs_branch=master
sed -i 's#@localhost:5432/c2cgeoform_demo#@localhost:54321/c2cgeoform_demo_tests#g' $@/development.ini
cp c2cgeoform_demo_dev.mk $@/dev.mk
.PHONY: update-catalog
update-catalog: poetry
poetry run pot-create -c lingua.cfg --keyword _ -o c2cgeoform/locale/c2cgeoform.pot $(L10N_SOURCE_FILES)
make $(PO_FILES)
c2cgeoform/locale/%/LC_MESSAGES/c2cgeoform.po: c2cgeoform/locale/c2cgeoform.pot
msgmerge --update $@ $<
.PHONY: compile-catalog
compile-catalog: $(MO_FILES)
.PHONY: docs
docs: poetry
make -C docs html
%.mo: %.po
msgfmt $< --output-file=$@
.PHONY: clean
clean:
rm -f $(MO_FILES)
rm -rf .build/node_modules.timestamp
rm -rf c2cgeoform/static/dist
rm -rf dist
rm -rf docs/_build
.PHONY: cleanall
cleanall: clean
poetry env remove --all
rm -rf c2cgeoform/static/node_modules
.PHONY: initdb
initdb: $(BUILD_DIR)/c2cgeoform_demo
docker compose up -d db
sleep 1
make -C $(BUILD_DIR)/c2cgeoform_demo -f dev.mk initdb
.PHONY: webpack-dev
webpack-dev:
cd c2cgeoform/static/ && ./node_modules/.bin/webpack -d -w
.PHONY: serve
serve: build $(BUILD_DIR)/c2cgeoform_demo
docker compose up -d db
make -C $(BUILD_DIR)/c2cgeoform_demo -f dev.mk serve
.PHONY: modwsgi
modwsgi: $(BUILD_DIR)/c2cgeoform_demo
make -C $(BUILD_DIR)/c2cgeoform_demo modwsgi
# Docker builds
docker-build-db:
docker build -t camptocamp/c2cgeoform-db:latest db