summaryrefslogtreecommitdiff
path: root/ci/set-target.sh
blob: f0dfbf093c2f32419d1637d1a0584d3e8d791268 (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
30
31
32
33
34
35
36
37
38
39
40
#!/bin/sh

if [ "$#" -ne 2 ]; then
    echo "Usage: $0 OS ARCHITECTURE" >&2
    exit 1
fi

os=$1
architecture=$2

output() {
    echo "Setting ACTIONS_RUST_TARGET=$1"
    echo "ACTIONS_RUST_TARGET=$1" >> "$GITHUB_ENV"
    exit 0
}

if [ "$architecture" = "x64" ]; then
    if [ "$os" = "ubuntu-latest" ]; then
        output "x86_64-unknown-linux-gnu"
    elif [ "$os" = "macos-latest" ]; then
        output "x86_64-apple-darwin"
    elif [ "$os" = "windows-latest" ]; then
        output "x86_64-pc-windows-msvc"
    else
        echo "Unknown 64-bit OS: $os"
        exit 1
    fi
elif [ "$architecture" = "x86" ]; then
    if [ "$os" = "ubuntu-latest" ]; then
        output "i686-unknown-linux-gnu"
    elif [ "$os" = "windows-latest" ]; then
        output "i686-pc-windows-msvc"
    else
        echo "Unknown 32-bit OS: $os"
        exit 1
    fi
else
    echo "Bad architecture: $architecture"
    exit 1
fi