-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
225 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,9 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
# Undo the Rosetta hack if needed. | ||
PROC_TRANSLATED="$(sysctl -n sysctl.proc_translated || true)" | ||
CURRENT_ARCH="$(uname -m)" | ||
if [[ "$PROC_TRANSLATED" == "1" && "$CURRENT_ARCH" == "x86_64" ]]; then | ||
if [[ "${MACOS_ROSETTA_HACK_UNDONE:-}" == "true" ]]; then | ||
printf "Seems like we've fallen into a loop of rosetta hack undoing, crashing the run.\n" >&2 | ||
exit 1 | ||
fi | ||
|
||
export MACOS_ROSETTA_HACK_UNDONE=true | ||
# Here we assume the native arch is arm64... | ||
set -x | ||
exec arch -arm64 "$0" "$@" | ||
fi | ||
|
||
brew install \ | ||
coreutils | ||
|
||
if [[ "$(uname -m)" == "x86_64" ]]; then | ||
echo "Intel-specific setup..." | ||
|
||
brew install \ | ||
michaeleisel/zld/zld | ||
|
||
ZLD_PATH="$(which zld)" | ||
|
||
"$ZLD_PATH" -v | ||
|
||
cat >>./.cargo/config.toml <<EOF | ||
[target.x86_64-apple-darwin] | ||
linker = "clang" | ||
rustflags = ["-C", "link-arg=-fuse-ld=${ZLD_PATH}"] | ||
EOF | ||
|
||
cat ./.cargo/config.toml | ||
fi | ||
.github/scripts/zig.sh | ||
.github/scripts/cargo-zigbuild.sh | ||
.github/scripts/use-zig.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,6 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
MOLD_GITHUB_REPO="rui314/mold" | ||
MOLD_VERSION="1.2.1" | ||
MOLD_INSTALL_PATH="${HOME}/.local" | ||
|
||
mkdir -p "$MOLD_INSTALL_PATH" | ||
wget \ | ||
-O- \ | ||
"https://github.com/$MOLD_GITHUB_REPO/releases/download/v${MOLD_VERSION}/mold-${MOLD_VERSION}-$(uname -m)-linux.tar.gz" | | ||
tar -C "$MOLD_INSTALL_PATH" --strip-components=1 -xzf - | ||
|
||
MOLD_PATH="${MOLD_INSTALL_PATH}/bin/mold" | ||
|
||
"$MOLD_PATH" --version | ||
|
||
cat >>./.cargo/config.toml <<EOF | ||
[target.x86_64-unknown-linux-gnu] | ||
linker = "clang" | ||
rustflags = ["-C", "link-arg=-fuse-ld=${MOLD_PATH}"] | ||
EOF | ||
|
||
cat ./.cargo/config.toml | ||
.github/scripts/zig.sh | ||
.github/scripts/cargo-zigbuild.sh | ||
.github/scripts/use-zig.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
.github/scripts/zig.sh | ||
.github/scripts/cargo-zigbuild.sh | ||
.github/scripts/use-zig.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
cd "$(dirname "${BASH_SOURCE[0]}")/../.." | ||
|
||
URL="$(build-utils/cargo-zigbuild-download-url)" | ||
TARGET_FILE="$(basename "$URL")" | ||
|
||
printf "Downloading %s from %s\n" "$TARGET_FILE" "$URL" | ||
curl -sSL "$URL" -o "$TARGET_FILE" | ||
|
||
maybe_sudo() { | ||
if [[ "${USE_SUDO:-}" == true ]]; then | ||
sudo "$@" | ||
else | ||
"$@" | ||
fi | ||
} | ||
|
||
extract() { | ||
maybe_sudo mkdir -p "$INSTALL_PATH" | ||
if [[ "$TARGET_FILE" == *.zip ]]; then | ||
maybe_sudo unzip -o -d "$INSTALL_PATH" "$TARGET_FILE" | ||
else | ||
maybe_sudo tar -C "$INSTALL_PATH" -xvf "$TARGET_FILE" | ||
fi | ||
} | ||
|
||
case "$(uname -s)" in | ||
"Win"* | "MINGW"*) | ||
INSTALL_PATH="$HOME/.cargo/bin" | ||
extract | ||
;; | ||
*) | ||
INSTALL_PATH="/usr/local/bin" | ||
USE_SUDO=true extract | ||
;; | ||
esac | ||
|
||
rm "$TARGET_FILE" | ||
|
||
"$INSTALL_PATH/cargo-zigbuild" --version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
setenv() { | ||
local KEY="$1" | ||
local VAL="$2" | ||
printf "%s=%s\n" "$KEY" "$VAL" >"$GITHUB_ENV" | ||
} | ||
|
||
case "$(uname -s)" in | ||
"Linux") | ||
LINKER="ld.lld" # ELF | ||
;; | ||
"Darwin") | ||
LINKER="ld64.lld" # Mach-O | ||
;; | ||
*) | ||
# Windows | ||
LINKER="lld-link" # COFF | ||
;; | ||
esac | ||
|
||
setenv CC "zig cc" | ||
setenv CXX "zig c++" | ||
setenv AR "zig ar" | ||
setenv RANLIB "zig ranlib" | ||
setenv LD "zig $LINKER" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
cd "$(dirname "${BASH_SOURCE[0]}")/../.." | ||
|
||
URL="$(build-utils/zig-download-url)" | ||
TARGET_FILE="$(basename "$URL")" | ||
|
||
printf "Downloading %s from %s\n" "$TARGET_FILE" "$URL" | ||
curl -sSL "$URL" -o "$TARGET_FILE" | ||
|
||
maybe_sudo() { | ||
if [[ "${USE_SUDO:-}" == true ]]; then | ||
sudo "$@" | ||
else | ||
"$@" | ||
fi | ||
} | ||
|
||
extract() { | ||
if [[ "$TARGET_FILE" == *.zip ]]; then | ||
EXTRACT_DIR="$(mktemp -d)" | ||
unzip -o -d "$EXTRACT_DIR" "$TARGET_FILE" | ||
maybe_sudo mkdir -p "$(dirname "$INSTALL_PATH")" | ||
maybe_sudo mv "$EXTRACT_DIR/$(basename "$TARGET_FILE" .zip)" "$INSTALL_PATH" | ||
else | ||
maybe_sudo mkdir -p "$INSTALL_PATH" | ||
maybe_sudo tar -C "$INSTALL_PATH" --strip-components=1 -xf "$TARGET_FILE" | ||
fi | ||
} | ||
|
||
case "$(uname -s)" in | ||
"Win"* | "MINGW"*) | ||
INSTALL_PATH="C:/zig" | ||
extract | ||
;; | ||
*) | ||
INSTALL_PATH="/usr/local/zig" | ||
USE_SUDO=true extract | ||
;; | ||
esac | ||
|
||
rm "$TARGET_FILE" | ||
|
||
"$INSTALL_PATH/zig" version | ||
|
||
# Add to PATH. | ||
printf "%s\n" "$INSTALL_PATH" >>"$GITHUB_PATH" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
VERSION="0.16.3" | ||
BASE_URL="https://github.com/rust-cross/cargo-zigbuild/releases" | ||
|
||
DESCRIPTOR="$(uname -s)-$(uname -m)" | ||
|
||
case "$DESCRIPTOR" in | ||
"Linux-x86_64") | ||
PACKAGE="x86_64-unknown-linux-musl.tar.gz" | ||
;; | ||
"Darwin-x86_64" | "Darwin-arm64") | ||
PACKAGE="apple-darwin.tar.gz" | ||
;; | ||
"Win"* | "MINGW"*) | ||
PACKAGE="windows-x64.zip" | ||
;; | ||
*) | ||
printf "Unsupported system: %s\n" "$DESCRIPTOR" >&2 | ||
exit 1 | ||
;; | ||
esac | ||
|
||
URL="$BASE_URL/download/v$VERSION/cargo-zigbuild-v$VERSION.$PACKAGE" | ||
|
||
printf "%s\n" "$URL" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
ZIG_VERSION="0.10.1" | ||
ZIG_BASE_URL="https://ziglang.org/download" | ||
|
||
SYSTEM="$(uname -s)" | ||
PLATFORM="$(uname -m)" | ||
EXT=".tar.xz" | ||
|
||
case "$SYSTEM" in | ||
"Linux") | ||
SYSTEM="linux" | ||
;; | ||
"Darwin") | ||
SYSTEM="macos" | ||
;; | ||
"Win"* | "MINGW"*) | ||
SYSTEM="windows" | ||
EXT=".zip" | ||
;; | ||
*) | ||
printf "Unsupported system: %s\n" "$SYSTEM" >&2 | ||
exit 1 | ||
;; | ||
esac | ||
|
||
case "$PLATFORM" in | ||
"arm64") | ||
PLATFORM="aarch64" | ||
;; | ||
esac | ||
|
||
URL="${ZIG_BASE_URL}/${ZIG_VERSION}/zig-${SYSTEM}-${PLATFORM}-${ZIG_VERSION}${EXT}" | ||
|
||
printf "%s\n" "$URL" |