Skip to content

Commit b6a8416

Browse files
chore: build more targets (#2)
1 parent 88b2f1d commit b6a8416

File tree

3 files changed

+54
-19
lines changed

3 files changed

+54
-19
lines changed

.github/workflows/rust.yml

Lines changed: 46 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,36 +11,70 @@ env:
1111

1212
jobs:
1313
build:
14-
runs-on: ${{ matrix.os }}
14+
name: Build (${{ matrix.platform.os-name }})
15+
runs-on: ${{ matrix.platform.runs-on }}
1516
strategy:
1617
matrix:
17-
os: [macos-latest, ubuntu-22.04, windows-latest]
18+
platform:
19+
- os-name: Linux-x86_64
20+
runs-on: ubuntu-24.04
21+
target: x86_64-unknown-linux-gnu
22+
command: both
23+
24+
- os-name: Linux-arm64
25+
runs-on: ubuntu-24.04-arm
26+
target: aarch64-unknown-linux-gnu
27+
command: both
28+
29+
- os-name: Windows-x86_64
30+
runs-on: windows-latest
31+
target: x86_64-pc-windows-msvc
32+
command: both
33+
34+
- os-name: Windows-arm64
35+
runs-on: windows-latest
36+
target: aarch64-pc-windows-msvc
37+
command: build
38+
39+
- os-name: macOS-x86_64
40+
runs-on: macos-latest
41+
target: x86_64-apple-darwin
42+
command: both
43+
44+
- os-name: macOS-arm64
45+
runs-on: macos-latest
46+
target: aarch64-apple-darwin
47+
command: both
48+
1849
steps:
1950
- uses: actions/checkout@v4
2051

21-
- name: Run tests
22-
run: cargo test
23-
2452
- name: Build
25-
run: cargo build --all --release
53+
uses: houseabsolute/actions-rust-cross@v1
54+
with:
55+
command: ${{ matrix.platform.command }}
56+
target: ${{ matrix.platform.target }}
57+
args: "--locked --all --release"
2658

2759
- name: Store command line tool
2860
uses: actions/upload-artifact@v4
2961
with:
30-
name: rdfu-${{ matrix.os }}
62+
name: rdfu-${{ matrix.platform.os-name }}
3163
path: |
32-
target/release/rdfu*
33-
!target/release/rdfu.d
34-
!target/release/rdfu.pdb
64+
target/${{ matrix.platform.target }}/release/rdfu*
65+
!target/${{ matrix.platform.target }}/release/rdfu.d
66+
!target/${{ matrix.platform.target }}/release/rdfu.pdb
3567
3668
- name: Package library
3769
shell: bash
38-
run: ./package.sh
70+
env:
71+
TARGET: ${{ matrix.platform.target }}
72+
run: ./package.sh $TARGET "target/$TARGET" "release"
3973

4074
- name: Store library
4175
uses: actions/upload-artifact@v4
4276
with:
43-
name: library-${{ matrix.os }}
77+
name: library-${{ matrix.platform.os-name }}
4478
path: rs_dfu-*.tar.gz
4579

4680
release:

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,8 @@ uf2 = { path = "uf2" }
2020
[build-dependencies]
2121
cxx-build = "1.0"
2222

23+
[profile.release]
24+
strip = true
25+
2326
[lib]
2427
crate-type = ["staticlib", "cdylib"]

package.sh

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
set -e
44

5-
# Build the project
6-
cargo build --all --release
7-
85
# Get target triple
96
TARGET=${1:-$(rustc -vV | sed -n 's|host: ||p')}
107

@@ -28,28 +25,29 @@ case "$TARGET" in
2825
esac
2926

3027
LIB_NAME="rs_dfu"
31-
TARGET_DIR="target/release"
28+
TARGET_DIR=${2:-"target"}
29+
PROFILE_DIR=${3:-"release"}
3230

3331
# Create distribution structure
3432
rm -rf dist
3533
mkdir -p dist/cmake dist/include dist/lib
3634

3735
# Copy libraries
38-
SHARED_LIB="${TARGET_DIR}/${LIB_PREFIX}${LIB_NAME}.${SHARED_EXT}"
36+
SHARED_LIB="${TARGET_DIR}/${PROFILE_DIR}/${LIB_PREFIX}${LIB_NAME}.${SHARED_EXT}"
3937

4038
if [ -f "$SHARED_LIB" ]; then
4139
cp "$SHARED_LIB" "dist/lib/"
4240
echo "Copied: $SHARED_LIB"
4341
fi
4442

45-
STATIC_LIB="${TARGET_DIR}/${LIB_PREFIX}${LIB_NAME}.${STATIC_EXT}"
43+
STATIC_LIB="${TARGET_DIR}/${PROFILE_DIR}/${LIB_PREFIX}${LIB_NAME}.${STATIC_EXT}"
4644
if [ -f "$STATIC_LIB" ]; then
4745
cp "$STATIC_LIB" "dist/lib/"
4846
echo "Copied: $STATIC_LIB"
4947
fi
5048

5149
# Copy headers
52-
HEADER_FILE="target/cxxbridge/rs-dfu/src/lib.rs.h"
50+
HEADER_FILE="${TARGET_DIR}/cxxbridge/rs-dfu/src/lib.rs.h"
5351
if [ -f "$HEADER_FILE" ]; then
5452
cp "$HEADER_FILE" "dist/include/$LIB_NAME.h"
5553
echo "Copied: $HEADER_FILE"

0 commit comments

Comments
 (0)