zig その2

std: Do not allocate the result for ChildProcess.init · ziglang/zig@a0a2ce9
Instead, just return ChildProcess directly. This structure does not require a stable address, so we can put it on the stack just fine. If someone wants it on the heap they should do. const proc ...
std: Do not allocate the result for ChildProcess.init · ziglang/zig@a0a2ce9 favicon https://github.com/ziglang/zig/commit/a0a2ce92ca129d28e22c63f7bace1672c43776b5
std: Do not allocate the result for ChildProcess.init · ziglang/zig@a0a2ce9

再度使ってみるべく環境整備から。

zls の master を使う

どうやら @import std 以外がうまく動かないらしく、 最新版を試してみたい。

const glfw = @import("glfw");

https://ziglang.org/download/ からダウンロードするべし。

いちおう build を 試みた

zls の最新判を試すには、 zig の最新版(0.9.1じゃなくてmaster)が必要。 zig のビルドには static build の llvm-13 が必要。 Windows では頓挫した。 しかし、最近 gentoo を育成しているのでこっちでやってみる。

cmake -B build -S .

してみたが、最後にリンクエラーが出る。

undefined reference to clang::SourceManager::getFilename

しかし、 gentoo の emerge に dev-lang/zig-9999 があった。 これを使って zls がビルドできた。 glfw のインテリセンスも動作した。

zig master(0.10) が変わっていて zls と gyro のビルドが通らない。

zls

gyro

std.ChildProcess.init のところ。

OpenGL やってく

を起点にやってみる。 前回は @cImport を使っているサンプルでインテリセンス効かなくて、続かなかった。 @import + 最新版zls で進めていけば慣れるかな。

gyro の使いかた

202204 現在だと、 gyro で import すると zls が解決できないような気がする。

add package

gyro add --src github hexops/mach-glfw --root src/main.zig --alias glfw

dep package

gyro add --build-dep --src github hexops/mach-glfw --root build.zig --alias build-glfw

use package

const glfw = @import("glfw");

build.zig

const pkgs = @import("deps.zig").pkgs;
const glfw = @import("build-glfw");
pub fn build(b: *Builder) void {
...
exe.addPackage(pkgs.glfw);
glfw.link(b, exe, .{});
}

zgl

libepoxy

gyro add --src github ziglibs/zgl --root zgl.zig --alias gl