]>
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 | host_architecture := $(target) | |
7 | ||
8 | default: build | |
9 | ||
10 | set_rust: | |
11 | rustup default stable | |
12 | ||
13 | prepare: | |
14 | rustup target add $(target) | |
15 | ||
16 | build: prepare | |
17 | # I need an actually configurable way to make this work. Right now i'm only | |
18 | # cross compiling in the CI, and I know what I'm running, but | |
19 | ifeq ($(host_architecture), x86_64-unknown-linux-gnu) | |
20 | ifeq ($(target), aarch64-unknown-linux-gnu) | |
21 | LD_LIBRARY_PATH=/usr/local/aarch64-linux-gnu/lib:${LD_LIBRARY_PATH} | |
22 | endif | |
23 | endif | |
24 | @export $$(cat .env | xargs) > /dev/null 2>&1 && cargo build --profile $(profile) --target $(target) | |
25 | ||
26 | release: rpm tar deb | |
27 | @$(eval filename := $(app_name)-$(target)-$(channel)) | |
28 | ||
29 | $(architectures): | |
30 | ifneq ($(channel),) | |
31 | $(MAKE) -e channel=$(channel) -e target=$@ release | |
32 | else | |
33 | $(MAKE) -e target=$@ build | |
34 | endif | |
35 | ||
36 | deb: build | |
37 | ifeq ($(findstring linux,$(target)),linux) | |
38 | @$(eval filename := $(app_name)-$(target)-$(channel)) | |
39 | @export $$(cat .env | xargs) > /dev/null 2>&1 && cargo deb --profile $(profile) --target $(target) | |
40 | mv target/$(target)/debian/*.deb $(filename).deb | |
41 | sha256sum $(filename).deb > $(filename).deb.sha256 | |
42 | rsync -avz $(filename).deb deploy@conchos.unlimited.pizza:/srv/http/build.r.bdr.sh/$(long_app_name) | |
43 | rsync -avz $(filename).deb.sha256 deploy@conchos.unlimited.pizza:/srv/http/build.r.bdr.sh/$(long_app_name) | |
44 | endif | |
45 | ||
46 | rpm: build | |
47 | ifeq ($(findstring linux,$(target)),linux) | |
48 | @$(eval filename := $(app_name)-$(target)-$(channel)) | |
49 | @export $$(cat .env | xargs) > /dev/null 2>&1 && cargo generate-rpm --profile $(profile) --target $(target) | |
50 | mv target/$(target)/generate-rpm/*.rpm $(filename).rpm | |
51 | sha256sum $(filename).rpm > $(filename).rpm.sha256 | |
52 | rsync -avz $(filename).rpm deploy@conchos.unlimited.pizza:/srv/http/build.r.bdr.sh/$(long_app_name) | |
53 | rsync -avz $(filename).rpm.sha256 deploy@conchos.unlimited.pizza:/srv/http/build.r.bdr.sh/$(long_app_name) | |
54 | endif | |
55 | ||
56 | tar: build | |
57 | @$(eval filename := $(app_name)-$(target)-$(channel)) | |
58 | tar -czvf $(filename).tar.gz -C target/$(target)/$(profile)/ $(app_name) | |
59 | sha256sum $(filename).tar.gz > $(filename).tar.gz.sha256 | |
60 | rsync -avz $(filename).tar.gz deploy@conchos.unlimited.pizza:/srv/http/build.r.bdr.sh/$(long_app_name) | |
61 | rsync -avz $(filename).tar.gz.sha256 deploy@conchos.unlimited.pizza:/srv/http/build.r.bdr.sh/$(long_app_name) | |
62 | ||
63 | package: $(architectures) | |
64 | ||
65 | mac: | |
66 | @$(eval mac_architectures := x86_64-apple-darwin aarch64-apple-darwin) | |
67 | ifeq ($(tag),) | |
68 | $(MAKE) -e profile=release -e architectures='$(mac_architectures)' -e channel=unstable package | |
69 | else | |
70 | $(MAKE) -e profile=release -e architectures='$(mac_architectures)' -e channel=$(tag) package | |
71 | endif | |
72 | ||
73 | ||
74 | ci: | |
75 | ifeq ($(GIT_REF),refs/heads/main) | |
76 | $(MAKE) -e profile=release -e channel=unstable package | |
77 | else ifneq (,$(findstring refs/tags/,$(GIT_REF))) | |
78 | $(MAKE) -e profile=release -e channel=$(subst refs/tags/,,$(GIT_REF)) package | |
79 | endif | |
80 | ||
81 | .PHONY: default build $(architectures) rpm package prepare set_rust ci release |