mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
build compiles at least
This commit is contained in:
52
build.zig
52
build.zig
@ -222,7 +222,7 @@ pub fn build(b: *std.build.Builder) !void {
|
|||||||
break :is_nixos if (std.fs.accessAbsolute("/etc/NIXOS", .{})) true else |_| false;
|
break :is_nixos if (std.fs.accessAbsolute("/etc/NIXOS", .{})) true else |_| false;
|
||||||
};
|
};
|
||||||
if (is_nixos and env.get("IN_NIX_SHELL") == null) {
|
if (is_nixos and env.get("IN_NIX_SHELL") == null) {
|
||||||
const notice = b.addLog(
|
try exe.step.addError(
|
||||||
"\x1b[" ++ color_map.get("yellow").? ++
|
"\x1b[" ++ color_map.get("yellow").? ++
|
||||||
"\x1b[" ++ color_map.get("b").? ++
|
"\x1b[" ++ color_map.get("b").? ++
|
||||||
"WARNING: " ++
|
"WARNING: " ++
|
||||||
@ -244,8 +244,6 @@ pub fn build(b: *std.build.Builder) !void {
|
|||||||
"\x1b[0m",
|
"\x1b[0m",
|
||||||
.{},
|
.{},
|
||||||
);
|
);
|
||||||
|
|
||||||
exe.step.dependOn(¬ice.step);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we're installing, we get the install step so we can add
|
// If we're installing, we get the install step so we can add
|
||||||
@ -327,7 +325,7 @@ pub fn build(b: *std.build.Builder) !void {
|
|||||||
.sources = lib_list.items,
|
.sources = lib_list.items,
|
||||||
});
|
});
|
||||||
libtool.step.dependOn(&lib.step);
|
libtool.step.dependOn(&lib.step);
|
||||||
b.default_step.dependOn(&libtool.step);
|
b.default_step.dependOn(libtool.step);
|
||||||
|
|
||||||
break :lib libtool;
|
break :lib libtool;
|
||||||
};
|
};
|
||||||
@ -355,7 +353,7 @@ pub fn build(b: *std.build.Builder) !void {
|
|||||||
.sources = lib_list.items,
|
.sources = lib_list.items,
|
||||||
});
|
});
|
||||||
libtool.step.dependOn(&lib.step);
|
libtool.step.dependOn(&lib.step);
|
||||||
b.default_step.dependOn(&libtool.step);
|
b.default_step.dependOn(libtool.step);
|
||||||
|
|
||||||
break :lib libtool;
|
break :lib libtool;
|
||||||
};
|
};
|
||||||
@ -363,22 +361,22 @@ pub fn build(b: *std.build.Builder) !void {
|
|||||||
const static_lib_universal = LipoStep.create(b, .{
|
const static_lib_universal = LipoStep.create(b, .{
|
||||||
.name = "ghostty",
|
.name = "ghostty",
|
||||||
.out_name = "libghostty.a",
|
.out_name = "libghostty.a",
|
||||||
.input_a = .{ .generated = &static_lib_aarch64.out_path },
|
.input_a = static_lib_aarch64.output,
|
||||||
.input_b = .{ .generated = &static_lib_x86_64.out_path },
|
.input_b = static_lib_x86_64.output,
|
||||||
});
|
});
|
||||||
static_lib_universal.step.dependOn(&static_lib_aarch64.step);
|
static_lib_universal.step.dependOn(static_lib_aarch64.step);
|
||||||
static_lib_universal.step.dependOn(&static_lib_x86_64.step);
|
static_lib_universal.step.dependOn(static_lib_x86_64.step);
|
||||||
|
|
||||||
// The xcframework wraps our ghostty library so that we can link
|
// The xcframework wraps our ghostty library so that we can link
|
||||||
// it to the final app built with Swift.
|
// it to the final app built with Swift.
|
||||||
const xcframework = XCFrameworkStep.create(b, .{
|
const xcframework = XCFrameworkStep.create(b, .{
|
||||||
.name = "GhosttyKit",
|
.name = "GhosttyKit",
|
||||||
.out_path = "macos/GhosttyKit.xcframework",
|
.out_path = "macos/GhosttyKit.xcframework",
|
||||||
.library = .{ .generated = &static_lib_universal.out_path },
|
.library = static_lib_universal.output,
|
||||||
.headers = .{ .path = "include" },
|
.headers = .{ .path = "include" },
|
||||||
});
|
});
|
||||||
xcframework.step.dependOn(&static_lib_universal.step);
|
xcframework.step.dependOn(static_lib_universal.step);
|
||||||
b.default_step.dependOn(&xcframework.step);
|
b.default_step.dependOn(xcframework.step);
|
||||||
}
|
}
|
||||||
|
|
||||||
// wasm
|
// wasm
|
||||||
@ -477,24 +475,11 @@ pub fn build(b: *std.build.Builder) !void {
|
|||||||
.target = target,
|
.target = target,
|
||||||
});
|
});
|
||||||
{
|
{
|
||||||
if (emit_test_exe) {
|
if (emit_test_exe) main_test.install();
|
||||||
const main_test_exe = b.addTest(.{
|
|
||||||
.name = "ghostty-test",
|
|
||||||
.kind = .test_exe,
|
|
||||||
.root_source_file = .{ .path = "src/main.zig" },
|
|
||||||
.target = target,
|
|
||||||
});
|
|
||||||
main_test_exe.install();
|
|
||||||
}
|
|
||||||
main_test.setFilter(test_filter);
|
main_test.setFilter(test_filter);
|
||||||
_ = try addDeps(b, main_test, true);
|
_ = try addDeps(b, main_test, true);
|
||||||
main_test.addOptions("build_options", exe_options);
|
main_test.addOptions("build_options", exe_options);
|
||||||
|
|
||||||
var before = b.addLog("\x1b[" ++ color_map.get("cyan").? ++ "\x1b[" ++ color_map.get("b").? ++ "[{s} tests]" ++ "\x1b[" ++ color_map.get("d").? ++ " ----" ++ "\x1b[0m", .{"ghostty"});
|
|
||||||
var after = b.addLog("\x1b[" ++ color_map.get("d").? ++ "–––---\n\n" ++ "\x1b[0m", .{});
|
|
||||||
test_step.dependOn(&before.step);
|
|
||||||
test_step.dependOn(&main_test.step);
|
test_step.dependOn(&main_test.step);
|
||||||
test_step.dependOn(&after.step);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Named package dependencies don't have their tests run by reference,
|
// Named package dependencies don't have their tests run by reference,
|
||||||
@ -510,7 +495,6 @@ pub fn build(b: *std.build.Builder) !void {
|
|||||||
var buf: [256]u8 = undefined;
|
var buf: [256]u8 = undefined;
|
||||||
var test_run = b.addTest(.{
|
var test_run = b.addTest(.{
|
||||||
.name = try std.fmt.bufPrint(&buf, "{s}-test", .{name}),
|
.name = try std.fmt.bufPrint(&buf, "{s}-test", .{name}),
|
||||||
.kind = .@"test",
|
|
||||||
.root_source_file = module.source_file,
|
.root_source_file = module.source_file,
|
||||||
.target = target,
|
.target = target,
|
||||||
});
|
});
|
||||||
@ -521,21 +505,9 @@ pub fn build(b: *std.build.Builder) !void {
|
|||||||
// try test_.packages.appendSlice(children);
|
// try test_.packages.appendSlice(children);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
var before = b.addLog("\x1b[" ++ color_map.get("cyan").? ++ "\x1b[" ++ color_map.get("b").? ++ "[{s} tests]" ++ "\x1b[" ++ color_map.get("d").? ++ " ----" ++ "\x1b[0m", .{name});
|
|
||||||
var after = b.addLog("\x1b[" ++ color_map.get("d").? ++ "–––---\n\n" ++ "\x1b[0m", .{});
|
|
||||||
test_step.dependOn(&before.step);
|
|
||||||
test_step.dependOn(&test_run.step);
|
test_step.dependOn(&test_run.step);
|
||||||
test_step.dependOn(&after.step);
|
|
||||||
|
|
||||||
if (emit_test_exe) {
|
if (emit_test_exe) test_run.install();
|
||||||
const test_exe = b.addTest(.{
|
|
||||||
.name = try std.fmt.bufPrint(&buf, "{s}-test", .{name}),
|
|
||||||
.kind = .test_exe,
|
|
||||||
.root_source_file = module.source_file,
|
|
||||||
.target = target,
|
|
||||||
});
|
|
||||||
test_exe.install();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
6
flake.lock
generated
6
flake.lock
generated
@ -126,11 +126,11 @@
|
|||||||
"nixpkgs": "nixpkgs_2"
|
"nixpkgs": "nixpkgs_2"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1678494092,
|
"lastModified": 1679669017,
|
||||||
"narHash": "sha256-0vB5xFl3qoQmyH3l2goAbdzxcU4KwHqdN1SrQsBfT7k=",
|
"narHash": "sha256-FUvrE/4HKsrl/CedvQuoJa+vDr9lM7elI28cJs9uSHs=",
|
||||||
"owner": "mitchellh",
|
"owner": "mitchellh",
|
||||||
"repo": "zig-overlay",
|
"repo": "zig-overlay",
|
||||||
"rev": "5f38868e7af88a575d6dfd48ee213afcd96bed82",
|
"rev": "810cecd27319cb79feb4a8e79ac7ad40c7826235",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -47,7 +47,7 @@ pub fn buildTracy(
|
|||||||
|
|
||||||
lib.addIncludePath(root);
|
lib.addIncludePath(root);
|
||||||
lib.addCSourceFile(try std.fs.path.join(
|
lib.addCSourceFile(try std.fs.path.join(
|
||||||
lib.builder.allocator,
|
b.allocator,
|
||||||
&.{ root, "TracyClient.cpp" },
|
&.{ root, "TracyClient.cpp" },
|
||||||
), flags.items);
|
), flags.items);
|
||||||
|
|
||||||
|
@ -4,8 +4,8 @@ const LibtoolStep = @This();
|
|||||||
|
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const Step = std.build.Step;
|
const Step = std.build.Step;
|
||||||
|
const RunStep = std.build.RunStep;
|
||||||
const FileSource = std.build.FileSource;
|
const FileSource = std.build.FileSource;
|
||||||
const GeneratedFile = std.build.GeneratedFile;
|
|
||||||
|
|
||||||
pub const Options = struct {
|
pub const Options = struct {
|
||||||
/// The name of this step.
|
/// The name of this step.
|
||||||
@ -19,47 +19,26 @@ pub const Options = struct {
|
|||||||
sources: []FileSource,
|
sources: []FileSource,
|
||||||
};
|
};
|
||||||
|
|
||||||
step: Step,
|
/// The step to depend on.
|
||||||
builder: *std.Build,
|
step: *Step,
|
||||||
|
|
||||||
/// Resulting binary
|
/// The output file from the libtool run.
|
||||||
out_path: GeneratedFile,
|
output: FileSource,
|
||||||
|
|
||||||
/// See Options
|
/// Run libtool against a list of library files to combine into a single
|
||||||
name: []const u8,
|
/// static library.
|
||||||
out_name: []const u8,
|
pub fn create(b: *std.Build, opts: Options) *LibtoolStep {
|
||||||
sources: []FileSource,
|
const self = b.allocator.create(LibtoolStep) catch @panic("OOM");
|
||||||
|
|
||||||
|
const run_step = RunStep.create(b, b.fmt("libtool {s}", .{opts.name}));
|
||||||
|
run_step.addArgs(&.{ "libtool", "-static", "-o" });
|
||||||
|
const output = run_step.addOutputFileArg(opts.out_name);
|
||||||
|
for (opts.sources) |source| run_step.addFileSourceArg(source);
|
||||||
|
|
||||||
pub fn create(builder: *std.Build, opts: Options) *LibtoolStep {
|
|
||||||
const self = builder.allocator.create(LibtoolStep) catch @panic("OOM");
|
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.step = Step.init(.custom, builder.fmt("lipo {s}", .{opts.name}), builder.allocator, make),
|
.step = &run_step.step,
|
||||||
.builder = builder,
|
.output = output,
|
||||||
.name = opts.name,
|
|
||||||
.out_path = .{ .step = &self.step },
|
|
||||||
.out_name = opts.out_name,
|
|
||||||
.sources = opts.sources,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn make(step: *Step) !void {
|
|
||||||
const self = @fieldParentPtr(LibtoolStep, "step", step);
|
|
||||||
|
|
||||||
// We use a RunStep here to ease our configuration.
|
|
||||||
const run = std.build.RunStep.create(self.builder, self.builder.fmt(
|
|
||||||
"libtool {s}",
|
|
||||||
.{self.name},
|
|
||||||
));
|
|
||||||
run.addArgs(&.{
|
|
||||||
"libtool",
|
|
||||||
"-static",
|
|
||||||
"-o",
|
|
||||||
});
|
|
||||||
try run.argv.append(.{ .output = .{
|
|
||||||
.generated_file = &self.out_path,
|
|
||||||
.basename = self.out_name,
|
|
||||||
} });
|
|
||||||
for (self.sources) |source| run.addFileSourceArg(source);
|
|
||||||
try run.step.make();
|
|
||||||
}
|
|
||||||
|
@ -4,8 +4,8 @@ const LipoStep = @This();
|
|||||||
|
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const Step = std.build.Step;
|
const Step = std.build.Step;
|
||||||
|
const RunStep = std.build.RunStep;
|
||||||
const FileSource = std.build.FileSource;
|
const FileSource = std.build.FileSource;
|
||||||
const GeneratedFile = std.build.GeneratedFile;
|
|
||||||
|
|
||||||
pub const Options = struct {
|
pub const Options = struct {
|
||||||
/// The name of the xcframework to create.
|
/// The name of the xcframework to create.
|
||||||
@ -19,46 +19,24 @@ pub const Options = struct {
|
|||||||
input_b: FileSource,
|
input_b: FileSource,
|
||||||
};
|
};
|
||||||
|
|
||||||
step: Step,
|
step: *Step,
|
||||||
builder: *std.build.Builder,
|
|
||||||
|
|
||||||
/// Resulting binary
|
/// Resulting binary
|
||||||
out_path: GeneratedFile,
|
output: FileSource,
|
||||||
|
|
||||||
/// See Options
|
pub fn create(b: *std.Build, opts: Options) *LipoStep {
|
||||||
name: []const u8,
|
const self = b.allocator.create(LipoStep) catch @panic("OOM");
|
||||||
out_name: []const u8,
|
|
||||||
input_a: FileSource,
|
const run_step = RunStep.create(b, b.fmt("lipo {s}", .{opts.name}));
|
||||||
input_b: FileSource,
|
run_step.addArgs(&.{ "lipo", "-create", "-output" });
|
||||||
|
const output = run_step.addOutputFileArg(opts.out_name);
|
||||||
|
run_step.addFileSourceArg(opts.input_a);
|
||||||
|
run_step.addFileSourceArg(opts.input_b);
|
||||||
|
|
||||||
pub fn create(builder: *std.build.Builder, opts: Options) *LipoStep {
|
|
||||||
const self = builder.allocator.create(LipoStep) catch @panic("OOM");
|
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.step = Step.init(.custom, builder.fmt("lipo {s}", .{opts.name}), builder.allocator, make),
|
.step = &run_step.step,
|
||||||
.builder = builder,
|
.output = output,
|
||||||
.name = opts.name,
|
|
||||||
.out_path = .{ .step = &self.step },
|
|
||||||
.out_name = opts.out_name,
|
|
||||||
.input_a = opts.input_a,
|
|
||||||
.input_b = opts.input_b,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn make(step: *Step) !void {
|
|
||||||
const self = @fieldParentPtr(LipoStep, "step", step);
|
|
||||||
|
|
||||||
// We use a RunStep here to ease our configuration.
|
|
||||||
const run = std.build.RunStep.create(self.builder, self.builder.fmt(
|
|
||||||
"lipo {s}",
|
|
||||||
.{self.name},
|
|
||||||
));
|
|
||||||
run.addArgs(&.{ "lipo", "-create", "-output" });
|
|
||||||
try run.argv.append(.{ .output = .{
|
|
||||||
.generated_file = &self.out_path,
|
|
||||||
.basename = self.out_name,
|
|
||||||
} });
|
|
||||||
run.addFileSourceArg(self.input_a);
|
|
||||||
run.addFileSourceArg(self.input_b);
|
|
||||||
try run.step.make();
|
|
||||||
}
|
|
||||||
|
@ -5,7 +5,8 @@ const XCFrameworkStep = @This();
|
|||||||
|
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const Step = std.build.Step;
|
const Step = std.build.Step;
|
||||||
const GeneratedFile = std.build.GeneratedFile;
|
const RunStep = std.build.RunStep;
|
||||||
|
const FileSource = std.build.FileSource;
|
||||||
|
|
||||||
pub const Options = struct {
|
pub const Options = struct {
|
||||||
/// The name of the xcframework to create.
|
/// The name of the xcframework to create.
|
||||||
@ -21,61 +22,38 @@ pub const Options = struct {
|
|||||||
headers: std.build.FileSource,
|
headers: std.build.FileSource,
|
||||||
};
|
};
|
||||||
|
|
||||||
step: Step,
|
step: *Step,
|
||||||
builder: *std.build.Builder,
|
|
||||||
|
|
||||||
/// See Options
|
pub fn create(b: *std.Build, opts: Options) *XCFrameworkStep {
|
||||||
name: []const u8,
|
const self = b.allocator.create(XCFrameworkStep) catch @panic("OOM");
|
||||||
out_path: []const u8,
|
|
||||||
library: std.build.FileSource,
|
|
||||||
headers: std.build.FileSource,
|
|
||||||
|
|
||||||
pub fn create(builder: *std.build.Builder, opts: Options) *XCFrameworkStep {
|
// We have to delete the old xcframework first since we're writing
|
||||||
const self = builder.allocator.create(XCFrameworkStep) catch @panic("OOM");
|
// to a static path.
|
||||||
self.* = .{
|
const run_delete = run: {
|
||||||
.step = Step.init(.custom, builder.fmt(
|
const run = RunStep.create(b, b.fmt("xcframework delete {s}", .{opts.name}));
|
||||||
"xcframework {s}",
|
run.has_side_effects = true;
|
||||||
.{opts.name},
|
run.addArgs(&.{ "rm", "-rf", opts.out_path });
|
||||||
), builder.allocator, make),
|
break :run run;
|
||||||
.builder = builder,
|
|
||||||
.name = opts.name,
|
|
||||||
.out_path = opts.out_path,
|
|
||||||
.library = opts.library,
|
|
||||||
.headers = opts.headers,
|
|
||||||
};
|
};
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn make(step: *Step) !void {
|
// Then we run xcodebuild to create the framework.
|
||||||
const self = @fieldParentPtr(XCFrameworkStep, "step", step);
|
const run_create = run: {
|
||||||
|
const run = RunStep.create(b, b.fmt("xcframework {s}", .{opts.name}));
|
||||||
// TODO: use the zig cache system when it is in the stdlib
|
run.has_side_effects = true;
|
||||||
// https://github.com/ziglang/zig/pull/14571
|
|
||||||
const output_path = self.out_path;
|
|
||||||
|
|
||||||
// We use a RunStep here to ease our configuration.
|
|
||||||
{
|
|
||||||
const run = std.build.RunStep.create(self.builder, self.builder.fmt(
|
|
||||||
"xcframework delete {s}",
|
|
||||||
.{self.name},
|
|
||||||
));
|
|
||||||
run.condition = .always;
|
|
||||||
run.addArgs(&.{ "rm", "-rf", output_path });
|
|
||||||
try run.step.make();
|
|
||||||
}
|
|
||||||
{
|
|
||||||
const run = std.build.RunStep.create(self.builder, self.builder.fmt(
|
|
||||||
"xcframework {s}",
|
|
||||||
.{self.name},
|
|
||||||
));
|
|
||||||
run.condition = .always;
|
|
||||||
run.addArgs(&.{ "xcodebuild", "-create-xcframework" });
|
run.addArgs(&.{ "xcodebuild", "-create-xcframework" });
|
||||||
run.addArg("-library");
|
run.addArg("-library");
|
||||||
run.addFileSourceArg(self.library);
|
run.addFileSourceArg(opts.library);
|
||||||
run.addArg("-headers");
|
run.addArg("-headers");
|
||||||
run.addFileSourceArg(self.headers);
|
run.addFileSourceArg(opts.headers);
|
||||||
run.addArg("-output");
|
run.addArg("-output");
|
||||||
run.addArg(output_path);
|
run.addArg(opts.out_path);
|
||||||
try run.step.make();
|
break :run run;
|
||||||
}
|
};
|
||||||
|
run_create.step.dependOn(&run_delete.step);
|
||||||
|
|
||||||
|
self.* = .{
|
||||||
|
.step = &run_create.step,
|
||||||
|
};
|
||||||
|
|
||||||
|
return self;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user