Skip to content

Commit c16929a

Browse files
committed
Add multibuild
1 parent f0e8fcc commit c16929a

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

Makefile

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
all: build
22

3-
AKG := target/release/authrorized-keys-github
3+
NATIVE_EXE := target/release/authorized-keys-github
44

55
# When building the testing image, make the UID and GID match ours
66
UID := $(shell id -u)
@@ -34,16 +34,35 @@ endef
3434
# To speed up interactive development with cargo, cache the cargo home in a subdir of `target`
3535
target/.docker_cargo_home:
3636
mkdir -p $@
37-
$(AKG): target/.docker_cargo_home
37+
$(NATIVE_EXE): target/.docker_cargo_home
3838
else
3939
define docker_exec
4040
$(2)
4141
endef
4242
endif
4343

44-
$(AKG): Cargo.toml Cargo.lock src/main.rs
44+
$(NATIVE_EXE): Cargo.toml Cargo.lock src/main.rs
4545
$(call docker_exec,rust,cargo build --color=always --release)
46-
build: $(AKG)
46+
build: $(NATIVE_EXE)
47+
48+
# Use `cross` to build for other architectures
49+
target/%/release/authorized-keys-github:
50+
ifeq ($(shell which cross 2>/dev/null),)
51+
cargo install cross --git https://github.com/cross-rs/cross
52+
endif
53+
cross build --target $* --release
54+
55+
# `ring` has some build problems, preventing us from building on:
56+
# - powerpc64le-unknown-linux-gnu
57+
# - arm-unknown-linux-gnueabihf
58+
TARGET_TRIPLETS := aarch64-unknown-linux-gnu \
59+
aarch64-unknown-linux-musl \
60+
armv7-unknown-linux-gnueabihf \
61+
i686-unknown-linux-gnu \
62+
i686-unknown-linux-musl \
63+
x86_64-unknown-linux-gnu \
64+
x86_64-unknown-linux-musl
65+
$(foreach triplet,$(TARGET_TRIPLETS),$(eval multibuild: target/$(triplet)/release/authorized-keys-github))
4766

4867
check:
4968
$(call docker_exec,rust,cargo fmt --color=always --all -- --check)

0 commit comments

Comments
 (0)