FalsePattern/koishi
The koishi C coroutine library ported to the zig build system
This is koishi, a portable C coroutine library, packaged for Zig.
First, update your build.zig.zon
:
zig fetch --save "git+https://github.com/FalsePattern/koishi/#master"
Next, add this snippet to your build.zig
script:
const koishi_dep = b.dependency("koishi", .{
.target = target,
.optimize = optimize,
});
your_compilation.linkLibrary(koishi_dep.artifact("koishi"));
This will provide koishi as a static library to your_compilation
.
If you want to use it inside a translateC step, you can do the following:
const translateC = b.addTranslateC(.{
.root_source_file = b.path("..."),
.target = target,
.optimize = optimize,
});
translateC.addIncludePath(koishi_dep.namedLazyPath("koishi_include"));
.verbose = [bool] Verbose logging for configure phase. [default: false]
.impl = [enum] Which implementation to use. Leave empty to autodetect.
Supported Values:
emscripten
fcontext
ucontext
ucontext_e2k
ucontext_sjlj
win32fiber
.threadsafe = [bool] Whether multiple coroutines can be ran on different threads at once (needs compiler support) [default: true]
.valgrind = [bool] Enable support for running under Valgrind (for debugging) [default: false]
.linkage = [enum] Whether the koishi library should be statically or dynamically linked. [default: static]
Supported Values:
static
dynamic
Using the emscripten implementation requires -s ASYNCIFY
in your emscripten linker args!
libboost is currently not supported.