forked from tcgoetz/GarminDB
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
293 lines (204 loc) · 6.73 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
#
# This Makefile handles downloading data from Garmin Connect and generating SQLite DB files from that data. The Makefile targets handle the dependaancies
# between downloading and geenrating varies types of data. It wraps the core Python scripts and runs them with appropriate parameters.
#
export PROJECT_BASE=$(CURDIR)
include defines.mk
#
# Master targets
#
all: update_dbs
# install all needed code
setup_repo: $(CONF_DIR)/GarminConnectConfig.json $(PROJECT_BASE)/.venv submodules_update
setup_install: deps devdeps install_all
setup: setup_repo setup_install
setup_pipeline: devdeps install_all
clean_dbs: clean_mshealth_db clean_fitbit_db clean_garmin_dbs
# Use for an intial download or when the start dates have been changed.
download_all: download_all_garmin
# build dbs from already downloaded data files
build_dbs: build_garmin mshealth fitbit
create_dbs: garmin mshealth fitbit
create_copy_dbs: copy_garmin mshealth fitbit
# delete the exisitng dbs and build new dbs from already downloaded data files
rebuild_dbs: rebuild_fitbit rebuild_mshealth rebuild_garmin
# update the exisitng dbs by downloading data files for dates after the last in the dbs and update the dbs
update_dbs: update_garmin
update_dbs_bin: update_garmin_bin
update_copy_dbs: copy_garmin_latest
#
# Project maintainance targets
#
SUBMODULES=Fit Tcx utilities
SUBDIRS=fitbitdb garmindb healthdb mshealthdb
$(CONF_DIR):
mkdir $(CONF_DIR)
$(CONF_DIR)/GarminConnectConfig.json: $(CONF_DIR)
cp $(PROJECT_BASE)/garmindb/GarminConnectConfig.json.example $(CONF_DIR)/GarminConnectConfig.json
$(PROJECT_BASE)/.venv:
$(PYTHON) -m venv --upgrade-deps $(PROJECT_BASE)/.venv
source $(PROJECT_BASE)/.venv/bin/activate
update: submodules_update
git pull --rebase
submodules_update:
git submodule init
git submodule update
$(SUBMODULES:%=%-install):
$(MAKE) -C $(subst -install,,$@) install
publish_check: build
$(PYTHON) -m twine check dist/*
publish: clean publish_check
$(PYTHON) -m twine upload dist/* --verbose
build: devdeps
$(PYTHON) -m build
$(PROJECT_BASE)/dist/$(MODULE)-*.whl: build
install: $(PROJECT_BASE)/dist/$(MODULE)-*.whl
$(PIP) install --upgrade $(PROJECT_BASE)/dist/$(MODULE)-*.whl
reinstall: $(PROJECT_BASE)/dist/$(MODULE)-*.whl
$(PIP) install --upgrade --force-reinstall --no-deps $(PROJECT_BASE)/dist/$(MODULE)-*.whl
install_all: $(SUBMODULES:%=%-install) install
$(SUBMODULES:%=%-uninstall):
$(MAKE) -C $(subst -uninstall,,$@) uninstall
uninstall:
$(PIP) uninstall -y $(MODULE)
uninstall_all: uninstall $(SUBMODULES:%=%-uninstall)
reinstall_all: clean uninstall_all install_all
republish_plugins:
$(MAKE) -C Plugins republish_plugins
$(SUBMODULES:%=%-deps):
$(MAKE) -C $(subst -deps,,$@) deps
pip_upgrade:
$(PIP) install --upgrade pip
requirements.txt:
$(PIP) freeze -r requirement.in > requirements.txt
deps: pip_upgrade $(SUBMODULES:%=%-deps)
$(PIP) install --upgrade --requirement requirements.txt
$(SUBMODULES:%=%-devdeps):
$(MAKE) -C $(subst -devdeps,,$@) devdeps
devdeps: $(SUBMODULES:%=%-devdeps)
$(PIP) install --upgrade --requirement dev-requirements.txt
$(SUBMODULES:%=%-remove_deps):
$(MAKE) -C $(subst -remove_deps,,$@) remove_deps
remove_deps: $(SUBMODULES:%=%-remove_deps)
$(PIP) uninstall -y --requirement requirements.txt
$(PIP) uninstall -y --requirement dev-requirements.txt
clean_deps: remove_deps
$(SUBMODULES:%=%-clean):
$(MAKE) -C $(subst -clean,,$@) clean
$(SUBDIRS:%=%-clean):
rm -f garmindb/$(subst -clean,,$@)/*.pyc
rm -rf garmindb/$(subst -clean,,$@)/__pycache__
clean: $(SUBMODULES:%=%-clean) $(SUBDIRS:%=%-clean) test_clean
rm -f *.pyc
rm -f *.log
rm -f scripts/*.log
rm -f Jupyter/*.log
rm -f *.spec
rm -f *.zip
rm -f *.png
rm -f *stats.txt
rm -f scripts/*stats.txt
rm -f Jupyter/*stats.txt
rm -rf __pycache__
rm -rf *.egg-info
rm -rf build
rm -rf dist
graphs:
garmindb_graphs.py --all
graph_yesterday:
garmindb_graphs.py --day $(YESTERDAY)
checkup: update_garmin
garmindb_checkup.py --battery
garmindb_checkup.py --goals
# define CHECKUP_COURSE_ID in my-defines.mk
checkup_course:
garmin_checkup.py --course $(CHECKUP_COURSE_ID)
daily: all checkup graph_yesterday
#
# Garmin targets
#
backup:
garmindb_cli.py --backup
download_all_garmin:
garmindb_cli.py --all --download
redownload_garmin_activities:
garmindb_cli.py --activities --download --overwrite
garmin:
garmindb_cli.py --all --download --import --analyze
build_garmin:
garmindb_cli.py --all --import --analyze
rebuild_garmin:
garmindb_cli.py --rebuild_db
build_garmin_monitoring:
garmindb_cli.py --monitoring --import --analyze
build_garmin_activities:
garmindb_cli.py --activities --import --analyze
copy_garmin_settings:
garmindb_cli.py --copy
copy_garmin:
garmindb_cli.py --all --copy --import --analyze
update_garmin:
garmindb_cli.py --all --download --import --analyze --latest
copy_garmin_latest:
garmindb_cli.py --all --copy --import --analyze --latest
# define EXPORT_ACTIVITY_ID in my-defines.mk
export_activity:
garmindb_cli.py --export-activity $(EXPORT_ACTIVITY_ID)
# define EXPORT_ACTIVITY_ID in my-defines.mk
basecamp_activity:
garmindb_cli.py --basecamp-activity $(EXPORT_ACTIVITY_ID)
# define EXPORT_ACTIVITY_ID in my-defines.mk
google_earth_activity:
garmindb_cli.py --google-earth-activity $(EXPORT_ACTIVITY_ID)
clean_garmin_dbs:
garmindb_cli.py --delete_db --all
clean_garmin_monitoring_dbs:
garmindb_cli.py --delete_db --monitoring
clean_garmin_activities_dbs:
garmindb_cli.py --delete_db --activities
#
# FitBit target
#
fitbit:
fitbit.py
clean_fitbit_db:
fitbit.py --delete_db
rebuild_fitbit:
fitbit.py --rebuild_db
#
# MS Health target
#
mshealth: $(MSHEALTH_DB)
mshealth.py
clean_mshealth_db:
mshealth.py --delete_db
rebuild_mshealth:
mshealth.py --rebuild_db
#
# test targets
#
$(SUBMODULES:%=%-test):
$(MAKE) -C $(subst -test,,$@) test
test: $(SUBMODULES:%=%-test)
$(MAKE) -C test all
$(SUBMODULES:%=%-verify_commit):
$(MAKE) -C $(subst -verify_commit,,$@) verify_commit
verify_commit: $(SUBMODULES:%=%-test)
$(MAKE) -C test verify_commit
$(SUBMODULES:%=%-test_clean):
$(MAKE) -C $(subst -test_clean,,$@) clean
test_clean:
$(MAKE) -C test clean
$(SUBMODULES:%=%-flake8):
$(MAKE) -C $(subst -flake8,,$@) flake8
flake8: $(SUBMODULES:%=%-flake8)
$(PYTHON) -m flake8 garmindb/*.py garmindb/garmindb/*.py garmindb/summarydb/*.py garmindb/fitbitdb/*.py garmindb/mshealthdb/*.py --max-line-length=180 --ignore=E203,E221,E241,W503
regression_test_run: flake8 rebuild_dbs
grep ERROR garmin.log || [ $$? -eq 1 ]
regression_test: clean regression_test_run test
#
# bugreport target
#
bugreport:
./bugreport.sh
.PHONY: all setup install install_all uninstall uninstall_all update deps create_dbs rebuild_dbs update_dbs clean clean_dbs test zip_packages release clean test test_clean daily flake8 $(SUBMODULES:%=%-flake8)