diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 21deb35..a350fbe 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -92,6 +92,16 @@ jobs: cmake_args: >- -DDEBUG_ASSERTIONS_FATAL=ON -DBATTERY=OFF + - name: Linux (arm64) + os: ubuntu-latest + triplet: arm64-linux-release + host_triplet: x64-linux-release + overlay_ports: vcpkg/overlay/ports + ccache_path: ~/.ccache + cpack_generator: TGZ + package_extension: tar.gz + cmake_args: >- + -DBATTERY=OFF name: '${{ matrix.name }}' runs-on: '${{ matrix.os }}' @@ -100,7 +110,7 @@ jobs: ARTIFACT_BASE_NAME: 'mixxx-${{ matrix.triplet }}${{ matrix.suffix }}' VCPKG_DEFAULT_TRIPLET: '${{ matrix.triplet }}' VCPKG_DEFAULT_HOST_TRIPLET: '${{ matrix.host_triplet }}' - VCPKG_OVERLAY_TRIPLETS: vcpkg/overlay/triplets + VCPKG_OVERLAY_TRIPLETS: overlay/triplets:vcpkg/overlay/triplets VCPKG_OVERLAY_PORTS: '${{ matrix.overlay_ports }}' steps: diff --git a/overlay/triplets/arm64-linux-release.cmake b/overlay/triplets/arm64-linux-release.cmake new file mode 100644 index 0000000..63b1506 --- /dev/null +++ b/overlay/triplets/arm64-linux-release.cmake @@ -0,0 +1,11 @@ +set(VCPKG_TARGET_ARCHITECTURE arm64) +set(VCPKG_CRT_LINKAGE dynamic) +set(VCPKG_LIBRARY_LINKAGE static) + +set(VCPKG_CMAKE_SYSTEM_NAME Linux) + +set(VCPKG_BUILD_TYPE release) + +if("${PORT}" STREQUAL "benchmark") + set(VCPKG_CMAKE_CONFIGURE_OPTIONS -DRUN_HAVE_POSIX_REGEX=0) +endif() diff --git a/scripts/install-ubuntu-deps b/scripts/install-ubuntu-deps index 3e6a1ca..7706861 100755 --- a/scripts/install-ubuntu-deps +++ b/scripts/install-ubuntu-deps @@ -7,26 +7,96 @@ if ! command -v apt-get >/dev/null; then exit 1 fi -echo "==> Installing system dependencies with APT..." +triplet_to_deb_arch() { + if [ -n "$1" ]; then + case "$1" in + x64-*) echo amd64;; + arm64-*) echo arm64;; + *) echo "Unsupported triplet: $1"; return 1;; + esac + fi +} + +triplet_to_gcc_arch() { + if [ -n "$1" ]; then + case "$1" in + x64-*) echo x86-64;; + arm64-*) echo aarch64;; + *) echo "Unsupported triplet: $1"; return 1;; + esac + fi +} + +deb_arch_to_mirror() { + if [ -n "$1" ]; then + case "$1" in + amd64|i386) echo "http://archive.ubuntu.com/ubuntu";; + *) echo "http://ports.ubuntu.com/ubuntu-ports";; + esac + fi +} + +echo "==> Updating APT..." sudo apt-get update -sudo apt-get install -y \ - autoconf-archive \ - autotools-dev \ - ccache \ - cmake \ - libasound2-dev \ - '^libxcb.*-dev' \ - libx11-xcb-dev \ - libgl1-mesa-dev \ - libglu1-mesa-dev \ - libsleef-dev \ - libudev-dev \ - libupower-glib-dev \ - libtool \ - libxrender-dev \ - libxi-dev \ - libxkbcommon-dev \ - libxkbcommon-x11-dev \ - mesa-common-dev \ - nasm \ + +echo "==> Installing host dependencies with APT..." +host_deps=( + autoconf-archive + autotools-dev + ccache + cmake + libtool + nasm ninja-build +) +sudo apt-get install -y "${host_deps[@]}" + +host="$VCPKG_DEFAULT_HOST_TRIPLET" +target="$VCPKG_DEFAULT_TRIPLET" + +host_deb_arch="$(triplet_to_deb_arch "$host")" +target_deb_arch="$(triplet_to_deb_arch "$target")" +target_gcc_arch="$(triplet_to_gcc_arch "$target")" +target_mirror="$(deb_arch_to_mirror "$target_deb_arch")" + +if [[ -n "$host" && -n "$target" && "$host" != "$target" ]]; then + echo "==> Installing cross-compilation tools with APT..." + sudo apt-get install -y "g++-$target_gcc_arch-linux-gnu" + + if [ -z "$(dpkg --print-foreign-architectures | grep "$target_arch")" ]; then + echo "==> Adding target mirror to APT sources..." + ubuntu_version="$(cat /etc/os-release | grep VERSION_CODENAME | cut -d '=' -f 2-)" + sudo sed -i "s/deb \([a-z]\)/deb [arch=$host_deb_arch] \1/" /etc/apt/sources.list + sudo bash -c "{ for repo_suffix in '' '-updates'; do echo \"deb [arch=$target_deb_arch] $target_mirror $ubuntu_version\$repo_suffix main multiverse universe\"; done; cat /etc/apt/sources.list; } > /etc/apt/sources.list.new" + sudo mv /etc/apt/sources.list{.new,} + cat /etc/apt/sources.list + + echo "==> Adding target architecture to APT..." + sudo dpkg --add-architecture "$target_deb_arch" + sudo apt-get update + fi +fi + +echo "==> Installing target dependencies with APT..." +target_deps=( + libasound2-dev + '^libxcb.*-dev' + libx11-xcb-dev + libgl1-mesa-dev + libglu1-mesa-dev + libsleef-dev + libudev-dev + libupower-glib-dev + libxrender-dev + libxi-dev + libxkbcommon-dev + libxkbcommon-x11-dev + mesa-common-dev +) +if [ -n "$target_deb_arch" ]; then + # We need the packages for the host architecture too, since some packages + # (e.g. Qt) have to be built for the host too during cross compilation + sudo apt-get install -y "${target_deps[@]}" "${target_deps[@]/%/:$target_deb_arch}" +else + sudo apt-get install -y "${target_deps[@]}" +fi diff --git a/vars/vcpkg.sh b/vars/vcpkg.sh index b6a2446..29bd905 100644 --- a/vars/vcpkg.sh +++ b/vars/vcpkg.sh @@ -4,5 +4,5 @@ if [ -z "$VCPKG_ROOT" ]; then export VCPKG_ROOT="$rootdir/vcpkg" fi -export VCPKG_OVERLAY_TRIPLETS="$VCPKG_ROOT/overlay/triplets" +export VCPKG_OVERLAY_TRIPLETS="$rootdir/overlay/triplets:$VCPKG_ROOT/overlay/triplets" export VCPKG_OVERLAY_PORTS="$VCPKG_ROOT/overlay/osx:$VCPKG_ROOT/overlay/ports"