#!/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 armv7-unknown-linux-gnueabihf

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

[properties]

[host_machine]
system = 'linux'
cpu_family = 'arm'
cpu = 'arm7hlf'
endian = 'little'
EOF
