Project

General

Profile

« Previous | Next » 

Revision 624

input.Makefile: Deal with inputs without a DB file, tests, verifications, etc.

View differences:

input.Makefile
62 62

  
63 63
log = $*$(if $(n),.n=$(n),).log
64 64

  
65
import-%: maps/VegBIEN.%.csv _always
66
	-$(import_cmd)
67
import_cmd = (set -x; "time" env commit=1 $(map) $<) \
68
$(if $(n),,>>$(log)) 2>&1$(if $(n),|tee -a $(log))
69

  
65 70
logs := $(wildcard *.log)
66 71

  
67 72
rm_logs: _always
......
69 74

  
70 75
#####
71 76

  
77
ifneq ($(wildcard verify.ref*),)
78

  
72 79
verify: verify.ref verify.out _always
73 80
	$(DIFF) $(+_)
74 81

  
......
80 87
out_cmd = $(psqlAsBien) --no-align --field-separator='	' --pset=footer=off \
81 88
--pset=null=NULL <$< >$@
82 89

  
90
else
91
verify: _always ;
92
endif
93

  
83 94
#####
84 95

  
96
ifneq ($(wildcard test/),)
97

  
85 98
test: test/import.out _always
86 99
	$(DIFF) $(<:.out=.ref) $<
87 100

  
......
90 103
accept: _always
91 104
	$(CP) test/import.out test/import.ref
92 105

  
106
else
107
test: _always ;
108
endif
109

  
93 110
#####
94 111

  
112
# Each input type needs var $(mapEnv) and targets install, uninstall
113

  
95 114
dbFile := $(firstword $(wildcard src/*.sql))
96 115

  
97 116
ifneq ($(dbFile),)
......
112 131

  
113 132
####
114 133

  
115
import-%: maps/VegBIEN.%.csv _always
116
	-$(import_cmd)
117
import_cmd = (set -x; "time" env commit=1 $(map) $<) \
118
$(if $(n),,>>$(log)) 2>&1$(if $(n),|tee -a $(log))
119

  
120
####
121

  
122 134
test/import.out: $(vegbienMaps) _always
123 135
	env test=1 n=$(test_n) $(map) $(+_) >$@ 2>&1 || { e=$$?; cat $@; exit $$e;}
124 136
.PRECIOUS: test/import.out
125 137

  
126 138
####
127 139

  
128
# Each DB engine needs var $(dbAsBien) and targets db, rm_db
140
# Each DB engine needs vars $(dbEngine), $(dbAsBien) and targets db, rm_db
129 141

  
130 142
ifeq ($(dbEngineExt),my)
131 143

  
......
146 158
	echo "DROP DATABASE IF EXISTS $(db);"|$(mysqlAsRoot)
147 159
# ignore errors if grant not defined
148 160

  
149
####
161
###
150 162

  
151 163
else
152
$(error The DB engine extension "$(dbEngineExt)" for $(dbFile) must be one of\
153
the following: my, pg)
164
$(error The DB filename $(dbFile) must have the form <db_name>.{my|pg}.sql)
154 165
endif
155 166

  
156
#####
157

  
158 167
# Must come after dbEngine is set
159 168
mapEnv := in_engine=$(dbEngine) in_database=$(db)
160 169

  
170
####
171

  
161 172
else
162
$(error The src subdir must contain a file <db_name>.{my|pg}.sql)
173
mapEnv :=
174
install: _always ;
175
uninstall: _always ;
163 176
endif
164 177

  
165 178
#####

Also available in: Unified diff