1
0
Fork 0
datetime.link/Makefile

73 lines
1.8 KiB
Makefile
Raw Normal View History

2020-10-31 00:32:05 +08:00
GO = go
DOWNLOAD = wget --quiet --output-document
2020-10-31 00:57:37 +08:00
UNZIP = unzip -d
2020-10-31 00:32:05 +08:00
MKDIR = mkdir -p
.PHONY: all
2020-11-07 23:57:45 +08:00
all: download-icons download-libs data build
2020-10-31 00:57:37 +08:00
2020-10-31 00:32:05 +08:00
.PHONY: clean
clean:
2020-11-07 23:57:45 +08:00
$(RM) -r datetime data/cities*.json third-party/ assets/js/third-party/ templates/icon_*.svg
2020-10-31 00:32:05 +08:00
.PHONY: build
build: datetime
datetime: *.go data/*.go
$(GO) build -tags "$(TAGS)" -v -o datetime
2020-10-31 01:12:08 +08:00
.PHONY: test
2020-11-09 00:31:47 +08:00
test: data
2020-11-10 19:44:58 +08:00
$(GO) test -cover -bench=. -v ./...
2020-10-31 00:32:05 +08:00
2020-10-31 00:57:37 +08:00
DATASETS = \
2020-11-07 23:36:02 +08:00
third-party/cities15000.txt \
third-party/admin1CodesASCII.txt \
third-party/countryInfo.txt
2020-10-31 00:32:05 +08:00
2020-10-31 00:57:37 +08:00
.PHONY: data
2020-11-07 23:36:02 +08:00
data: data/cities.json
2020-10-31 00:32:05 +08:00
2020-11-10 19:48:59 +08:00
data/cities.json: $(DATASETS) scripts/data.go data/*.go
2020-11-07 20:45:00 +08:00
cd scripts && $(GO) run data.go
2020-11-07 23:36:02 +08:00
third-party/cities15000.txt:
$(MKDIR) third-party/
$(DOWNLOAD) third-party/cities15000.zip http://download.geonames.org/export/dump/cities15000.zip
$(UNZIP) third-party/ third-party/cities15000.zip
$(RM) third-party/cities15000.zip
2020-11-07 23:36:02 +08:00
third-party/countryInfo.txt:
$(MKDIR) third-party/
$(DOWNLOAD) third-party/countryInfo.txt http://download.geonames.org/export/dump/countryInfo.txt
2020-11-07 23:36:02 +08:00
third-party/admin1CodesASCII.txt:
$(MKDIR) third-party/
$(DOWNLOAD) third-party/admin1CodesASCII.txt https://download.geonames.org/export/dump/admin1CodesASCII.txt
2020-10-31 00:32:05 +08:00
2020-11-07 23:57:45 +08:00
.PHONY: download-libs
download-libs: assets/js/third-party/luxon.min.js
assets/js/third-party/luxon.min.js:
$(MKDIR) assets/js/third-party/
$(DOWNLOAD) assets/js/third-party/luxon.min.js https://cdn.jsdelivr.net/npm/luxon@1.25.0/build/global/luxon.min.js
2020-10-31 00:32:05 +08:00
ICONS = \
solid_sun \
solid_moon \
2020-11-22 16:41:58 +08:00
solid_adjust \
solid_trash \
solid_plus
2020-10-31 00:32:05 +08:00
.PHONY: download-icons
download-icons: $(foreach icon,$(ICONS),templates/icon_$(icon).svg)
.DELETE_ON_ERROR: templates/icon_%.svg
templates/icon_%.svg:
$(DOWNLOAD) $@ https://github.com/FortAwesome/Font-Awesome/raw/5.15.1/svgs/$(subst _,/,$*).svg