-
Notifications
You must be signed in to change notification settings - Fork 0
Cross-compile binaries for aarch64-unknown-linux-gnu #172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,11 +48,20 @@ jobs: | |
strategy: | ||
matrix: | ||
os: | ||
- ubuntu-latest | ||
- windows-latest | ||
- macos-latest | ||
|
||
runs-on: ${{ matrix.os }} | ||
- name: ubuntu-latest | ||
cross_compile_os: linux | ||
cross_compile_target: aarch64-unknown-linux-gnu | ||
- name: ubuntu-latest | ||
cross_compile_os: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if we need to specify those... If we don't, surely There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I don't think we need to specify this. Can't say for sure though. |
||
cross_compile_target: | ||
- name: windows-latest | ||
cross_compile_os: | ||
cross_compile_target: | ||
- name: macos-latest | ||
cross_compile_os: | ||
cross_compile_target: | ||
|
||
runs-on: ${{ matrix.os.name }} | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
@@ -66,17 +75,34 @@ jobs: | |
- name: Setup PostgreSQL | ||
uses: ikalnytskyi/action-setup-postgres@v6 | ||
|
||
- uses: actions-rs/cargo@v1 | ||
with: | ||
command: build | ||
args: --release | ||
- run: | | ||
if [ -z "${CROSS_COMPILE_TARGET}" ]; then | ||
# normal build targetting the CPU architecture and the OS of the host | ||
cargo build --release | ||
else | ||
# cross build with the specified rustc target | ||
cargo install cross | ||
cross build --release --target ${CROSS_COMPILE_TARGET} | ||
fi | ||
env: | ||
CROSS_COMPILE_TARGET: ${{ matrix.os.cross_compile_target }} | ||
|
||
- id: build | ||
run: | | ||
rustc --print cfg | grep = > rustc.vars | ||
source rustc.vars | ||
if [ -z "${CROSS_COMPILE_TARGET}" ]; then | ||
# normal build targetting the CPU architecture and the OS of the host | ||
rustc --print cfg | grep = > rustc.vars | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alternatively, we can get rid of calling |
||
source rustc.vars | ||
|
||
pushd target/release | ||
else | ||
# cross build with the specified rustc target | ||
export target_os=${CROSS_COMPILE_OS} | ||
export target_arch=${CROSS_COMPILE_TARGET} | ||
|
||
pushd target/${CROSS_COMPILE_TARGET}/release | ||
fi | ||
|
||
pushd target/release | ||
if [ "$RUNNER_OS" == "Windows" ]; then | ||
export ASSET_NAME="xsnippet-api-${target_arch}-${target_os}.exe.7z" | ||
7z a $ASSET_NAME xsnippet-api.exe | ||
|
@@ -89,6 +115,8 @@ jobs: | |
|
||
echo "asset_path=target/release/$ASSET_NAME" >> $GITHUB_OUTPUT | ||
env: | ||
CROSS_COMPILE_OS: ${{ matrix.os.cross_compile_os }} | ||
CROSS_COMPILE_TARGET: ${{ matrix.os.cross_compile_target }} | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
GH_REPO: ${{ env.GITHUB_REPOSITORY }} | ||
RELEASE_TAG: ${{ needs.create_release.outputs.release_tag }} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[build] | ||
pre-build = [ | ||
"dpkg --add-architecture $CROSS_DEB_ARCH", | ||
"apt-get update && apt-get install --assume-yes libssl-dev:$CROSS_DEB_ARCH libpq-dev:$CROSS_DEB_ARCH" | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we somehow infer this from matrix.os? maybe using
uname
or something?