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