diff --git a/.gitmodules b/.gitmodules index 6a4ca53b7..70a7fdbcb 100644 --- a/.gitmodules +++ b/.gitmodules @@ -27,7 +27,7 @@ url = https://github.com/cimgui/cimgui.git [submodule "vendor/pixman"] path = vendor/pixman - url = https://github.com/freedesktop/pixman.git + url = https://gitlab.freedesktop.org/pixman/pixman.git [submodule "vendor/zig-js"] path = vendor/zig-js url = https://github.com/mitchellh/zig-js.git diff --git a/build.zig b/build.zig index a62912b62..0be2295a5 100644 --- a/build.zig +++ b/build.zig @@ -427,7 +427,6 @@ pub fn build(b: *std.Build) !void { .target = wasm_crosstarget, .optimize = optimize, }); - wasm.setOutputDir("zig-out"); wasm.addOptions("build_options", exe_options); // So that we can use web workers with our wasm binary @@ -442,8 +441,12 @@ pub fn build(b: *std.Build) !void { // Wasm-specific deps _ = try addDeps(b, wasm, true); + // Install + const wasm_install = b.addInstallArtifact(wasm); + wasm_install.dest_dir = .{ .prefix = {} }; + const step = b.step("wasm", "Build the wasm library"); - step.dependOn(&wasm.step); + step.dependOn(&wasm_install.step); // We support tests via wasmtime. wasmtime uses WASI so this // isn't an exact match to our freestanding target above but @@ -468,8 +471,8 @@ pub fn build(b: *std.Build) !void { defer conformance_exes.deinit(); break :blk conformance_exes.get(name) orelse return error.InvalidConformance; } else exe; - const run_cmd = run_exe.run(); - run_cmd.step.dependOn(&run_exe.step); + + const run_cmd = b.addRunArtifact(run_exe); if (b.args) |args| { run_cmd.addArgs(args); } @@ -487,14 +490,14 @@ pub fn build(b: *std.Build) !void { .name = "ghostty-test", .root_source_file = .{ .path = "src/main.zig" }, .target = target, + .filter = test_filter, }); { - if (emit_test_exe) main_test.install(); - main_test.setFilter(test_filter); + if (emit_test_exe) b.installArtifact(main_test); _ = try addDeps(b, main_test, true); main_test.addOptions("build_options", exe_options); - const test_run = main_test.run(); + const test_run = b.addRunArtifact(main_test); test_step.dependOn(&test_run.step); } @@ -513,7 +516,7 @@ pub fn build(b: *std.Build) !void { .root_source_file = module.source_file, .target = target, }); - if (emit_test_exe) test_exe.install(); + if (emit_test_exe) b.installArtifact(test_exe); _ = try addDeps(b, test_exe, true); // if (pkg.dependencies) |children| { @@ -521,7 +524,7 @@ pub fn build(b: *std.Build) !void { // try test_.packages.appendSlice(children); // } - const test_run = test_exe.run(); + const test_run = b.addRunArtifact(test_exe); test_step.dependOn(&test_run.step); } } @@ -785,7 +788,7 @@ fn benchSteps( .optimize = optimize, }); c_exe.setMainPkgPath("./src"); - if (install) c_exe.install(); + if (install) b.installArtifact(c_exe); _ = try addDeps(b, c_exe, true); } } @@ -823,8 +826,10 @@ fn conformanceSteps( .target = target, .optimize = optimize, }); - c_exe.setOutputDir("zig-out/bin/conformance"); - c_exe.install(); + + const install = b.addInstallArtifact(c_exe); + install.dest_sub_path = "conformance"; + b.getInstallStep().dependOn(&install.step); // Store the mapping try map.put(name, c_exe); diff --git a/flake.lock b/flake.lock index 2d00b8f84..916cf719b 100644 --- a/flake.lock +++ b/flake.lock @@ -126,11 +126,11 @@ "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1680782874, - "narHash": "sha256-H/ATZl/uXdo5ruyDlGlJE2uSO7g4/+D+1048Uk+8Ewc=", + "lastModified": 1683461227, + "narHash": "sha256-IhHbNNK+XeiKEvsdnMTiFw99ck2Iwdrt2gCbWXrmlRc=", "owner": "mitchellh", "repo": "zig-overlay", - "rev": "0517edcc1356ed89aec9751bfa123fe5f8b88e20", + "rev": "6ab09a96babc526ba9743ebab3f7863d140a73a5", "type": "github" }, "original": { diff --git a/pkg/fontconfig/build.zig b/pkg/fontconfig/build.zig index 3bd47193b..6a1d3b019 100644 --- a/pkg/fontconfig/build.zig +++ b/pkg/fontconfig/build.zig @@ -116,7 +116,7 @@ pub fn buildFontconfig( "-DHAVE_RAND", "-DHAVE_RANDOM", "-DHAVE_LRAND48", - "-DHAVE_RANDOM_R", + //"-DHAVE_RANDOM_R", "-DHAVE_RAND_R", "-DHAVE_READLINK", "-DHAVE_FSTATVFS", diff --git a/pkg/pixman/build.zig b/pkg/pixman/build.zig index 4a1650a21..77847fa75 100644 --- a/pkg/pixman/build.zig +++ b/pkg/pixman/build.zig @@ -28,10 +28,10 @@ pub fn build(b: *std.Build) !void { tests.setBuildMode(mode); tests.setTarget(target); _ = try link(b, tests, .{}); - tests.install(); + b.installArtifact(tests); const test_step = b.step("test", "Run tests"); - const tests_run = tests.run(); + const tests_run = b.addRunArtifact(tests); test_step.dependOn(&tests_run.step); } diff --git a/pkg/pixman/image.zig b/pkg/pixman/image.zig index 51a868095..7a2645d6d 100644 --- a/pkg/pixman/image.zig +++ b/pkg/pixman/image.zig @@ -171,7 +171,7 @@ test "create and destroy" { const len = height * @intCast(usize, stride); var data = try alloc.alloc(u32, len); defer alloc.free(data); - std.mem.set(u32, data, 0); + @memset(data, 0); const img = try Image.createBitsNoClear(.g1, width, height, data.ptr, stride); try testing.expectEqual(@as(c_int, height), img.getHeight()); try testing.expectEqual(@as(c_int, stride), img.getStride()); @@ -193,7 +193,7 @@ test "fill boxes a1" { const len = height * @intCast(usize, stride); var data = try alloc.alloc(u32, len); defer alloc.free(data); - std.mem.set(u32, data, 0); + @memset(data, 0); const img = try Image.createBitsNoClear(format, width, height, data.ptr, stride); defer _ = img.unref(); diff --git a/src/font/Atlas.zig b/src/font/Atlas.zig index 54efddcc1..4630bbed4 100644 --- a/src/font/Atlas.zig +++ b/src/font/Atlas.zig @@ -275,7 +275,7 @@ pub fn grow(self: *Atlas, alloc: Allocator, size_new: u32) Allocator.Error!void // If our allocation and rectangle add succeeded, we can go ahead // and persist our new size and copy over the old data. self.size = size_new; - std.mem.set(u8, self.data, 0); + @memset(self.data, 0); self.set(.{ .x = 0, // don't bother skipping border so we can avoid strides .y = 1, // skip the first border row @@ -291,7 +291,7 @@ pub fn grow(self: *Atlas, alloc: Allocator, size_new: u32) Allocator.Error!void // Empty the atlas. This doesn't reclaim any previously allocated memory. pub fn clear(self: *Atlas) void { self.modified = true; - std.mem.set(u8, self.data, 0); + @memset(self.data, 0); self.nodes.clearRetainingCapacity(); // Add our initial rectangle. This is the size of the full texture @@ -403,7 +403,7 @@ pub const Wasm = struct { // Convert from A8 to RGBA so every 4th byte is set to a value. var buf: []u8 = try alloc.alloc(u8, self.data.len * 4); errdefer alloc.free(buf); - std.mem.set(u8, buf, 0); + @memset(buf, 0); for (self.data, 0..) |value, i| { buf[(i * 4) + 3] = value; } diff --git a/src/font/face/freetype.zig b/src/font/face/freetype.zig index 87ff689bb..19c886edc 100644 --- a/src/font/face/freetype.zig +++ b/src/font/face/freetype.zig @@ -440,7 +440,7 @@ pub const Face = struct { // cell height (mainly: non-scalable fonts, i.e. emoji) break :underline_pos cell_height - 1; }; - const underline_thickness = @max(1, fontUnitsToPxY( + const underline_thickness = @max(@as(f32, 1), fontUnitsToPxY( face, face.handle.*.underline_thickness, )); @@ -461,7 +461,7 @@ pub const Face = struct { break :pos @intToFloat(f32, ascender_px - declared_px); }, - .thickness = @max(1, fontUnitsToPxY(face, os2.yStrikeoutSize)), + .thickness = @max(@as(f32, 1), fontUnitsToPxY(face, os2.yStrikeoutSize)), } else .{ .pos = cell_baseline * 0.6, .thickness = underline_thickness, diff --git a/src/font/sprite/Box.zig b/src/font/sprite/Box.zig index f7635bd15..3e5d87b74 100644 --- a/src/font/sprite/Box.zig +++ b/src/font/sprite/Box.zig @@ -2178,7 +2178,7 @@ fn draw_light_arc( // Allocate our supersample sized canvas var ss_data = try alloc.alloc(u8, height * width); defer alloc.free(ss_data); - std.mem.set(u8, ss_data, 0); + @memset(ss_data, 0); const height_pixels = self.height; const width_pixels = self.width; diff --git a/src/font/sprite/canvas.zig b/src/font/sprite/canvas.zig index 28f17337a..5cc4842d3 100644 --- a/src/font/sprite/canvas.zig +++ b/src/font/sprite/canvas.zig @@ -310,7 +310,7 @@ const PixmanImpl = struct { // by 4 since u32 / u8 = 4. var data = try alloc.alloc(u32, len / 4); errdefer alloc.free(data); - std.mem.set(u32, data, 0); + @memset(data, 0); // Create the image we'll draw to const img = try pixman.Image.createBitsNoClear( diff --git a/src/renderer/Metal.zig b/src/renderer/Metal.zig index 47fff2eea..371a8f35f 100644 --- a/src/renderer/Metal.zig +++ b/src/renderer/Metal.zig @@ -1116,12 +1116,21 @@ fn syncCells( } // We can fit within the vertex buffer so we can just replace bytes. - const ptr = target.msgSend(?[*]u8, objc.sel("contents"), .{}) orelse { - log.warn("buf_cells contents ptr is null", .{}); - return error.MetalFailed; + const dst = dst: { + const ptr = target.msgSend(?[*]u8, objc.sel("contents"), .{}) orelse { + log.warn("buf_cells contents ptr is null", .{}); + return error.MetalFailed; + }; + + break :dst ptr[0..req_bytes]; }; - @memcpy(ptr, @ptrCast([*]const u8, cells.items.ptr), req_bytes); + const src = src: { + const ptr = @ptrCast([*]const u8, cells.items.ptr); + break :src ptr[0..req_bytes]; + }; + + @memcpy(dst, src); } /// Sync the atlas data to the given texture. This copies the bytes diff --git a/src/renderer/size.zig b/src/renderer/size.zig index 0be4e6476..7f3f3578b 100644 --- a/src/renderer/size.zig +++ b/src/renderer/size.zig @@ -105,11 +105,12 @@ pub const Padding = struct { const padding_top = @min(padding_left, @floor(space_bot / 2)); const padding_bot = space_bot - padding_top; + const zero = @as(f32, 0); return .{ - .top = @max(0, padding_top), - .bottom = @max(0, padding_bot), - .right = @max(0, padding_right), - .left = @max(0, padding_left), + .top = @max(zero, padding_top), + .bottom = @max(zero, padding_bot), + .right = @max(zero, padding_right), + .left = @max(zero, padding_left), }; } diff --git a/src/terminal/Screen.zig b/src/terminal/Screen.zig index 6479367e8..1ea952b12 100644 --- a/src/terminal/Screen.zig +++ b/src/terminal/Screen.zig @@ -319,7 +319,7 @@ pub const Row = struct { // If our row has no graphemes, then this is a fast copy if (!self.storage[0].header.flags.grapheme) { - std.mem.set(StorageCell, self.storage[start + 1 .. len + 1], .{ .cell = cell }); + @memset(self.storage[start + 1 .. len + 1], .{ .cell = cell }); return; } @@ -1013,7 +1013,7 @@ pub fn scrollRegionUp(self: *Screen, top: RowIndex, bottom: RowIndex, count: usi // is a lot more of that. const dst_offset = total_copy; const dst = buf[dst_offset..]; - std.mem.set(StorageCell, dst, .{ .cell = self.cursor.pen }); + @memset(dst, .{ .cell = self.cursor.pen }); // Then we make sure our row headers are zeroed out. We set // the value to a dirty row header so that the renderer re-draws. @@ -1093,7 +1093,7 @@ pub fn scrollRegionUp(self: *Screen, top: RowIndex, bottom: RowIndex, count: usi if (offset >= slices[i].len) continue; const dst = slices[i][offset..]; - std.mem.set(StorageCell, dst, .{ .cell = self.cursor.pen }); + @memset(dst, .{ .cell = self.cursor.pen }); var j: usize = offset; while (j < slices[i].len) : (j += self.cols + 1) { @@ -1557,8 +1557,7 @@ pub fn selectionString( // we use are correct by default. if (std.debug.runtime_safety) { if (cell.header.id == 0) { - std.mem.set( - StorageCell, + @memset( slice[i + 1 .. i + 1 + self.cols], .{ .cell = .{} }, ); diff --git a/src/terminal/Tabstops.zig b/src/terminal/Tabstops.zig index 4b30d9094..894e9964b 100644 --- a/src/terminal/Tabstops.zig +++ b/src/terminal/Tabstops.zig @@ -145,8 +145,8 @@ pub fn capacity(self: Tabstops) usize { /// Unset all tabstops and then reset the initial tabstops to the given /// interval. An interval of 0 sets no tabstops. pub fn reset(self: *Tabstops, interval: usize) void { - std.mem.set(Unit, &self.prealloc_stops, 0); - std.mem.set(Unit, self.dynamic_stops, 0); + @memset(&self.prealloc_stops, 0); + @memset(self.dynamic_stops, 0); if (interval > 0) { var i: usize = interval - 1; diff --git a/src/terminal/circ_buf.zig b/src/terminal/circ_buf.zig index 926addb63..b60f64b4b 100644 --- a/src/terminal/circ_buf.zig +++ b/src/terminal/circ_buf.zig @@ -28,7 +28,7 @@ pub fn CircBuf(comptime T: type, comptime default: T) type { /// Initialize a new circular buffer that can store size elements. pub fn init(alloc: Allocator, size: usize) !Self { var buf = try alloc.alloc(T, size); - std.mem.set(T, buf, default); + @memset(buf, default); return Self{ .storage = buf, @@ -60,7 +60,7 @@ pub fn CircBuf(comptime T: type, comptime default: T) type { // If we grew, we need to set our new defaults. We can add it // at the end since we rotated to start. if (size > prev_cap) { - std.mem.set(T, self.storage[prev_cap..], default); + @memset(self.storage[prev_cap..], default); // Fix up our head/tail if (self.full) { @@ -127,7 +127,7 @@ pub fn CircBuf(comptime T: type, comptime default: T) type { // Clear the values back to default const slices = self.getPtrSlice(0, n); - inline for (slices) |slice| std.mem.set(T, slice, default); + inline for (slices) |slice| @memset(slice, default); // If we're not full, we can just advance the tail. We know // it'll be less than the length because otherwise we'd be full. diff --git a/vendor/harfbuzz b/vendor/harfbuzz index 9e4ae09fe..8df5cdbcd 160000 --- a/vendor/harfbuzz +++ b/vendor/harfbuzz @@ -1 +1 @@ -Subproject commit 9e4ae09fe76e0ab908095940c880b4ded94c1e18 +Subproject commit 8df5cdbcda495a582e72a7e2ce35d6106401edce diff --git a/vendor/mach-glfw b/vendor/mach-glfw index 871de9334..1b3def951 160000 --- a/vendor/mach-glfw +++ b/vendor/mach-glfw @@ -1 +1 @@ -Subproject commit 871de9334926273b41c80b0fb13a74d8438eb4e7 +Subproject commit 1b3def95123bc5b040bb1786f6ef3f551504a6f5 diff --git a/vendor/pixman b/vendor/pixman index 713077d0a..e4c878d17 160000 --- a/vendor/pixman +++ b/vendor/pixman @@ -1 +1 @@ -Subproject commit 713077d0a3c310ca1955bc331d46d55d0ae4a72b +Subproject commit e4c878d17942346dce5f54b25d7624440ef47de6 diff --git a/vendor/zig-libxml2 b/vendor/zig-libxml2 index eabfcf3a0..252c73242 160000 --- a/vendor/zig-libxml2 +++ b/vendor/zig-libxml2 @@ -1 +1 @@ -Subproject commit eabfcf3a0b3ca319693d3e5991098a77dace5e9b +Subproject commit 252c732429a686e4a835831038263a554e752c40