- Zig 100%
|
Carter Snook
7192e3c91c
Upgrade icu4x version
This is using the latest working commit of icu4x. See linusg/zig-build-icu4x#4 |
||
|---|---|---|
| .forgejo/workflows | Run CI on sakamoto | |
| src | Update zig-build-icu4x | |
| .gitignore | zig-cache -> .zig-cache | |
| build.zig | Link against 'userenv' and 'ws2_32' on Windows | |
| build.zig.zon | Upgrade icu4x version | |
| LICENSE | Update for new build API | |
| README.md | Add build.zig example | |
icu4zig
Zig language bindings for the ICU4X library using its C API under the hood (via zig-build-icu4x).
Currently under heavy development and not feature-complete!
Installation
Install using the Zig package manager's build.zig.zon. Use the provided
link() function from this packages's build.zig to set up dependencies:
conststd=@import("std");constbuild_icu4zig=@import("icu4zig");pubfnbuild(b:*std.Build)void{consttarget=b.standardTargetOptions(.{});constoptimize=b.standardOptimizeOption(.{});consticu4zig=b.dependency("icu4zig",.{.target=target,.optimize=optimize,});consticu4x=icu4zig.builder.dependency("icu4x",.{.target=target,.optimize=optimize,});constexe=b.addExecutable(.{.name="example",.root_source_file=.{.path="src/main.zig"},.target=target,.optimize=optimize,});exe.addModule("icu4zig",icu4zig);build_icu4zig.link(exe,icu4x);b.installArtifact(exe);// ...}Note that cargo is required to build ICU4X.
A note on allocations
Because ICU4X is written in Rust not every allocation can be controlled, or OOM situations be handled. There is an option to create a custom crate providing overrides for the global allocator and OOM panic handler, but those are not comparable to Zig's usual allocator pattern.
This means that things like Vec<T> resizes within the library may panic on
OOM. However, operations creating strings use an OOM-safe abstraction allowing
to provide an Allocator and handle error.OutOfMemory.