updating uhdk to 0.17.0
This commit is contained in:
parent
019d08cbfc
commit
8dabc0ffb9
|
|
@ -56,11 +56,11 @@ pub fn build(b: *std.Build) void {
|
|||
|
||||
// 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, use_llvm: ?bool, shared: bool, instrumented: bool) *std.Build.Step.Compile {
|
||||
pub fn createLibrary(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.lang.Optimize, use_llvm: ?bool, shared: bool, instrumented: bool) *std.Build.Step.Compile {
|
||||
return createLibraryNamed(b, target, optimize, use_llvm, shared, instrumented, if (instrumented) "uhdk-instrumented" else "uhdk");
|
||||
}
|
||||
|
||||
fn createLibraryNamed(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, use_llvm: ?bool, shared: bool, instrumented: bool, artifact_name: []const u8) *std.Build.Step.Compile {
|
||||
fn createLibraryNamed(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.lang.Optimize, use_llvm: ?bool, shared: bool, instrumented: bool, artifact_name: []const u8) *std.Build.Step.Compile {
|
||||
std.debug.assert(!shared or !instrumented);
|
||||
|
||||
const module = b.createModule(.{
|
||||
|
|
@ -68,7 +68,7 @@ fn createLibraryNamed(b: *std.Build, target: std.Build.ResolvedTarget, optimize:
|
|||
.target = target,
|
||||
.optimize = optimize,
|
||||
.link_libc = true,
|
||||
.unwind_tables = if (optimize == .ReleaseSmall) .none else null,
|
||||
.unwind_tables = if (optimize == .small) .none else null,
|
||||
});
|
||||
|
||||
const native = b.addTranslateC(.{
|
||||
|
|
@ -124,7 +124,7 @@ fn createLibraryNamed(b: *std.Build, target: std.Build.ResolvedTarget, optimize:
|
|||
return lib;
|
||||
}
|
||||
|
||||
pub fn createProfileModule(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, enabled: bool) *std.Build.Module {
|
||||
pub fn createProfileModule(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.lang.Optimize, enabled: bool) *std.Build.Module {
|
||||
const options = b.addOptions();
|
||||
options.addOption(bool, "enabled", enabled);
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,138 @@
|
|||
const std = @import("std");
|
||||
|
||||
pub fn build(b: *std.Build) void {
|
||||
const target = b.standardTargetOptions(.{});
|
||||
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
const use_llvm = b.option(bool, "use_llvm", "Use LLVM for Zig compilation") orelse null;
|
||||
const shared = b.option(bool, "shared", "Build libuhdk as a shared library instead of static") orelse false;
|
||||
const tracy = b.option(bool, "tracy", "Emit Tracy 0.14.1 on-demand hooks; consumer must link the client") orelse false;
|
||||
|
||||
if (tracy and shared) @panic("Tracy instrumentation requires static linking");
|
||||
|
||||
const lib = createLibraryNamed(b, target, optimize, use_llvm, shared, tracy, "uhdk");
|
||||
const module = lib.root_module;
|
||||
const install_lib = b.addInstallArtifact(lib, .{});
|
||||
const install_headers = b.addInstallDirectory(.{
|
||||
.source_dir = b.path("include"),
|
||||
.install_dir = .header,
|
||||
.install_subdir = "",
|
||||
});
|
||||
|
||||
const lib_step = b.step("lib", "Build and install the Uhdk library and headers");
|
||||
lib_step.dependOn(&install_lib.step);
|
||||
lib_step.dependOn(&install_headers.step);
|
||||
b.getInstallStep().dependOn(&install_lib.step);
|
||||
b.getInstallStep().dependOn(&install_headers.step);
|
||||
|
||||
const unit = b.addTest(.{ .root_module = module });
|
||||
|
||||
const check_step = b.step("check", "Compile library and core tests without running them");
|
||||
check_step.dependOn(&lib.step);
|
||||
check_step.dependOn(&unit.step);
|
||||
|
||||
const unit_run = b.addRunArtifact(unit);
|
||||
b.step("test", "Run core library tests").dependOn(&unit_run.step);
|
||||
|
||||
const public_c = b.addTranslateC(.{
|
||||
.root_source_file = b.path("include/uhdk.h"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
public_c.defineCMacro("UHDK_ENABLE_OPENGL", "1");
|
||||
public_c.defineCMacro("UHDK_ENABLE_NATIVE", "1");
|
||||
public_c.addIncludePath(b.path("include"));
|
||||
|
||||
if (shared)
|
||||
public_c.defineCMacro("UHDK_SHARED", "1");
|
||||
|
||||
const public_module = b.addModule("uhdk", .{
|
||||
.root_source_file = public_c.getOutput(),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
public_module.linkLibrary(lib);
|
||||
}
|
||||
|
||||
// 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, use_llvm: ?bool, shared: bool, instrumented: bool) *std.Build.Step.Compile {
|
||||
return createLibraryNamed(b, target, optimize, use_llvm, shared, instrumented, if (instrumented) "uhdk-instrumented" else "uhdk");
|
||||
}
|
||||
|
||||
fn createLibraryNamed(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, use_llvm: ?bool, shared: bool, instrumented: bool, artifact_name: []const u8) *std.Build.Step.Compile {
|
||||
std.debug.assert(!shared or !instrumented);
|
||||
|
||||
const module = b.createModule(.{
|
||||
.root_source_file = b.path("src/root.zig"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.link_libc = true,
|
||||
.unwind_tables = if (optimize == .ReleaseSmall) .none else null,
|
||||
});
|
||||
|
||||
const native = b.addTranslateC(.{
|
||||
.root_source_file = b.path("src/native.h"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
|
||||
native.defineCMacro("UHDK_ENABLE_OPENGL", "1");
|
||||
native.addIncludePath(b.path("include"));
|
||||
module.addImport("native", native.createModule());
|
||||
module.addImport("profile", createProfileModule(b, target, optimize, instrumented));
|
||||
module.addIncludePath(b.path("include"));
|
||||
module.addIncludePath(b.path("src"));
|
||||
|
||||
if (instrumented)
|
||||
module.addCMacro("UHDK_INTERNAL_TRACY", "1");
|
||||
|
||||
if (target.result.os.tag == .macos) {
|
||||
module.addCSourceFile(.{
|
||||
.file = b.path("src/macos/native.m"),
|
||||
.flags = &.{
|
||||
"-fobjc-arc", "-fblocks", "-Wno-deprecated-declarations",
|
||||
"-Wall", "-Wextra", "-Werror",
|
||||
},
|
||||
});
|
||||
module.linkFramework("Cocoa", .{});
|
||||
module.linkFramework("OpenGL", .{});
|
||||
module.linkFramework("CoreServices", .{});
|
||||
module.linkFramework("CoreVideo", .{});
|
||||
} else if (target.result.os.tag == .linux) {
|
||||
@import("src/linux/build.zig").configure(b, module, target, optimize);
|
||||
} else {
|
||||
module.addCSourceFile(.{ .file = b.path("src/windows/native.c"), .flags = &.{ "-std=c11", "-Wall", "-Wextra", "-Werror", "-DUNICODE", "-D_UNICODE" } });
|
||||
for ([_][]const u8{ "user32", "gdi32", "opengl32", "shell32", "ole32", "uuid", "imm32", "comctl32", "shlwapi", "advapi32", "api-ms-win-core-synch-l1-2-0" }) |name| module.linkSystemLibrary(name, .{});
|
||||
}
|
||||
|
||||
module.addCSourceFile(.{ .file = b.path("src/gl_loader.c"), .flags = &.{ "-std=c99", "-Wall", "-Wextra", "-Werror", "-fvisibility=hidden" } });
|
||||
module.addCSourceFile(.{ .file = b.path("src/platform_io.c"), .flags = &.{ "-std=c11", "-Wall", "-Wextra", "-Werror" } });
|
||||
|
||||
const lib = b.addLibrary(.{
|
||||
.name = artifact_name,
|
||||
.linkage = if (shared) .dynamic else .static,
|
||||
.use_llvm = use_llvm,
|
||||
.root_module = module,
|
||||
});
|
||||
if (shared and target.result.os.tag == .linux)
|
||||
lib.version_script = b.path("src/linux/exports.map");
|
||||
|
||||
// temp
|
||||
// lib.root_module.strip = false;
|
||||
|
||||
return lib;
|
||||
}
|
||||
|
||||
pub fn createProfileModule(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, enabled: bool) *std.Build.Module {
|
||||
const options = b.addOptions();
|
||||
options.addOption(bool, "enabled", enabled);
|
||||
|
||||
const profile = b.createModule(.{
|
||||
.root_source_file = b.path("src/Profile.zig"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
profile.addOptions("profile_options", options);
|
||||
return profile;
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
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;
|
||||
const verify_stack_order = builtin.mode == .debug or builtin.mode == .safe;
|
||||
|
||||
// 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.
|
||||
|
|
|
|||
|
|
@ -56,9 +56,9 @@ fn snapshot(object: *Resource, desc: [*c]const c.uhdk_tray_desc) !*Resource.Tray
|
|||
s.* = .{ .arena = .init(object.gpa), .desc = d };
|
||||
errdefer s.arena.deinit();
|
||||
const a = s.arena.allocator();
|
||||
s.desc.id = abi.textSpan(try a.dupeZ(u8, abi.textBytes(d.id)));
|
||||
s.desc.title = abi.textSpan(try a.dupeZ(u8, abi.textBytes(d.title)));
|
||||
s.desc.tooltip = abi.textSpan(try a.dupeZ(u8, abi.textBytes(d.tooltip)));
|
||||
s.desc.id = abi.textSpan(try a.dupeSentinel(u8, abi.textBytes(d.id), 0));
|
||||
s.desc.title = abi.textSpan(try a.dupeSentinel(u8, abi.textBytes(d.title), 0));
|
||||
s.desc.tooltip = abi.textSpan(try a.dupeSentinel(u8, abi.textBytes(d.tooltip), 0));
|
||||
s.desc.icon.pixels = try abi.copyBytes(a, icon.pixels);
|
||||
if (d.menu) |menu| runtime.retain(runtime.fromObjectHandle(menu));
|
||||
return s;
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ export fn z_file_init(
|
|||
@memcpy(std.mem.sliceAsBytes(wide), abi.bytes(path));
|
||||
object.payload.file.path = std.unicode.wtf16LeToWtf8AllocZ(arena, wide) catch return abi.OOM;
|
||||
} else {
|
||||
object.payload.file.path = arena.dupeZ(u8, abi.bytes(path)) catch return abi.OOM;
|
||||
object.payload.file.path = arena.dupeSentinel(u8, abi.bytes(path), 0) catch return abi.OOM;
|
||||
}
|
||||
|
||||
object.payload.file.uri = arena.dupe(u8, abi.textBytes(uri)) catch return abi.OOM;
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ test "poll allocation failure keeps queued terminal completion retryable" {
|
|||
|
||||
application.main_thread = std.Thread.getCurrentId();
|
||||
const handle = runtime.toAppHandle(application);
|
||||
var bytes = [_]u8{42} ** 20000;
|
||||
var bytes: [20000]u8 = @splat(42);
|
||||
var event = std.mem.zeroes(c.z_event);
|
||||
event.type = c.UHDK_EVENT_REQUEST_DONE;
|
||||
event.data.request = .{ .tag = 123, .kind = c.UHDK_REQUEST_FILE_READ, .status = abi.OK, .diagnostic = .{ .ptr = null, .len = 0 }, .value = .{ .bytes = .{ .ptr = &bytes, .len = bytes.len } } };
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ const n = @import("native");
|
|||
/// physical positions, independently of the compositor-supplied XKB layout.
|
||||
pub fn physical(code: u32) u32 {
|
||||
const map = comptime blk: {
|
||||
var t = [_]u16{0} ** 256;
|
||||
var t: [256]u16 = @splat(0);
|
||||
const pairs = [_][2]u16{
|
||||
.{ 1, 41 }, .{ 12, 45 }, .{ 13, 46 }, .{ 14, 42 }, .{ 15, 43 }, .{ 26, 47 }, .{ 27, 48 }, .{ 28, 40 }, .{ 29, 224 },
|
||||
.{ 39, 51 }, .{ 40, 52 }, .{ 41, 53 }, .{ 42, 225 }, .{ 43, 49 }, .{ 51, 54 }, .{ 52, 55 }, .{ 53, 56 }, .{ 54, 229 },
|
||||
|
|
|
|||
|
|
@ -1,22 +1,53 @@
|
|||
const std = @import("std");
|
||||
|
||||
pub fn configure(b: *std.Build, module: *std.Build.Module, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode) void {
|
||||
pub fn configure(b: *std.Build, module: *std.Build.Module, target: std.Build.ResolvedTarget, optimize: std.lang.Optimize) void {
|
||||
const bindings = b.addTranslateC(.{
|
||||
.root_source_file = b.path("src/linux/bindings.h"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
for ([_][]const u8{ "src/linux", "src/linux/vendor/wayland", "src/linux/vendor", "src/linux/vendor/dbus", "src/linux/vendor/khronos", "src/linux/protocols/generated" }) |path| {
|
||||
|
||||
for ([_][]const u8{
|
||||
"src/linux",
|
||||
"src/linux/vendor/wayland",
|
||||
"src/linux/vendor",
|
||||
"src/linux/vendor/dbus",
|
||||
"src/linux/vendor/khronos",
|
||||
"src/linux/protocols/generated",
|
||||
}) |path| {
|
||||
bindings.addIncludePath(b.path(path));
|
||||
module.addIncludePath(b.path(path));
|
||||
}
|
||||
|
||||
module.addImport("linux_c", bindings.createModule());
|
||||
module.addCSourceFile(.{ .file = b.path("src/linux/libraries.c"), .flags = &.{ "-std=gnu11", "-Wall", "-Wextra", "-Werror", "-fvisibility=hidden" } });
|
||||
for ([_][]const u8{ "wayland", "xdg-shell", "xdg-decoration-unstable-v1", "viewporter", "fractional-scale-v1", "cursor-shape-v1", "pointer-constraints-unstable-v1", "tablet-v2", "text-input-unstable-v3", "xdg-activation-v1", "xdg-foreign-unstable-v2", "xdg-toplevel-icon-v1", "appmenu" }) |name| {
|
||||
module.addCSourceFile(.{
|
||||
.file = b.path("src/linux/libraries.c"),
|
||||
.flags = &.{ "-std=gnu11", "-Wall", "-Wextra", "-Werror", "-fvisibility=hidden" },
|
||||
});
|
||||
|
||||
for ([_][]const u8{
|
||||
"wayland",
|
||||
"xdg-shell",
|
||||
"xdg-decoration-unstable-v1",
|
||||
"viewporter",
|
||||
"fractional-scale-v1",
|
||||
"cursor-shape-v1",
|
||||
"pointer-constraints-unstable-v1",
|
||||
"tablet-v2",
|
||||
"text-input-unstable-v3",
|
||||
"xdg-activation-v1",
|
||||
"xdg-foreign-unstable-v2",
|
||||
"xdg-toplevel-icon-v1",
|
||||
"appmenu",
|
||||
}) |name| {
|
||||
module.addCSourceFile(.{
|
||||
.file = b.path(b.fmt("src/linux/protocols/generated/{s}.c", .{name})),
|
||||
.flags = &.{ "-std=c99", "-fdata-sections", "-include", b.path("src/linux/protocols/generated/private-symbols.h").getPath(b) },
|
||||
.flags = &.{
|
||||
"-std=c99",
|
||||
"-fdata-sections",
|
||||
"-include",
|
||||
"private-symbols.h",
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,9 +33,9 @@ test {
|
|||
}
|
||||
|
||||
fn checkExports(comptime module: type) void {
|
||||
for (@typeInfo(module).@"struct".decls) |declaration| {
|
||||
if (!std.mem.startsWith(u8, declaration.name, "uhdk_")) continue;
|
||||
if (@TypeOf(@field(module, declaration.name)) != @TypeOf(@field(c, declaration.name))) {
|
||||
for (@typeInfo(module).@"struct".decl_names) |declaration| {
|
||||
if (!std.mem.startsWith(u8, declaration, "uhdk_")) continue;
|
||||
if (@TypeOf(@field(module, declaration)) != @TypeOf(@field(c, declaration))) {
|
||||
@compileError("C signature mismatch: " ++ declaration.name);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue