Project

General

Profile

« Previous | Next » 

Revision 718

input.Makefile: Import all tables at once by default

View differences:

input.Makefile
21 21
vegxMaps += $(filter-out $(vegxMaps),$(wildcard maps/VegX.*.csv))
22 22
tables := $(vegxMaps:maps/VegX.%.csv=%)
23 23
vegbienMaps := $(subst VegX.,VegBIEN.,$(vegxMaps))
24
dbFile := $(firstword $(wildcard src/db.*.sql))
24 25

  
25 26
+maps = $(filter maps/%,$(+_))
26 27
+in = $(filter-out maps/%,$(+_))
......
68 69

  
69 70
#####
70 71

  
71
import: _always $(addprefix import-,$(tables)) verify ;
72
ifneq ($(wildcard $(dbFile)),)
72 73

  
73
log = $*$(if $(n),.n=$(n),).log
74
import: _always import-all verify ;
74 75

  
75
import-%: maps/VegBIEN.%.csv _always
76
	-$(import_cmd)
76
log = $(@:-all=)$(if $(n),.n=$(n),).log
77
import = -(set -x; "time" env commit=1 $(map2db) $(+_)) \
78
$(if $(n),,>>$(log)) 2>&1$(if $(n),|tee -a $(log))
77 79
# ignore import errors, which are often benign (e.g. invalid date format)
78
import_cmd = (set -x; "time" env commit=1 $(import) $<) \
79
$(if $(n),,>>$(log)) 2>&1$(if $(n),|tee -a $(log))
80 80

  
81
import-all: $(vegbienMaps) _always
82
	$(import)
83

  
84
import-%: maps/VegBIEN.%.csv _always
85
	$(import)
86

  
81 87
logs := $(wildcard *.log)
82 88

  
83 89
rm_logs: _always
84 90
	$(RM) $(logs)
85 91

  
92
else
93
import: _always ;
94
import-%: _always ;
95
rm_logs: _always ;
96
endif
97

  
86 98
#####
87 99

  
88 100
ifneq ($(wildcard verify.ref*),)
......
135 147
	$(call test,$(root)/map)
136 148

  
137 149
test/import.out: $(vegbienMaps) _always
138
	$(call test,$(import))
150
	$(call test,$(map2db))
139 151

  
140 152
# Accepts a test output: make <test_output_path>-ok
141 153
%-ok: _always
......
149 161

  
150 162
# Each input type needs var $(mapEnv) and targets install, uninstall
151 163

  
152
dbFile := $(firstword $(wildcard src/db.*.sql))
153

  
154 164
ifneq ($(dbFile),)
155 165

  
156 166
dbEngineExt := $(subst .,,$(suffix $(basename $(notdir $(dbFile)))))
......
211 221

  
212 222
# Must come after mapEnv is set
213 223
map := $(if $(mapEnv),env $(mapEnv) ,)$(root)/map
214
import := env out_database=vegbien $(map)
224
map2db := env out_database=vegbien $(map)

Also available in: Unified diff