-
Notifications
You must be signed in to change notification settings - Fork 16
/
Makefile
130 lines (122 loc) · 4.41 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
REPOSITORY ?= joseluisq
TAG ?= latest
build:
docker build \
-t $(REPOSITORY)/rust-linux-darwin-builder:$(TAG) \
--network=host \
-f Dockerfile .
.PHONY: build
# Use to build both arm64 and amd64 images at the same time.
# WARNING! Will automatically push, since multi-platform images are not available locally.
# Use `REPOSITORY` arg to specify which container repository to push the images to.
buildx:
docker run --privileged --rm tonistiigi/binfmt --install linux/amd64,linux/arm64
docker buildx create --name darwin-builder --driver docker-container --bootstrap
docker buildx use darwin-builder
docker buildx build \
--platform linux/amd64,linux/arm64 \
--push \
-t $(REPOSITORY)/rust-linux-darwin-builder:$(TAG) \
-f Dockerfile .
.PHONY: buildx
test:
@docker run --rm \
-v $(PWD):/root/src \
-w /root/src \
$(REPOSITORY)/rust-linux-darwin-builder:$(TAG) \
bash -c 'set -eu; make test-ci'
.PHONY: test
test-ci:
@echo "Checking Debian version..."
@cat /etc/debian_version
@echo
@echo "Testing cross-compiling application..."
@rustc -vV
@echo
@cd tests/hello-world \
\
&& if [ "$$(uname -m)" = "x86_64" ]; then \
echo "Compiling application (linux-gnu x86_64)..."; \
cargo build --release --target x86_64-unknown-linux-gnu; \
du -sh target/x86_64-unknown-linux-gnu/release/hello-world-test; \
target/x86_64-unknown-linux-gnu/release/hello-world-test; \
echo; \
\
echo "Compiling application (linux-musl x86_64)..."; \
cargo build --release --target x86_64-unknown-linux-musl; \
du -sh target/x86_64-unknown-linux-musl/release/hello-world-test; \
target/x86_64-unknown-linux-musl/release/hello-world-test; \
echo; \
fi \
\
&& echo "Cross-compiling application (apple-darwin x86_64)..." \
&& cargo build --release --target x86_64-apple-darwin \
&& du -sh target/x86_64-apple-darwin/release/hello-world-test \
&& echo \
\
\
&& echo "Cross-compiling application (linux-gnu aarch64)..." \
&& cargo build --release --target aarch64-unknown-linux-gnu \
&& du -sh target/aarch64-unknown-linux-gnu/release/hello-world-test \
&& if [ "$$(uname -m)" = "aarch64" ]; then \
target/aarch64-unknown-linux-gnu/release/hello-world-test; \
fi \
&& echo \
\
&& echo "Cross-compiling application (linux-musl aarch64)..." \
&& cargo build --release --target aarch64-unknown-linux-musl \
&& du -sh target/aarch64-unknown-linux-musl/release/hello-world-test \
&& if [ "$$(uname -m)" = "aarch64" ]; then \
target/aarch64-unknown-linux-musl/release/hello-world-test; \
fi \
&& echo \
\
&& echo "Cross-compiling application (apple-darwin aarch64)..." \
&& cargo build --release --target aarch64-apple-darwin \
&& du -sh target/aarch64-apple-darwin/release/hello-world-test
@echo
@cd ../..
@cd tests/zlib \
\
&& if [ "$$(uname -m)" = "x86_64" ]; then \
echo "Compiling application (linux-gnu x86_64)..."; \
cargo build --release --target x86_64-unknown-linux-gnu; \
du -sh target/x86_64-unknown-linux-gnu/release/zlib-test; \
target/x86_64-unknown-linux-gnu/release/zlib-test; \
echo; \
\
echo "Compiling application (linux-musl x86_64)..."; \
cargo build --release --target x86_64-unknown-linux-musl; \
du -sh target/x86_64-unknown-linux-musl/release/zlib-test; \
target/x86_64-unknown-linux-musl/release/zlib-test; \
echo; \
fi \
\
&& echo "Cross-compiling application (apple-darwin x86_64)..." \
&& LIBZ_SYS_STATIC=0 CC=o64-clang CXX=o64-clang++ \
cargo build --release --target x86_64-apple-darwin \
&& du -sh target/x86_64-apple-darwin/release/zlib-test \
&& echo \
\
\
&& echo "Cross-compiling application (linux-gnu aarch64)..." \
&& cargo build --release --target aarch64-unknown-linux-gnu \
&& du -sh target/aarch64-unknown-linux-gnu/release/zlib-test \
&& if [ "$$(uname -m)" = "aarch64" ]; then \
target/aarch64-unknown-linux-gnu/release/zlib-test; \
fi \
&& echo \
\
&& echo "Cross-compiling application (linux-musl aarch64)..." \
&& cargo build --release --target aarch64-unknown-linux-musl \
&& du -sh target/aarch64-unknown-linux-musl/release/zlib-test \
&& if [ "$$(uname -m)" = "aarch64" ]; then \
target/aarch64-unknown-linux-musl/release/zlib-test; \
fi \
&& echo \
\
&& echo "Cross-compiling application (apple-darwin aarch64)..." \
&& LIBZ_SYS_STATIC=0 CC=o64-clang CXX=o64-clang++ \
cargo build --release --target aarch64-apple-darwin \
&& du -sh target/aarch64-apple-darwin/release/zlib-test
.ONESHELL: test-ci