<commit_before>SITE_PACKAGES = $(shell .build/venv/bin/python -c "import distutils; print(distutils.sysconfig.get_python_lib())" 2> /dev/null)
OL_JS_FILES = $(shell find node_modules/openlayers/src/ol -type f -name '*.js' 2> /dev/null)
NGEO_JS_FILES = $(shell find node_modules/ngeo/src -type f -name '*.js' 2> /dev/null)
APP_JS_FILES = $(shell find geoportailv3/static/js -type f -name '*.js')
APP_HTML_FILES = $(shell find geoportailv3/templates -type f -name '*.html')
LESS_FILES = $(shell find less -type f -name '*.less')
TEMPLATE_EXCLUDE += buildout .build CONST_alembic/script.py.mako print/templates/print.mako
FIND_OPTS = $(foreach ELEM, $(TEMPLATE_EXCLUDE),-path ./$(ELEM) -prune -o) -type f
TEMPLATE_FILES = $(shell find $(FIND_OPTS) -name "*.in" -print 2> /dev/null)
MAKO_FILES = $(shell find $(FIND_OPTS) -name "*.mako" -print 2> /dev/null)
JINJA_FILES = $(shell find $(FIND_OPTS) -name "*.jinja" -print 2> /dev/null)
VARS_FILES += CONST_vars.yaml

.PHONY: help
help:
	@echo "Usage: make <target>"
	@echo
	@echo "Main targets:"
	@echo
	@echo "- build              Build and configure the project"
	@echo "- check              Perform a number of checks on the code"
	@echo "- serve              Run the development server (pserve)"
	@echo "- clean              Remove generated files"
	@echo "- cleanall           Remove all the build artefacts"
	@echo
	@echo "Secondary targets:"
	@echo
	@echo "- build-web          Build the javascript and the css"
	@echo "- build-server       Build the files required by the server"
	@echo "- compile-catalog    Compile the translation catalog"
	@echo "- flake8             Run flake8 checker on the Python code"
	@echo "- lint               Check the JavaScript code with linters"
	@echo

.PHONY: build
build: $(SITE_PACKAGES)/geoportailv3.egg-link build-web build-server compile-catalog

.PHONY: check
check: flake8 lint build-web

