summaryrefslogtreecommitdiffhomepage
path: root/scripts/utils/host
blob: 5227ded73da03f33c6860bf6c0714bb5dc109973 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env bash
# shellcheck shell=bash

# This function returns the target triple of the machine running this script

case "$(uname -s)" in
  Linux*)
    arch="$(uname -m)"
    if [[ ("${arch}" == "riscv64") ]]; then
        arch="riscv64gc"
    fi
    HOST="${arch}-unknown-linux-gnu"
    ;;
  Darwin*)
    arch="$(uname -m)"
    if [[ ("${arch}" == "arm64") ]]; then
        arch="aarch64"
    fi
    HOST="${arch}-apple-darwin"
    ;;
  MINGW*|MSYS_NT*)
    arch="$(powershell -Command "(Get-CimInstance Win32_OperatingSystem).OSArchitecture")"
    if [[ $arch == "ARM 64"* ]]; then
        HOST="aarch64-pc-windows-msvc"
    else
        HOST="x86_64-pc-windows-msvc"
    fi
    ;;
esac