Disable iconv on Windows by default (enabled via cli flag).

Skip various tests not implemented on windows.
This commit is contained in:
Krzysztof Wolicki
2023-10-19 09:39:20 +02:00
parent 1d71a87cd6
commit 3936b471a8
7 changed files with 22 additions and 2 deletions

View File

@ -621,9 +621,11 @@ 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 iconv_win_enabled = b.option(bool, "enable-iconv-win", "Build libxml2 for fontconfig with iconv on Windows") orelse false;
const fontconfig_dep = b.dependency("fontconfig", .{
.target = step.target,
.optimize = step.optimize,
.iconv_win_enabled = iconv_win_enabled,
});
const freetype_dep = b.dependency("freetype", .{
.target = step.target,

View File

@ -6,6 +6,7 @@ pub fn build(b: *std.Build) !void {
const optimize = b.standardOptimizeOption(.{});
const libxml2_enabled = b.option(bool, "enable-libxml2", "Build libxml2") orelse true;
const iconv_win_enabled = b.option(bool, "enable-iconv-win", "Build libxml2 with iconv on Windows") orelse false;
const freetype_enabled = b.option(bool, "enable-freetype", "Build freetype") orelse true;
_ = b.addModule("fontconfig", .{ .source_file = .{ .path = "main.zig" } });
@ -25,7 +26,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 = !(target.getOsTag() == .windows) or iconv_win_enabled,
});
lib.linkLibrary(libxml2_dep.artifact("xml2"));
}

View File

@ -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 });

View File

@ -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,

View File

@ -40,6 +40,7 @@ pub fn launchedFromDesktop() bool {
break :linux gio_pid == pid;
},
.windows => false,
else => @compileError("unsupported platform"),
};

View File

@ -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();

View File

@ -20,7 +20,8 @@ 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| {
if (std.process.getEnvVarOwned(alloc, "XDG_CONFIG_HOME")) |env| {
defer alloc.free(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{
@ -30,6 +31,11 @@ pub fn config(alloc: Allocator, opts: Options) ![]u8 {
}
return try alloc.dupe(u8, env);
} else |err| {
switch (err) {
error.EnvironmentVariableNotFound => {},
else => return err,
}
}
// If we have a cached home dir, use that.