]>
Commit | Line | Data |
---|---|---|
738ec06d RBR |
1 | profile := dev |
2 | target = $(shell rustc -vV | grep host | awk '{print $$2}') | |
3 | architectures := x86_64-unknown-linux-gnu aarch64-unknown-linux-gnu | |
44e7b4de | 4 | app_name := lrc |
8d584ce7 | 5 | long_app_name := lyricli |
169297c8 BB |
6 | |
7 | default: build | |
8 | ||
738ec06d RBR |
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 | ||
aece0e58 | 18 | test: |
d33e6d4d | 19 | @export $$(cat .env | xargs) > /dev/null 2>&1 && cargo test |
aece0e58 RBR |
20 | |
21 | coverage: | |
d33e6d4d | 22 | @export $$(cat .env | xargs) > /dev/null 2>&1 && cargo tarpaulin |
aece0e58 RBR |
23 | |
24 | format: | |
d33e6d4d | 25 | @export $$(cat .env | xargs) > /dev/null 2>&1 && cargo fmt && cargo clippy --fix |
aece0e58 RBR |
26 | |
27 | lint: | |
d33e6d4d | 28 | @export $$(cat .env | xargs) > /dev/null 2>&1 && cargo fmt -- --check && cargo clippy |
aece0e58 | 29 | |
738ec06d RBR |
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 | |
8d584ce7 | 41 | ifeq ($(findstring linux,$(target)),linux) |
738ec06d | 42 | @$(eval filename := $(app_name)-$(target)-$(channel)) |
f5a040da | 43 | @export $$(cat .env | xargs) > /dev/null 2>&1 && cargo deb --profile $(profile) --target $(target) |
738ec06d RBR |
44 | mv target/$(target)/debian/*.deb $(filename).deb |
45 | sha256sum $(filename).deb > $(filename).deb.sha256 | |
8d584ce7 RBR |
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 | |
738ec06d RBR |
49 | |
50 | rpm: build | |
8d584ce7 | 51 | ifeq ($(findstring linux,$(target)),linux) |
738ec06d | 52 | @$(eval filename := $(app_name)-$(target)-$(channel)) |
f5a040da | 53 | @export $$(cat .env | xargs) > /dev/null 2>&1 && cargo generate-rpm --profile $(profile) --target $(target) |
738ec06d RBR |
54 | mv target/$(target)/generate-rpm/*.rpm $(filename).rpm |
55 | sha256sum $(filename).rpm > $(filename).rpm.sha256 | |
8d584ce7 RBR |
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 | |
738ec06d RBR |
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 | |
8d584ce7 RBR |
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) | |
738ec06d RBR |
66 | |
67 | package: $(architectures) | |
68 | ||
8d584ce7 | 69 | mac: |
534287c3 | 70 | @$(eval mac_architectures := x86_64-apple-darwin aarch64-apple-darwin) |
8d584ce7 | 71 | ifeq ($(tag),) |
534287c3 | 72 | $(MAKE) -e profile=release -e architectures='$(mac_architectures)' -e channel=unstable package |
8d584ce7 | 73 | else |
534287c3 | 74 | $(MAKE) -e profile=release -e architectures='$(mac_architectures)' -e channel=$(tag) package |
8d584ce7 RBR |
75 | endif |
76 | ||
aece0e58 | 77 | ci: lint coverage |
738ec06d | 78 | ifeq ($(GIT_REF),refs/heads/main) |
aece0e58 | 79 | $(MAKE) -e profile=release -e channel=unstable package |
738ec06d | 80 | else ifneq (,$(findstring refs/tags/,$(GIT_REF))) |
aece0e58 | 81 | $(MAKE) -e profile=release -e channel=$(subst refs/tags/,,$(GIT_REF)) package |
738ec06d RBR |
82 | endif |
83 | ||
84 | .PHONY: default build $(architectures) rpm package prepare set_rust ci release |