.PHONY: clean
clean:
	rm -f .build/node_modules.timestamp
	rm -f .build/dev-requirements.timestamp
	rm -f .build/venv.timestamp
	rm -f geoportailv3/locale/*.pot
	rm -rf geoportailv3/static/build
	rm -f $(TEMPLATE_FILES:.in=)
	rm -f $(MAKO_FILES:.mako=)
	rm -f $(JINJA_FILES:.jinja=)

.PHONY: cleanall
cleanall: clean
	rm -rf .build
	rm -rf node_modules

.PHONY: build-web
build-web: geoportailv3/static/build/build.js geoportailv3/static/build/build.css geoportailv3/static/build/build.min.css

.PHONY: compile-catalog
compile-catalog: geoportailv3/static/build/locale/fr/geoportailv3.json

.PHONY: flake8
flake8: .build/venv/bin/flake8
	.build/venv/bin/flake8 geoportailv3

.PHONY: build-server
build-server: $(TEMPLATE_FILES:.in=) $(MAKO_FILES:.mako=) $(JINJA_FILES:.jinja=)

.PHONY: lint
lint: .build/venv/bin/gjslint .build/node_modules.timestamp .build/gjslint.timestamp .build/jshint.timestamp

.PHONY: serve
serve: build development.ini
	.build/venv/bin/pserve --reload --monitor-restart development.ini

$(TEMPLATE_FILES:.in=): $(TEMPLATE_FILES) .build/venv/bin/c2c-template ${VARS_FILES}
ifeq ($(origin VARS_FILE), undefined)
	echo "Error: the variable VARS_FILE is required."
	exit 1
endif
	.build/venv/bin/c2c-template --engine template --vars $(VARS_FILE) $@.in

$(MAKO_FILES:.mako=): $(MAKO_FILES) .build/venv/bin/c2c-template ${VARS_FILES}
ifeq ($(origin VARS_FILE), undefined)
	echo "Error: the variable VARS_FILE is required."
	exit 1
endif
	.build/venv/bin/c2c-template --engine mako --vars $(VARS_FILE) $@.mako

$(JINJA_FILES:.jinja=): $(JINJA_FILES) .build/venv/bin/c2c-template ${VARS_FILES}
ifeq ($(origin VARS_FILE), undefined)
	echo "Error: the variable VARS_FILE is required."
	exit 1
endif
	.build/venv/bin/c2c-template --engine jinja --vars $(VARS_FILE) $@.jinja

geoportailv3/closure/%.py: $(CLOSURE_LIBRARY_PATH)/closure/bin/build/%.py
	cp $< $@

geoportailv3/locale/geoportailv3-client.pot: $(APP_HTML_FILES)
	node tasks/extract-messages.js $^ > $@

geoportailv3/locale/fr/LC_MESSAGES/geoportailv3-client.po: geoportailv3/locale/geoportailv3-client.pot
	cd geoportailv3/locale && msgmerge --update fr/LC_MESSAGES/geoportailv3-client.po geoportailv3-client.pot

geoportailv3/static/build/build.js: build.json $(OL_JS_FILES) $(NGEO_JS_FILES) $(APP_JS_FILES) .build/externs/angular-1.3.js .build/externs/angular-1.3-q.js .build/externs/angular-1.3-http-promise.js .build/node_modules.timestamp
	mkdir -p $(dir $@)
	node tasks/build.js $< $@

geoportailv3/static/build/build.min.css: $(LESS_FILES) .build/node_modules.timestamp
	mkdir -p $(dir $@)
	./node_modules/.bin/lessc --clean-css less/geoportailv3.less > $@

geoportailv3/static/build/build.css: $(LESS_FILES) .build/node_modules.timestamp
	mkdir -p $(dir $@)
	./node_modules/.bin/lessc less/geoportailv3.less > $@

geoportailv3/static/build/locale/fr/geoportailv3.json: geoportailv3/locale/fr/LC_MESSAGES/geoportailv3-client.po
	mkdir -p $(dir $@)
	node tasks/compile-catalog $< > $@

.build/externs/angular-1.3.js:
	mkdir -p $(dir $@)
	wget -O $@ https://raw.githubusercontent.com/google/closure-compiler/master/contrib/externs/angular-1.3.js
	touch $@

.build/externs/angular-1.3-q.js:
	mkdir -p $(dir $@)
	wget -O $@ https://raw.githubusercontent.com/google/closure-compiler/master/contrib/externs/angular-1.3-q.js
	touch $@

.build/externs/angular-1.3-http-promise.js:
	mkdir -p $(dir $@)
	wget -O $@ https://raw.githubusercontent.com/google/closure-compiler/master/contrib/externs/angular-1.3-http-promise.js
	touch $@

.build/node_modules.timestamp: package.json
	mkdir -p $(dir $@)
	npm install<commit_msg>Don't need to redirect output for lessc command<commit_after>SITE_PACKAGES = $(shell .build/venv/bin/python -c "import distutils; print(distutils.sysconfig.get_python_lib())" 2> /dev/null)
OL_JS_FILES = $(shell find node_modules/openlayers/src/ol -type f -name '*.js' 2> /dev/null)
NGEO_JS_FILES = $(shell find node_modules/ngeo/src -type f -name '*.js' 2> /dev/null)
APP_JS_FILES = $(shell find geoportailv3/static/js -type f -name '*.js')
APP_HTML_FILES = $(shell find geoportailv3/templates -type f -name '*.html')
LESS_FILES = $(shell find less -type f -name '*.less')
TEMPLATE_EXCLUDE += buildout .build CONST_alembic/script.py.mako print/templates/print.mako
FIND_OPTS = $(foreach ELEM, $(TEMPLATE_EXCLUDE),-path ./$(ELEM) -prune -o) -type f
TEMPLATE_FILES = $(shell find $(FIND_OPTS) -name "*.in" -print 2> /dev/null)
MAKO_FILES = $(shell find $(FIND_OPTS) -name "*.mako" -print 2> /dev/null)
JINJA_FILES = $(shell find $(FIND_OPTS) -name "*.jinja" -print 2> /dev/null)
VARS_FILES += CONST_vars.yaml

.PHONY: help
help:
	@echo "Usage: make <target>"
	@echo
	@echo "Main targets:"
	@echo
	@echo "- build              Build and configure the project"
	@echo "- check              Perform a number of checks on the code"
	@echo "- serve              Run the development server (pserve)"
	@echo "- clean              Remove generated files"
	@echo "- cleanall           Remove all the build artefacts"
	@echo
	@echo "Secondary targets:"
	@echo
	@echo "- build-web          Build the javascript and the css"
	@echo "- build-server       Build the files required by the server"
	@echo "- compile-catalog    Compile the translation catalog"
	@echo "- flake8             Run flake8 checker on the Python code"
	@echo "- lint               Check the JavaScript code with linters"
	@echo

.PHONY: build
build: $(SITE_PACKAGES)/geoportailv3.egg-link build-web build-server compile-catalog

.PHONY: check
check: flake8 lint build-web

.PHONY: clean
clean:
	rm -f .build/node_modules.timestamp
	rm -f .build/dev-requirements.timestamp
	rm -f .build/venv.timestamp
	rm -f geoportailv3/locale/*.pot
	rm -rf geoportailv3/static/build
	rm -f $(TEMPLATE_FILES:.in=)
	rm -f $(MAKO_FILES:.mako=)
	rm -f $(JINJA_FILES:.jinja=)

.PHONY: cleanall
cleanall: clean
	rm -rf .build
	rm -rf node_modules

.PHONY: build-web
build-web: geoportailv3/static/build/build.js geoportailv3/static/build/build.css geoportailv3/static/build/build.min.css

.PHONY: compile-catalog
compile-catalog: geoportailv3/static/build/locale/fr/geoportailv3.json

.PHONY: flake8
flake8: .build/venv/bin/flake8
	.build/venv/bin/flake8 geoportailv3

.PHONY: build-server
build-server: $(TEMPLATE_FILES:.in=) $(MAKO_FILES:.mako=) $(JINJA_FILES:.jinja=)

.PHONY: lint
lint: .build/venv/bin/gjslint .build/node_modules.timestamp .build/gjslint.timestamp .build/jshint.timestamp

.PHONY: serve
serve: build development.ini
	.build/venv/bin/pserve --reload --monitor-restart development.ini

$(TEMPLATE_FILES:.in=): $(TEMPLATE_FILES) .build/venv/bin/c2c-template ${VARS_FILES}
ifeq ($(origin VARS_FILE), undefined)
	echo "Error: the variable VARS_FILE is required."
	exit 1
endif
	.build/venv/bin/c2c-template --engine template --vars $(VARS_FILE) $@.in

$(MAKO_FILES:.mako=): $(MAKO_FILES) .build/venv/bin/c2c-template ${VARS_FILES}
ifeq ($(origin VARS_FILE), undefined)
	echo "Error: the variable VARS_FILE is required."
	exit 1
endif
	.build/venv/bin/c2c-template --engine mako --vars $(VARS_FILE) $@.mako

$(JINJA_FILES:.jinja=): $(JINJA_FILES) .build/venv/bin/c2c-template ${VARS_FILES}
ifeq ($(origin VARS_FILE), undefined)
	echo "Error: the variable VARS_FILE is required."
	exit 1
endif
	.build/venv/bin/c2c-template --engine jinja --vars $(VARS_FILE) $@.jinja

geoportailv3/closure/%.py: $(CLOSURE_LIBRARY_PATH)/closure/bin/build/%.py
	cp $< $@

geoportailv3/locale/geoportailv3-client.pot: $(APP_HTML_FILES)
	node tasks/extract-messages.js $^ > $@

geoportailv3/locale/fr/LC_MESSAGES/geoportailv3-client.po: geoportailv3/locale/geoportailv3-client.pot
	cd geoportailv3/locale && msgmerge --update fr/LC_MESSAGES/geoportailv3-client.po geoportailv3-client.pot

geoportailv3/static/build/build.js: build.json $(OL_JS_FILES) $(NGEO_JS_FILES) $(APP_JS_FILES) .build/externs/angular-1.3.js .build/externs/angular-1.3-q.js .build/externs/angular-1.3-http-promise.js .build/node_modules.timestamp
	mkdir -p $(dir $@)
	node tasks/build.js $< $@

geoportailv3/static/build/build.min.css: $(LESS_FILES) .build/node_modules.timestamp
	mkdir -p $(dir $@)
	./node_modules/.bin/lessc --clean-css less/geoportailv3.less $@

geoportailv3/static/build/build.css: $(LESS_FILES) .build/node_modules.timestamp
	mkdir -p $(dir $@)
	./node_modules/.bin/lessc less/geoportailv3.less $@

geoportailv3/static/build/locale/fr/geoportailv3.json: geoportailv3/locale/fr/LC_MESSAGES/geoportailv3-client.po
	mkdir -p $(dir $@)
	node tasks/compile-catalog $< > $@

.build/externs/angular-1.3.js:
	mkdir -p $(dir $@)
	wget -O $@ https://raw.githubusercontent.com/google/closure-compiler/master/contrib/externs/angular-1.3.js
	touch $@

.build/externs/angular-1.3-q.js:
	mkdir -p $(dir $@)
	wget -O $@ https://raw.githubusercontent.com/google/closure-compiler/master/contrib/externs/angular-1.3-q.js
	touch $@

.build/externs/angular-1.3-http-promise.js:
	mkdir -p $(dir $@)
	wget -O $@ https://raw.githubusercontent.com/google/closure-compiler/master/contrib/externs/angular-1.3-http-promise.js
	touch $@

.build/node_modules.timestamp: package.json
	mkdir -p $(dir $@)
	npm install
{'fraction_non_alphanumeric': 0.15077343039126478, 'fraction_numerical': 0.012738853503184714, 'mean_word_length': 3.9643179765130983, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 23, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6560645', 'n_tokens_mistral': 4425, 'n_tokens_neox': 4229, 'n_words': 874}