#!/usr/bin/env bash
# Copyright 2021 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
set -ex

rustup target add aarch64-unknown-linux-gnu

# Generate a cross file for meson to compile for aarch64
sudo mkdir -p -m 0755 /usr/local/share/meson/cross
sudo tee /usr/local/share/meson/cross/aarch64 >/dev/null <<EOF
[binaries]
c = '/usr/bin/aarch64-linux-gnu-gcc'
cpp = '/usr/bin/aarch64-linux-gnu-g++'
ar = '/usr/bin/aarch64-linux-gnu-ar'
strip = '/usr/bin/aarch64-linux-gnu-strip'
objcopy = '/usr/bin/aarch64-linux-gnu-objcopy'
ld= '/usr/bin/aarch64-linux-gnu-ld'
pkgconfig = '/usr/bin/aarch64-linux-gnu-pkg-config'

[properties]

[host_machine]
system = 'linux'
cpu_family = 'aarch64'
cpu = 'arm64'
endian = 'little'
EOF
