Revision 1955
Added by Aaron Marcuse-Kubitza almost 13 years ago
input.Makefile | ||
---|---|---|
106 | 106 |
$(call addDirWithIgnore,test,$$'*.out\n*.xml') |
107 | 107 |
$(call addDirWithIgnore,verify,$$'*.out') |
108 | 108 |
|
109 |
##### Sources |
|
110 |
|
|
111 |
inputFiles := $(wildcard $(exts:%=src/*.%)) |
|
112 |
ifeq ($(inputFiles),) |
|
113 |
dbExport := $(firstword $(wildcard src/db.*.sql)) |
|
114 |
endif |
|
115 |
|
|
116 |
srcs = $(shell $(bin)/sort_filenames $(wildcard $(exts:%=src/*.$*.%))) |
|
117 |
isCsv = $(if $(srcs),$(if $(filter %.xml,$(srcs)),,1)) |
|
118 |
# true if $(srcs) non-empty and contains no *.xml |
|
119 |
catSrcs = $(bin)/cat$(if $(isCsv),_csv) $(srcs) |
|
120 |
withCatSrcs = $(catSrcs:$(bin)/%=$(bin)/with_%) -- |
|
121 |
|
|
122 |
# Usage: `make {--silent|-s} cat` (removes echoed make commands) |
|
123 |
cat: $(addprefix cat-,$(tables)) _always ; |
|
124 |
|
|
125 |
cat-%: _always |
|
126 |
$(catSrcs) |
|
127 |
|
|
109 | 128 |
##### Existing maps discovery |
110 | 129 |
|
111 | 130 |
srcMap := maps/src.%.csv |
... | ... | |
149 | 168 |
echo 'DROP SCHEMA IF EXISTS "$(datasrc)" CASCADE;'|$(psqlAsBien) |
150 | 169 |
|
151 | 170 |
import/install-%: _always |
152 |
$(import_install_table)
|
|
153 |
import_install_table = (prefix=; . $(bin)/vegbien_dest; env schema=$(datasrc)\
|
|
171 |
$(if $(isCsv),$(import_install_))
|
|
172 |
import_install_ = (prefix=; . $(bin)/vegbien_dest; "time" env schema=$(datasrc)\
|
|
154 | 173 |
table=$* $(bin)/csv2db $(catSrcs)$(if $(log), &>import/install.log)) |
155 | 174 |
|
156 |
##### Sources |
|
157 |
|
|
158 |
srcs = $(shell $(bin)/sort_filenames $(wildcard $(exts:%=src/*.$*.%))) |
|
159 |
isXml = $(filter %.xml,$(firstword $(srcs))) |
|
160 |
catSrcs = $(bin)/cat$(if $(isXml),,_csv) $(srcs) |
|
161 |
withCatSrcs = $(catSrcs:$(bin)/%=$(bin)/with_%) -- |
|
162 |
|
|
163 |
# Usage: `make {--silent|-s} cat` (removes echoed make commands) |
|
164 |
cat: $(addprefix cat-,$(tables)) _always ; |
|
165 |
|
|
166 |
cat-%: _always |
|
167 |
$(catSrcs) |
|
168 |
|
|
169 | 175 |
##### Maps building |
170 | 176 |
|
171 | 177 |
# Maps to (try to) build are added to one of these |
... | ... | |
178 | 184 |
|
179 | 185 |
# Autogen src maps with known table names |
180 | 186 |
maps/src.%.csv: # no prereqs so only built if doesn't exist |
181 |
$(if $(srcs),$(if $(isXml),,$(mkSrcMap)))
|
|
187 |
$(if $(isCsv),$(mkSrcMap))
|
|
182 | 188 |
# only build if CSV srcs exist for that table name |
183 | 189 |
# Try all table names |
184 | 190 |
createOnlyMaps += $(tablesSort:%=maps/src.%.csv) |
... | ... | |
236 | 242 |
|
237 | 243 |
##### Mapping |
238 | 244 |
|
239 |
inputFiles := $(wildcard $(exts:%=src/*.%)) |
|
240 |
ifeq ($(inputFiles),) |
|
241 |
dbExport := $(firstword $(wildcard src/db.*.sql)) |
|
242 |
endif |
|
243 |
|
|
244 | 245 |
+maps = $(filter maps/% $(mappings)/%,$(+_)) |
245 | 246 |
<in = $(firstword $(filter-out $(+maps),$(+_))) |
246 | 247 |
map = $(if $(<in),<$(<in),\ |
Also available in: Unified diff
input.Makefile: Staging tables: import/install-%: Only install staging table if input contains only CSV sources. Changed $(isXml) to $(isCsv) (negated) everywhere because rules almost always only run something if input contains only CSV sources, rather than if input contains XML sources.