From 3089a4034a224d99fadfe35ab5b5ecd19361dfef Mon Sep 17 00:00:00 2001 From: Johann150 Date: Sat, 6 Feb 2021 17:06:46 +0100 Subject: [PATCH] use cargo cross The problems I had using podman were resolved by realizing that ubuntu-latest does not actually mean the latest version of Ubuntu (for now) so explicitly stating the Ubuntu version, installing podman works fine and can build binaries for Raspberry Pi properly. --- .cargo/config | 8 -------- .github/workflows/rust.yml | 14 ++++++++------ Cross.toml | 2 ++ release.sh | 8 ++++---- 4 files changed, 14 insertions(+), 18 deletions(-) delete mode 100644 .cargo/config create mode 100644 Cross.toml diff --git a/.cargo/config b/.cargo/config deleted file mode 100644 index 704b897..0000000 --- a/.cargo/config +++ /dev/null @@ -1,8 +0,0 @@ -[target.aarch64-unknown-linux-gnu] -linker = "aarch64-linux-gnu-gcc" - -[target.arm-unknown-linux-gnueabihf] -linker = "arm-linux-gnueabihf-gcc" - -[target.armv7-unknown-linux-gnueabihf] -linker = "arm-linux-gnueabihf-gcc" diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index b9bd1d7..ee14a79 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -25,7 +25,7 @@ jobs: upload_url: ${{ steps.create_release.outputs.upload_url }} build_ubuntu: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 needs: create_release steps: - uses: actions/checkout@v1 @@ -73,19 +73,21 @@ jobs: needs: create_release steps: - uses: actions/checkout@v1 - - run: rustc -Vv - name: Build run: cargo build --verbose --release + - name: strip names + run: strip target/release/agate.exe + - name: compress + run: gzip -c target/release/agate.exe > ./agate.exe.gz - name: upload release asset win uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ needs.create_release.outputs.upload_url }} - asset_name: agate.x86_64-pc-windows-msvc.exe - # TODO: this one is not zipped and not stripped - asset_path: target/release/agate.exe - asset_content_type: application/vnd.microsoft.portable-executable + asset_name: agate.x86_64-pc-windows-msvc.exe.gz + asset_path: agate.exe.gz + asset_content_type: application/gzip build_macos: runs-on: macos-latest diff --git a/Cross.toml b/Cross.toml new file mode 100644 index 0000000..2217b8f --- /dev/null +++ b/Cross.toml @@ -0,0 +1,2 @@ +[target.arm-unknown-linux-gnueabihf] +image = "zenria/cross:arm-rpi-4.9.3-linux-gnueabihf" diff --git a/release.sh b/release.sh index cb27040..406a57b 100755 --- a/release.sh +++ b/release.sh @@ -5,13 +5,13 @@ set -e # Cross-compiling needs a linker for the respective platforms. If you are on a Debian-based x86_64 Linux, # you can install them with: -sudo apt -y install gcc-arm-linux-gnueabihf gcc-aarch64-linux-gnu +sudo apt -y install podman gcc-arm-linux-gnueabihf gcc-aarch64-linux-gnu +# Also install cross compilation tool for cargo +cargo install cross for i in x86_64-unknown-linux-gnu aarch64-unknown-linux-gnu arm-unknown-linux-gnueabihf armv7-unknown-linux-gnueabihf do - # Make sure the cross-compiled std crate is available. - rustup target add $i - cargo build --verbose --release --target $i + cross build --verbose --release --target $i cp target/$i/release/agate agate.$i done