]>
Commit | Line | Data |
---|---|---|
1 | profile := dev | |
2 | target = $(shell rustc -vV | grep host | awk '{print $$2}') | |
3 | architectures := x86_64-unknown-linux-gnu aarch64-unknown-linux-gnu | |
4 | app_name := lrc | |
5 | long_app_name := lyricli | |
6 | ||
7 | default: build | |
8 | ||
9 | set_rust: | |
10 | rustup default stable | |
11 | ||
12 | prepare: | |
13 | rustup target add $(target) | |
14 | ||
15 | build: prepare | |
16 | @export $$(cat .env | xargs) > /dev/null 2>&1 && cargo build --profile $(profile) --target $(target) | |
17 | ||
18 | test: | |
19 | @export $$(cat .env | xargs) > /dev/null 2>&1 && cargo test | |
20 | ||
21 | coverage: | |
22 | @export $$(cat .env | xargs) > /dev/null 2>&1 && cargo tarpaulin | |
23 | ||
24 | format: | |
25 | @export $$(cat .env | xargs) > /dev/null 2>&1 && cargo fmt && cargo clippy --fix | |
26 | ||
27 | lint: | |
28 | @export $$(cat .env | xargs) > /dev/null 2>&1 && cargo fmt -- --check && cargo clippy | |
29 | ||
30 | release: rpm tar deb | |
31 | @$(eval filename := $(app_name)-$(target)-$(channel)) | |
32 | ||
33 | $(architectures): | |
34 | ifneq ($(channel),) | |
35 | $(MAKE) -e channel=$(channel) -e target=$@ release | |
36 | else | |
37 | $(MAKE) -e target=$@ build | |
38 | endif | |
39 | ||
40 | deb: build | |
41 | ifeq ($(findstring linux,$(target)),linux) | |
42 | @$(eval filename := $(app_name)-$(target)-$(channel)) | |
43 | @export $$(cat .env | xargs) > /dev/null 2>&1 && cargo deb --profile $(profile) --target $(target) | |
44 | mv target/$(target)/debian/*.deb $(filename).deb | |
45 | sha256sum $(filename).deb > $(filename).deb.sha256 | |
46 | rsync -avz $(filename).deb deploy@conchos.unlimited.pizza:/srv/http/build.r.bdr.sh/$(long_app_name) | |
47 | rsync -avz $(filename).deb.sha256 deploy@conchos.unlimited.pizza:/srv/http/build.r.bdr.sh/$(long_app_name) | |
48 | endif | |
49 | ||
50 | rpm: build | |
51 | ifeq ($(findstring linux,$(target)),linux) | |
52 | @$(eval filename := $(app_name)-$(target)-$(channel)) | |
53 | @export $$(cat .env | xargs) > /dev/null 2>&1 && cargo generate-rpm --profile $(profile) --target $(target) | |
54 | mv target/$(target)/generate-rpm/*.rpm $(filename).rpm | |
55 | sha256sum $(filename).rpm > $(filename).rpm.sha256 | |
56 | rsync -avz $(filename).rpm deploy@conchos.unlimited.pizza:/srv/http/build.r.bdr.sh/$(long_app_name) | |
57 | rsync -avz $(filename).rpm.sha256 deploy@conchos.unlimited.pizza:/srv/http/build.r.bdr.sh/$(long_app_name) | |
58 | endif | |
59 | ||
60 | tar: build | |
61 | @$(eval filename := $(app_name)-$(target)-$(channel)) | |
62 | tar -czvf $(filename).tar.gz -C target/$(target)/$(profile)/ $(app_name) | |
63 | sha256sum $(filename).tar.gz > $(filename).tar.gz.sha256 | |
64 | rsync -avz $(filename).tar.gz deploy@conchos.unlimited.pizza:/srv/http/build.r.bdr.sh/$(long_app_name) | |
65 | rsync -avz $(filename).tar.gz.sha256 deploy@conchos.unlimited.pizza:/srv/http/build.r.bdr.sh/$(long_app_name) | |
66 | ||
67 | package: $(architectures) | |
68 | ||
69 | mac: | |
70 | @$(eval mac_architectures := x86_64-apple-darwin aarch64-apple-darwin) | |
71 | ifeq ($(tag),) | |
72 | $(MAKE) -e profile=release -e architectures='$(mac_architectures)' -e channel=unstable package | |
73 | else | |
74 | $(MAKE) -e profile=release -e architectures='$(mac_architectures)' -e channel=$(tag) package | |
75 | endif | |
76 | ||
77 | ci: lint coverage | |
78 | ifeq ($(GIT_REF),refs/heads/main) | |
79 | $(MAKE) -e profile=release -e channel=unstable package | |
80 | else ifneq (,$(findstring refs/tags/,$(GIT_REF))) | |
81 | $(MAKE) -e profile=release -e channel=$(subst refs/tags/,,$(GIT_REF)) package | |
82 | endif | |
83 | ||
84 | .PHONY: default build $(architectures) rpm package prepare set_rust ci release |