This commit is contained in:
Peter Li 2026-09-18 09:58:47 -07:00
parent 70f19f1652
commit 97c4b41e12
3 changed files with 11 additions and 22 deletions

View File

@ -5,16 +5,10 @@ It provides windows, input and IME, clipboard, file dialogs, drag and drop, menu
async file operations, file watching, and OpenGL context creation. The macOS
backend uses AppKit, OpenGL, and FSEvents through a private Objective-C bridge.
This directory is a standalone source package. It does not depend on the parent
repository, its examples, fonts, skills, or development tools. macOS builds require
Xcode Command Line Tools. The Windows Win32/WGL backend cross-compiles for
`x86_64-windows-gnu`; runtime verification on Windows is pending. It requires
macOS builds require Xcode Command Line Tools. The Windows Win32/WGL backend
cross-compiles for `x86_64-windows-gnu`; runtime verification on Windows is pending. It requires
Windows 10 version 1703 or later and an OpenGL 3.3-capable driver.
Private profiling hooks compile away in this standalone build. Tracy support
belongs to the parent repository's static demos; it adds no dependencies or
public ABI to this package.
## Build
```sh
@ -28,8 +22,7 @@ zig build check -Dtarget=x86_64-windows-gnu # compile only
## Use from Zig
After cloning this directory's standalone mirror into `vendor/uhdk`, add it to
`build.zig.zon`:
To use a local checkout at `vendor/uhdk`, add it to `build.zig.zon`:
```zig
.dependencies = .{
@ -53,9 +46,6 @@ OpenGL headers, and links the library and required system frameworks. The
or custom bindings. Set `.shared = true` to build a dynamic library; applications
must arrange its runtime location/rpath.
Once a standalone mirror or archive is published, `zig fetch --save=uhdk <URL>`
can replace the local path dependency. No release URL has been assigned yet.
## C interface
- [uhdk.h](include/uhdk.h): desktop API, lifecycle, ownership, and threading contracts.
@ -82,7 +72,6 @@ are not implemented. Native UTF-16 path bytes are kept separately from the WTF-8
paths passed to Zig I/O. If a native path cannot be exported losslessly as a shell
URI, URI export returns `UNSUPPORTED`; native-path export still preserves it.
## Optional profiling
`uhdk.h` includes `uhdk_profile.h`: scope, frame, thread-name and named allocation/
@ -96,13 +85,13 @@ Internal CPU and memory instrumentation is disabled by default. A static consume
can pass `.tracy = true` to `b.dependency("uhdk", ...)` (or `-Dtracy=true` when
building the archive) and link its own Tracy 0.14.1 client configured with
`TRACY_ENABLE` and `TRACY_ON_DEMAND`. UHDK never fetches or links Tracy itself.
Shared instrumentation is unsupported. Run standalone unit tests with the default
Shared instrumentation is unsupported. Run unit tests with the default
configuration; enabled instrumentation requires the consumer's linked client.
The full repository provides an example adapter under `examples/profiling`.
The `UHDK` memory pool measures requested Zig backing allocations, including
objects and arena blocks. Win32 explicit calloc/free blocks use a separate
`UHDK native` pool. OS/framework allocations and GPU memory are excluded. On-demand capture omits allocations made before connection, so it is not
a full live-heap snapshot. Failed allocations emit nothing; in-place resizes emit
`UHDK native` pool. OS/framework allocations and GPU memory are excluded.
On-demand capture omits allocations made before connection, so it is not a full
live-heap snapshot. Failed allocations emit nothing; in-place resizes emit
free + alloc. Moving reallocations use alloc/copy/free to preserve event ordering.
Disabled builds use the original allocator directly.

View File

@ -41,8 +41,8 @@ pub fn build(b: *std.Build) void {
public_module.linkLibrary(lib);
}
// The parent development build uses this to create a separate, uninstalled
// instrumented archive. Standalone consumers may opt in and supply their client.
// Create a library artifact without installing it. Instrumented static builds
// require the consumer to link a matching Tracy client.
pub fn createLibrary(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, shared: bool, instrumented: bool) *std.Build.Step.Compile {
return createLibraryNamed(b, target, optimize, shared, instrumented, if (instrumented) "uhdk-instrumented" else "uhdk");
}

View File

@ -1,10 +1,10 @@
//! Private, compile-time instrumentation. Standalone UHDK builds disable it.
//! Optional compile-time instrumentation, disabled by default.
const std = @import("std");
const builtin = @import("builtin");
pub const enabled = @import("profile_options").enabled;
const verify_stack_order = builtin.mode == .Debug or builtin.mode == .ReleaseSafe;
// Tracy 0.14.1 C ABI with TRACY_ON_DEMAND, linked only by the full repo's demos.
// Tracy 0.14.1 C ABI with TRACY_ON_DEMAND; the consumer supplies the client.
// No C header translation or references to Tracy symbols in disabled builds.
const SourceLocation = extern struct {
name: [*:0]const u8,