-
Notifications
You must be signed in to change notification settings - Fork 20
/
Makefile
104 lines (81 loc) · 2.94 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
.PHONY: build test
SHELL := /bin/sh
# Linux
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
UNAME_P := $(shell uname -p)
ifeq ($(UNAME_P),x86_64)
TARGET := x86_64-unknown-linux-gnu
else
TARGET := i686-unknown-linux-gnu
endif
endif
# OS X
ifeq ($(UNAME_S),Darwin)
TARGET := x86_64-apple-darwin
# use brew OpenSSL on Mac OSX
export OPENSSL_ROOT_DIR = /usr/local/opt/openssl
export OPENSSL_LIB_DIR = /usr/local/opt/openssl/lib
export OPENSSL_INCLUDE_DIR = /usr/local/opt/openssl/include
endif
# move command line args to RUN_ARGS for the run command
ifeq (run,$(firstword $(MAKECMDGOALS)))
# use the rest as arguments for "run"
RUN_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
# ...and turn them into do-nothing targets
$(eval $(RUN_ARGS):;@:)
endif
export RUST_BACKTRACE = 1
fmt:
cargo fmt
pre_release:
sed -ibak 's/^version = ".*"$$/version = "$(VERSION)"/' Cargo.toml
sed '/^```$$/d;' examples/commands.md > examples/commands.txt
run:
cargo run -- $(RUN_ARGS)
clean:
cargo clean
build:
rustup update stable
cargo build --release --target=$(TARGET)
build_linux_x86_64:
cd build && \
vagrant up linux_x86_64 --provision && \
vagrant ssh -c "cd /src && make build;" linux_x86_64 && \
vagrant halt linux_x86_64
build_linux_i686:
cd build && \
vagrant up linux_i686 --provision && \
vagrant ssh -c "cd /src && make build;" linux_i686 && \
vagrant halt linux_i686
release: clean pre_release build_linux_x86_64 build_linux_i686 build
# update release urls
sed -ibak 's/releases\/download\/v[^/]*\/ssh-permit-a38-v[^/]*-/releases\/download\/v$(VERSION)\/ssh-permit-a38-v$(VERSION)-/' README.md
# update release version an date
sed -ibak 's/^## Latest release v.*/## Latest release v$(VERSION) - $(shell date +%Y-%m-%d)/' README.md
rm README.mdbak
rm Cargo.tomlbak
git commit -a -m "bump $(VERSION)"
git push
git checkout master
git merge develop
git push origin master
git tag v$(VERSION)
git push origin v$(VERSION)
rm build/binaries/*.zip || true
# OS X
cp target/x86_64-apple-darwin/release/ssh-permit-a38 build/binaries/
cd build/binaries/ && zip --move ssh-permit-a38-v$(VERSION)-x86_64-apple-darwin.zip ssh-permit-a38
# Linux x86_64
cp target/x86_64-unknown-linux-gnu/release/ssh-permit-a38 build/binaries/
cd build/binaries/ && zip --move ssh-permit-a38-v$(VERSION)-x86_64-unknown-linux-gnu.zip ssh-permit-a38
# Linux i686
cp target/i686-unknown-linux-gnu/release/ssh-permit-a38 build/binaries/
cd build/binaries/ && zip --move ssh-permit-a38-v$(VERSION)-i686-unknown-linux-gnu.zip ssh-permit-a38
cd build/binaries/ && hub release create -a ssh-permit-a38-v$(VERSION)-x86_64-apple-darwin.zip -a ssh-permit-a38-v$(VERSION)-x86_64-unknown-linux-gnu.zip -a ssh-permit-a38-v$(VERSION)-i686-unknown-linux-gnu.zip v$(VERSION)
git checkout develop
open https://github.com/ierror/ssh-permit-a38/releases
test:
cargo test --jobs=4 -- --test-threads=4
push: fmt
git push