4

部署 Zig (编程语言) 工具链

 9 months ago
source link: https://jixun.uk/posts/2023/deploy-zig-lang/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

部署 Zig (编程语言) 工具链

在 Linux (Ubuntu) 下部署 zig-lang 的脚本。

需要先找到需要安装的版本,可以在官方下载列表找到,本文撰写时的最新版为 0.11.0

当然,如果你需要最新的开发版本,你也可以指定 master 作版本号。

# 必须的依赖
sudo apt install -y curl jq

# 指定版本与架构。
ZIG_VER="0.11.0" # for latest release, use "master"
ZIG_ARCH="x86_64-linux"

zig_xz_url="$(curl -fsL https://ziglang.org/download/index.json \
  | jq -r '.["'"${ZIG_VER}"'"]["'"${ZIG_ARCH}"'"].tarball')"

sudo mkdir -p "/opt/zig/${ZIG_VER}" /opt/zig/
curl -fsL "${zig_xz_url}" \
  | sudo tar -Jx --strip-components=1 -C "/opt/zig/${ZIG_VER}"

# 建立一些链接
sudo ln -sf "/opt/zig/${ZIG_VER}" "/opt/zig/current"
sudo ln -sf "/opt/zig/${ZIG_VER}/zig" "/usr/local/bin/zig-${ZIG_VER}"
sudo ln -sf "/opt/zig/current/zig" "/usr/local/bin/zig"

安装完成后就可以执行 zig version 确认安装的版本了。

注意:你也可以指定某个特定版本的 zig,如 zig-0.11.0


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK