diff --git a/build.zig b/build.zig index cf9e096e1..911ea8c05 100644 --- a/build.zig +++ b/build.zig @@ -624,6 +624,7 @@ fn addDeps( const js_dep = b.dependency("zig_js", .{ .target = step.target, .optimize = step.optimize }); const libxev_dep = b.dependency("libxev", .{ .target = step.target, .optimize = step.optimize }); const objc_dep = b.dependency("zig_objc", .{ .target = step.target, .optimize = step.optimize }); + const fontconfig_dep = b.dependency("fontconfig", .{ .target = step.target, .optimize = step.optimize, diff --git a/pkg/fontconfig/build.zig b/pkg/fontconfig/build.zig index 01eb46181..0a927d66f 100644 --- a/pkg/fontconfig/build.zig +++ b/pkg/fontconfig/build.zig @@ -6,6 +6,11 @@ pub fn build(b: *std.Build) !void { const optimize = b.standardOptimizeOption(.{}); const libxml2_enabled = b.option(bool, "enable-libxml2", "Build libxml2") orelse true; + const libxml2_iconv_enabled = b.option( + bool, + "enable-libxml2-iconv", + "Build libxml2 with iconv", + ) orelse (target.getOsTag() != .windows); const freetype_enabled = b.option(bool, "enable-freetype", "Build freetype") orelse true; _ = b.addModule("fontconfig", .{ .source_file = .{ .path = "main.zig" } }); @@ -25,7 +30,11 @@ pub fn build(b: *std.Build) !void { lib.linkLibrary(freetype_dep.artifact("freetype")); } if (libxml2_enabled) { - const libxml2_dep = b.dependency("libxml2", .{ .target = target, .optimize = optimize }); + const libxml2_dep = b.dependency("libxml2", .{ + .target = target, + .optimize = optimize, + .iconv = libxml2_iconv_enabled, + }); lib.linkLibrary(libxml2_dep.artifact("xml2")); } diff --git a/src/Command.zig b/src/Command.zig index b9d282aa7..ce606f770 100644 --- a/src/Command.zig +++ b/src/Command.zig @@ -355,6 +355,7 @@ test "createNullDelimitedEnvMap" { } test "Command: pre exec" { + if (builtin.os.tag == .windows) return error.SkipZigTest; var cmd: Command = .{ .path = "/usr/bin/env", .args = &.{ "/usr/bin/env", "-v" }, @@ -375,6 +376,7 @@ test "Command: pre exec" { } test "Command: redirect stdout to file" { + if (builtin.os.tag == .windows) return error.SkipZigTest; var td = try TempDir.init(); defer td.deinit(); var stdout = try td.dir.createFile("stdout.txt", .{ .read = true }); @@ -400,6 +402,7 @@ test "Command: redirect stdout to file" { } test "Command: custom env vars" { + if (builtin.os.tag == .windows) return error.SkipZigTest; var td = try TempDir.init(); defer td.deinit(); var stdout = try td.dir.createFile("stdout.txt", .{ .read = true }); @@ -430,6 +433,7 @@ test "Command: custom env vars" { } test "Command: custom working directory" { + if (builtin.os.tag == .windows) return error.SkipZigTest; var td = try TempDir.init(); defer td.deinit(); var stdout = try td.dir.createFile("stdout.txt", .{ .read = true }); diff --git a/src/Pty.zig b/src/Pty.zig index 3bbcb713a..c1e8efd18 100644 --- a/src/Pty.zig +++ b/src/Pty.zig @@ -128,6 +128,7 @@ pub fn childPreExec(self: Pty) !void { } test { + if (builtin.os.tag == .windows) return error.SkipZigTest; var ws: winsize = .{ .ws_row = 50, .ws_col = 80, diff --git a/src/os/desktop.zig b/src/os/desktop.zig index f7717cf65..ed4f977d9 100644 --- a/src/os/desktop.zig +++ b/src/os/desktop.zig @@ -41,6 +41,9 @@ pub fn launchedFromDesktop() bool { break :linux gio_pid == pid; }, + // TODO: This should have some logic to detect this. Perhaps std.builtin.subsystem + .windows => false, + else => @compileError("unsupported platform"), }; } diff --git a/src/os/passwd.zig b/src/os/passwd.zig index 32d93da3b..b3e3dcc12 100644 --- a/src/os/passwd.zig +++ b/src/os/passwd.zig @@ -138,6 +138,7 @@ pub fn get(alloc: Allocator) !Entry { } test { + if (builtin.os.tag == .windows) return error.SkipZigTest; const testing = std.testing; var arena = ArenaAllocator.init(testing.allocator); defer arena.deinit(); diff --git a/src/os/xdg.zig b/src/os/xdg.zig index cab8aab3d..f193cdf19 100644 --- a/src/os/xdg.zig +++ b/src/os/xdg.zig @@ -20,7 +20,22 @@ pub const Options = struct { /// Get the XDG user config directory. The returned value is allocated. pub fn config(alloc: Allocator, opts: Options) ![]u8 { - if (std.os.getenv("XDG_CONFIG_HOME")) |env| { + // First check the env var. On Windows we have to allocate so this tracks + // both whether we have the env var and whether we own it. + const env_, const owned = switch (builtin.os.tag) { + else => .{ std.os.getenv("XDG_CONFIG_HOME"), false }, + .windows => windows: { + if (std.process.getEnvVarOwned(alloc, "XDG_CONFIG_HOME")) |env| { + break :windows .{ env, true }; + } else |err| switch (err) { + error.EnvironmentVariableNotFound => break :windows .{ null, false }, + else => return err, + } + }, + }; + defer if (owned) if (env_) |v| alloc.free(v); + + if (env_) |env| { // If we have a subdir, then we use the env as-is to avoid a copy. if (opts.subdir) |subdir| { return try std.fs.path.join(alloc, &[_][]const u8{