Repository navigation
Expand file tree
/
Copy pathaction.yml
More file actions
70 lines (61 loc) · 2.62 KB
/
Copy pathaction.yml
File metadata and controls
70 lines (61 loc) · 2.62 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
name: "wild"
description: "Use the Wild linker when building Rust code for Linux or WebAssembly"
author: "Wild authors"
inputs:
wild-version:
description: "Wild version to use"
required: false
default: "0.11.0"
download-retries:
description: "Number of times to retry the Wild download on transient failures (passed to curl --retry). curl uses exponential backoff between retries."
required: false
default: "5"
runs:
using: "composite"
steps:
- run: |
case "$RUNNER_ARCH" in
X64) target_arch="x86_64" ;;
ARM64) target_arch="aarch64" ;;
*) echo "Unsupported architecture: $RUNNER_ARCH" >&2; exit 1 ;;
esac
mkdir "${RUNNER_TEMP}/wild-install"
url="https://github.com/wild-linker/wild/releases/download/${{ inputs.wild-version }}/wild-linker-${{ inputs.wild-version }}-${target_arch}-unknown-linux-gnu.tar.gz"
archive="${RUNNER_TEMP}/wild.tar.gz"
curl --fail-with-body --show-error --location \
--retry "${{ inputs.download-retries }}" --retry-all-errors \
--output "${archive}" \
"${url}"
tar -xzf "${archive}" -C "${RUNNER_TEMP}/wild-install" --strip-components=1
rm -f "${archive}"
mkdir -p "$HOME/.cargo"
wild_bin="${RUNNER_TEMP}/wild-install/wild"
config="$HOME/.cargo/config.toml"
add_target_config() {
local target_key="$1"
local body="$2"
if grep -F -x -q "[${target_key}]" "$config" 2>/dev/null; then
return 0
fi
printf '# Added by wild GitHub Action\n[%s]\n%s\n\n' "$target_key" "$body" >>"$config"
}
printf -v linux_body 'linker = "clang"\nrustflags = ["-Clink-arg=--ld-path=%s"]' "$wild_bin"
for libc in gnu musl; do
add_target_config "target.${target_arch}-unknown-linux-${libc}" "$linux_body"
done
wild_version="${{ inputs.wild-version }}"
wild_version="${wild_version#v}"
wild_version="${wild_version%%+*}"
wild_version="${wild_version%%-*}"
if [[ "$wild_version" =~ ^([0-9]+)\.([0-9]+)(\.[0-9]+)?$ ]]; then
wasm_major=$((10#${BASH_REMATCH[1]}))
wasm_minor=$((10#${BASH_REMATCH[2]}))
if (( wasm_major > 0 || wasm_minor >= 11 )); then
printf -v wasm_body 'rustflags = ["-C", "linker=%s", "-C", "linker-flavor=wasm-ld"]' "$wild_bin"
for triple in wasm32-unknown-unknown wasm32-wasip1 wasm32-wasip1-threads; do
add_target_config "target.${triple}" "$wasm_body"
done
fi
fi
shell: bash
if: runner.os == 'Linux'