-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
61 lines (53 loc) · 2.02 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
PLATFORMS:=x86_64-apple-darwin x86_64-unknown-linux-gnu x86_64-unknown-linux-musl aarch64-apple-darwin
VERSION:=0.1.4
CLI:=qiniu-upload-util
HOST_TRIPLE := $(shell rustc -vV | grep 'host:' | awk '{print $$2}')
SHELLS:=fish zsh bash elvish
all: $(PLATFORMS)
x86_64-apple-darwin:
cargo build --release --locked
x86_64-unknown-linux-musl:
TARGET_CC=x86_64-linux-musl-cc cargo build --release --target x86_64-unknown-linux-musl --locked
x86_64-unknown-linux-gnu:
TARGET_CC=x86_64-linux-gnu-cc cargo build --release --target x86_64-unknown-linux-gnu --locked
aarch64-apple-darwin:
cargo build --release --target aarch64-apple-darwin --locked
artifacts:all completions
@mkdir -p artifacts/$(VERSION)
@for platform in $(PLATFORMS); do \
if [ "$$platform" == "$(HOST_TRIPLE)" ]; then \
chmod +x target/release/$(CLI); \
mkdir /tmp/$(CLI); \
cp target/release/$(CLI) /tmp/$(CLI); \
cp -R completions /tmp/$(CLI); \
cp README.md /tmp/$(CLI); \
tar zcvf $(CLI)_$$platform.tar.gz -C /tmp $(CLI); \
rm -rf /tmp/$(CLI); \
else \
chmod +x target/$$platform/release/$(CLI); \
mkdir /tmp/$(CLI); \
cp target/$$platform/release/$(CLI) /tmp/$(CLI); \
cp -R completions /tmp/$(CLI); \
cp README.md /tmp/$(CLI); \
tar zcvf $(CLI)_$$platform.tar.gz -C /tmp $(CLI); \
rm -rf /tmp/$(CLI); \
fi; \
mv $(CLI)_$$platform.tar.gz artifacts/$(VERSION); \
md5 -q artifacts/$(VERSION)/$(CLI)_$$platform.tar.gz > artifacts/$(VERSION)/$(CLI)_$$platform.tar.gz.md5; \
done
@echo "generate artifacts done !!!"
completions:
@for shell in $(SHELLS);do \
mkdir -p completions/$$shell; \
completion_name=$(CLI); \
if [ "$$shell" == "fish" ];then \
completion_name=$$completion_name.$$shell; \
elif [ "$$shell" == "zsh" ];then \
completion_name=_$$completion_name; \
elif [ "$$shell" == "elvish" ];then \
completion_name=$$completion_name.elv; \
fi; \
target/release/$(CLI) --completion $$shell > completions/$$shell/$$completion_name; \
done
@echo "generate completions done !!!"
.PHONY: artifacts completions