From f187310ef6439ecd8b0dd432d2002cfe80cd816b Mon Sep 17 00:00:00 2001 From: Salman Mohammed Date: Fri, 17 Jan 2025 07:22:07 -0500 Subject: [PATCH] use cross for building, update Cross.toml and release.yml --- .github/workflows/release.yml | 68 ++++------------------------------- Cross.toml | 29 +++++++++------ 2 files changed, 25 insertions(+), 72 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e4f9814d76..e1b4a2ab03 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -47,75 +47,19 @@ jobs: toolchain: stable target: ${{ matrix.architecture }}-${{ matrix.target-suffix }} - # --- X86_64 only --- - - name: Install system libraries on Ubuntu (x86_64) - if: matrix.os == 'ubuntu-latest' && matrix.architecture == 'x86_64' - run: | - sudo apt-get update - # Add needed libs: openssl, dbus, xcb, etc. - sudo apt-get install -y \ - pkg-config \ - libssl-dev \ - libdbus-1-dev \ - libxcb1-dev - - # --- AARCH64 only --- - - name: Install system libraries on Ubuntu (aarch64) - if: matrix.os == 'ubuntu-latest' && matrix.architecture == 'aarch64' - run: | - if [[ $ImageOS == "ubuntu24" ]]; then - cat < deb822sources - Types: deb - URIs: http://archive.ubuntu.com/ubuntu/ - Suites: noble - Components: main restricted universe - Architectures: amd64 - - Types: deb - URIs: http://security.ubuntu.com/ubuntu/ - Suites: noble-security - Components: main restricted universe - Architectures: amd64 - - Types: deb - URIs: http://archive.ubuntu.com/ubuntu/ - Suites: noble-updates - Components: main restricted universe - Architectures: amd64 - - Types: deb - URIs: http://azure.ports.ubuntu.com/ubuntu-ports/ - Suites: noble - Components: main restricted multiverse universe - Architectures: arm64 - - Types: deb - URIs: http://azure.ports.ubuntu.com/ubuntu-ports/ - Suites: noble-updates - Components: main restricted multiverse universe - Architectures: arm64 - EOF - - sudo mv deb822sources /etc/apt/sources.list.d/ubuntu.sources - fi - - sudo dpkg --add-architecture arm64 - sudo apt-get update - sudo apt-get install -y \ - gcc-aarch64-linux-gnu \ - libc6-dev-arm64-cross \ - libssl-dev:arm64 \ - libdbus-1-dev:arm64 \ - libxcb1-dev:arm64 \ - pkg-config + - name: Install cross + run: cargo install cross --git https://github.com/cross-rs/cross - name: Build CLI + env: + CROSS_NO_WARNINGS: 0 run: | export TARGET="${{ matrix.architecture }}-${{ matrix.target-suffix }}" rustup target add "${TARGET}" + # 'cross' is used to cross-compile for different architectures (see Cross.toml) # Only 'goose' binary is needed for CLI release, skipping 'goosed' here - cargo build --release --target ${TARGET} -p goose-cli + cross build --release --target ${TARGET} -p goose-cli cd target/${TARGET}/release tar -cjf goose-${TARGET}.tar.bz2 goose diff --git a/Cross.toml b/Cross.toml index 3c37eeeb17..5c4db82b35 100644 --- a/Cross.toml +++ b/Cross.toml @@ -1,19 +1,28 @@ +# Configuration for cross-compiling using cross [target.aarch64-unknown-linux-gnu] xargo = false pre-build = [ - "dpkg --add-architecture $CROSS_DEB_ARCH && apt-get update --fix-missing && apt-get install --assume-yes libxcb1-dev:$CROSS_DEB_ARCH libdbus-1-dev:$CROSS_DEB_ARCH", + # Add the ARM64 architecture and install necessary dependencies + "dpkg --add-architecture arm64", + """\ + apt-get update --fix-missing && apt-get install -y \ + pkg-config:arm64 \ + libssl-dev:arm64 \ + libdbus-1-dev:arm64 \ + libxcb1-dev:arm64 + """ ] +env = { PKG_CONFIG_PATH = "/usr/lib/aarch64-linux-gnu/pkgconfig" } -# If you run the build on your local machine, -# This is a workaround for the missing pkg-config path on aarch64 -# You also need to add pkg-config:$CROSS_DEB_ARCH to the apt-get install command above -#[target.aarch64-unknown-linux-gnu.env] -#passthrough = ["PKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig"] - -# If you run the build on your local machine, -# You need to add pkg-config:$CROSS_DEB_ARCH to the apt-get install command below [target.x86_64-unknown-linux-gnu] xargo = false pre-build = [ - "dpkg --add-architecture $CROSS_DEB_ARCH && apt-get update --fix-missing && apt-get install --assume-yes libxcb1-dev:$CROSS_DEB_ARCH libdbus-1-dev:$CROSS_DEB_ARCH", + # Install necessary dependencies for x86_64 + """\ + apt-get update && apt-get install -y \ + pkg-config \ + libssl-dev \ + libdbus-1-dev \ + libxcb1-dev \ + """ ]