Skip to content

Commit 98573e2

Browse files
authored
Merge pull request #3 from JuliaComputing/sf/add_ci
Add `multibuild` makefile target
2 parents ff3bf62 + 5d5dd26 commit 98573e2

File tree

2 files changed

+27
-32
lines changed

2 files changed

+27
-32
lines changed

.github/workflows/CI.yml

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,6 @@ jobs:
4343
- name: Checkout
4444
uses: actions/checkout@v1
4545

46-
- name: Install rust
47-
uses: actions-rs/toolchain@v1
48-
with:
49-
toolchain: stable
50-
profile: minimal
51-
override: true
52-
53-
- name: Build
54-
shell: bash
55-
run: "make"
56-
5746
- name: Test
5847
shell: bash
5948
run: "make test"
@@ -63,26 +52,13 @@ jobs:
6352
needs: [test]
6453
if: startsWith(github.ref, 'refs/tags/')
6554
runs-on: ubuntu-latest
66-
strategy:
67-
matrix:
68-
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 ]
6955
steps:
7056
- name: Checkout
7157
uses: actions/checkout@v1
72-
- name: Install rust
73-
uses: actions-rs/toolchain@v1
74-
with:
75-
toolchain: stable
76-
profile: minimal
77-
override: true
78-
target: ${{ matrix.target }}
7958

80-
- name: Build target
81-
uses: actions-rs/cargo@v1
82-
with:
83-
use-cross: true
84-
command: build
85-
args: --release --target ${{ matrix.target }}
59+
- name: Build for all targets
60+
shell: bash
61+
run: "make multibuild -j$(nproc)"
8662

8763
- name: Package
8864
shell: bash

Makefile

Lines changed: 24 additions & 5 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)
@@ -52,7 +71,7 @@ format:
5271
$(call docker_exec,rust,cargo fmt --color=always --all)
5372

5473
.PHONY: test build
55-
test: $(AKG)
74+
test: $(NATIVE_EXE)
5675
ifeq ($(USE_DOCKER),true)
5776
docker build --build-arg UID=$(UID) --build-arg GID=$(GID) -t authorized-keys-github-test .
5877
endif

0 commit comments

Comments
 (0)