Skip to content

Commit

Permalink
Fix Makefile duplicate runs (#923)
Browse files Browse the repository at this point in the history
Make sure that core targets (i.e. part of the `all` target like build-sql and build yaml files) do not run multiple times if they already exist.

Makefile for some reason does not like it when a real target depends on a PHONY target, and re-runs it. I added an `if` statement to skip building targets if their result already exists.
  • Loading branch information
nyurik committed Jun 8, 2020
1 parent 6457419 commit 60a3e1e
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -192,24 +192,31 @@ help:

.PHONY: init-dirs
init-dirs:
@mkdir -p build/sql
@mkdir -p build/sql/parallel
@mkdir -p build/openmaptiles.tm2source
@mkdir -p data/borders
@mkdir -p cache

build/openmaptiles.tm2source/data.yml: init-dirs
mkdir -p build/openmaptiles.tm2source
ifeq (,$(wildcard build/openmaptiles.tm2source/data.yml))
$(DOCKER_COMPOSE) run $(DC_OPTS) openmaptiles-tools generate-tm2source openmaptiles.yaml --host="postgres" --port=5432 --database="openmaptiles" --user="openmaptiles" --password="openmaptiles" > $@
endif

build/mapping.yaml: init-dirs
ifeq (,$(wildcard build/mapping.yaml))
$(DOCKER_COMPOSE) run $(DC_OPTS) openmaptiles-tools generate-imposm3 openmaptiles.yaml > $@
endif

.PHONY: build-sql
build-sql: init-dirs
ifeq (,$(wildcard build/sql/run_last.sql))
@mkdir -p build/sql/parallel
$(DOCKER_COMPOSE) run $(DC_OPTS) openmaptiles-tools bash -c \
'generate-sql openmaptiles.yaml --dir ./build/sql \
&& generate-sqltomvt openmaptiles.yaml \
--key --gzip --postgis-ver 3.0.1 \
--function --fname=getmvt >> "./build/sql/run_last.sql"'
--function --fname=getmvt >> ./build/sql/run_last.sql'
endif

.PHONY: clean
clean:
Expand Down

0 comments on commit 60a3e1e

Please sign in to comment.