Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

post/2023/10/14/zig-version-manager/

由于 Zig 还在快速开发迭代中,因此项目很有可能出现新版本 Zig 无法编译的情况,这时候一方面可以跟踪上游进展,看看是否有 workaround,另一个就是使用固定的版本来开发这个项目,显然这种方式更靠谱一些,因此这篇文章就来介绍一些管理多个 Zig 版本的方式。
Zig version manager 现在 Zig 的版本管理工具主要有如下几个:
marler8997/zigup Download and manage zig compilers tristanisham/zvm Lets you easily install/upgrade between different versions of Zig hendriknielaender/zvm Fast and simple zig version manager 他们工作方式类似,大致步骤:
https://ziglang.org/download/index.json 这个链接中解析所有版本,然后根据当前系统架构确定要安装的二进制, 创建一个类似 current 软链用来表示当前的 Zig 安装目录, 根据项目下 .zig-version 文件中指定的版本,修改 current 软链的指向,保证 PATH 中的 Zig 版本是正确的 相关实现:
https://github.com/tristanisham/zvm/blob/639dca34b4b1dcbf881fd684020222d8161e4f7a/cli/use.go#L38 https://github.com/hendriknielaender/zvm/blob/e0b1bedf1aea58c1627a983a8ef7fd8857a2ee80/src/alias.zig#L13 通用版本管理工具 asdf 鉴于社区之前的 asdf-zig 已经年久失修,zigcc 已经 fork 过来,对下载的软件包增加了 checksum 校验,防止出现中间人攻击,欢迎大家使用。
https://github.com/zigcc/asdf-zig 多版本管理是个常见的需求,比如 Python 中的 pyenv、Ruby 中的 rvm,甚至还有一个通用的框架:asdf,名字简单暴力,敲起来得心应手。安装方式可以参考官方文档的 Getting Started。

https://ziglang.cc/post/2023/10/14/zig-version-manager/

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
0 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.