Skip to content

Commit 5d5dd26

Browse files
committed
Add multibuild
1 parent e2e0b95 commit 5d5dd26

File tree

2 files changed

+26
-20
lines changed

2 files changed

+26
-20
lines changed

.github/workflows/CI.yml

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,26 +52,13 @@ jobs:
5252
needs: [test]
5353
if: startsWith(github.ref, 'refs/tags/')
5454
runs-on: ubuntu-latest
55-
strategy:
56-
matrix:
57-
target: [ aarch64-unknown-linux-gnu, armv7-unknown-linux-gnueabihf, i686-unknown-linux-gnu, i686-unknown-linux-musl, powerpc64-unknown-linux-gnu, powerpc64le-unknown-linux-gnu, arm-unknown-linux-gnueabi, x86_64-unknown-linux-gnu, x86_64-unknown-linux-musl ]
5855
steps:
5956
- name: Checkout
6057
uses: actions/checkout@v1
61-
- name: Install rust
62-
uses: actions-rs/toolchain@v1
63-
with:
64-
toolchain: stable
65-
profile: minimal
66-
override: true
67-
target: ${{ matrix.target }}
6858

69-
- name: Build target
70-
uses: actions-rs/cargo@v1
71-
with:
72-
use-cross: true
73-
command: build
74-
args: --release --target ${{ matrix.target }}
59+
- name: Build for all targets
60+
shell: bash
61+
run: "make multibuild -j$(nproc)"
7562

7663
- name: Package
7764
shell: bash

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)