mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-04-12 10:48:39 +03:00
Merge pull request #704 from der-teufel-programming/windows-test
Get `zig build test` working on Windows
This commit is contained in:
@ -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,
|
||||
|
@ -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"));
|
||||
}
|
||||
|
||||
|
@ -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 });
|
||||
|
@ -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,
|
||||
|
@ -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"),
|
||||
};
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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{
|
||||
|
Reference in New Issue
Block a user