mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-04-12 10:48:39 +03:00
Merge 5ff449823f80d8c55a6cf6053c5cbed57ac5300a into 66636195f18d21bd65f8e7ced461f6b6770be189
This commit is contained in:
@ -4,28 +4,15 @@ pub fn build(b: *std.Build) !void {
|
||||
const target = b.standardTargetOptions(.{});
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
|
||||
const upstream = b.dependency("highway", .{});
|
||||
|
||||
const module = b.addModule("highway", .{
|
||||
.root_source_file = b.path("main.zig"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
|
||||
const lib = b.addStaticLibrary(.{
|
||||
.name = "highway",
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
lib.linkLibCpp();
|
||||
lib.addIncludePath(upstream.path(""));
|
||||
module.addIncludePath(upstream.path(""));
|
||||
|
||||
if (target.result.os.tag.isDarwin()) {
|
||||
const apple_sdk = @import("apple_sdk");
|
||||
try apple_sdk.addPaths(b, lib.root_module);
|
||||
try apple_sdk.addPaths(b, module);
|
||||
}
|
||||
const dynamic_link_opts: std.Build.Module.LinkSystemLibraryOptions = .{
|
||||
.preferred_link_mode = .dynamic,
|
||||
.search_strategy = .mode_first,
|
||||
};
|
||||
|
||||
var flags = std.ArrayList([]const u8).init(b.allocator);
|
||||
defer flags.deinit();
|
||||
@ -70,8 +57,67 @@ pub fn build(b: *std.Build) !void {
|
||||
"-fno-exceptions",
|
||||
});
|
||||
}
|
||||
var test_exe: ?*std.Build.Step.Compile = null;
|
||||
if (target.query.isNative()) {
|
||||
test_exe = b.addTest(.{
|
||||
.name = "test",
|
||||
.root_source_file = b.path("main.zig"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
const tests_run = b.addRunArtifact(test_exe.?);
|
||||
const test_step = b.step("test", "Run tests");
|
||||
test_step.dependOn(&tests_run.step);
|
||||
var it = module.import_table.iterator();
|
||||
while (it.next()) |entry| test_exe.?.root_module.addImport(entry.key_ptr.*, entry.value_ptr.*);
|
||||
|
||||
// Uncomment this if we're debugging tests
|
||||
// b.installArtifact(test_exe.?);
|
||||
}
|
||||
|
||||
module.addCSourceFiles(
|
||||
.{ .flags = flags.items, .files = &.{"bridge.cpp"} },
|
||||
);
|
||||
|
||||
if (b.systemIntegrationOption("highway", .{})) {
|
||||
module.linkSystemLibrary("libhwy", dynamic_link_opts);
|
||||
} else {
|
||||
const lib = try buildLib(b, module, .{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.flags = flags,
|
||||
});
|
||||
if (test_exe) |exe| {
|
||||
exe.linkLibrary(lib);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn buildLib(b: *std.Build, module: *std.Build.Module, options: anytype) !*std.Build.Step.Compile {
|
||||
const target = options.target;
|
||||
const optimize = options.optimize;
|
||||
const flags = options.flags;
|
||||
|
||||
const lib = b.addStaticLibrary(.{
|
||||
.name = "highway",
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
b.installArtifact(lib);
|
||||
|
||||
const upstream = b.lazyDependency("highway", .{}) orelse
|
||||
return lib;
|
||||
|
||||
lib.linkLibCpp();
|
||||
lib.addIncludePath(upstream.path(""));
|
||||
module.addIncludePath(upstream.path(""));
|
||||
|
||||
if (target.result.os.tag.isDarwin()) {
|
||||
const apple_sdk = @import("apple_sdk");
|
||||
try apple_sdk.addPaths(b, lib.root_module);
|
||||
try apple_sdk.addPaths(b, module);
|
||||
}
|
||||
|
||||
lib.addCSourceFiles(.{ .flags = flags.items, .files = &.{"bridge.cpp"} });
|
||||
lib.addCSourceFiles(.{
|
||||
.root = upstream.path(""),
|
||||
.flags = flags.items,
|
||||
@ -91,21 +137,5 @@ pub fn build(b: *std.Build) !void {
|
||||
.{ .include_extensions = &.{".h"} },
|
||||
);
|
||||
|
||||
b.installArtifact(lib);
|
||||
|
||||
{
|
||||
const test_exe = b.addTest(.{
|
||||
.name = "test",
|
||||
.root_source_file = b.path("main.zig"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
test_exe.linkLibrary(lib);
|
||||
|
||||
var it = module.import_table.iterator();
|
||||
while (it.next()) |entry| test_exe.root_module.addImport(entry.key_ptr.*, entry.value_ptr.*);
|
||||
const tests_run = b.addRunArtifact(test_exe);
|
||||
const test_step = b.step("test", "Run tests");
|
||||
test_step.dependOn(&tests_run.step);
|
||||
}
|
||||
return lib;
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
.highway = .{
|
||||
.url = "https://deps.files.ghostty.org/highway-66486a10623fa0d72fe91260f96c892e41aceb06.tar.gz",
|
||||
.hash = "N-V-__8AAGmZhABbsPJLfbqrh6JTHsXhY6qCaLAQyx25e0XE",
|
||||
.lazy = true,
|
||||
},
|
||||
|
||||
.apple_sdk = .{ .path = "../apple-sdk" },
|
||||
|
@ -355,13 +355,13 @@ pub fn init(b: *std.Build) !Config {
|
||||
// generally want a fat binary. This can be overridden with the
|
||||
// `-fsys` flag.
|
||||
for (&[_][]const u8{
|
||||
"freetype",
|
||||
"harfbuzz",
|
||||
"fontconfig",
|
||||
"libpng",
|
||||
"zlib",
|
||||
"oniguruma",
|
||||
"freetype",
|
||||
"gtk4-layer-shell",
|
||||
"harfbuzz",
|
||||
"libpng",
|
||||
"oniguruma",
|
||||
"zlib",
|
||||
}) |dep| {
|
||||
_ = b.systemIntegrationOption(
|
||||
dep,
|
||||
@ -380,6 +380,13 @@ pub fn init(b: *std.Build) !Config {
|
||||
"spirv-cross",
|
||||
"simdutf",
|
||||
|
||||
// This is mostly header-only in release builds and the API
|
||||
// isn't totally stable so this package either doesn't typically
|
||||
// exist OR is a common source of build issues. Packagers who
|
||||
// feel strongly about not building this from source can explicitly
|
||||
// enable fsys on this.
|
||||
"highway",
|
||||
|
||||
// This is default false because it is used for testing
|
||||
// primarily and not official packaging. The packaging
|
||||
// guide advises against building the GLFW backend.
|
||||
|
@ -485,8 +485,13 @@ pub fn add(
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
})) |highway_dep| {
|
||||
step.linkLibrary(highway_dep.artifact("highway"));
|
||||
try static_libs.append(highway_dep.artifact("highway").getEmittedBin());
|
||||
step.root_module.addImport("highway", highway_dep.module("highway"));
|
||||
if (b.systemIntegrationOption("highway", .{})) {
|
||||
step.linkSystemLibrary2("libhwy", dynamic_link_opts);
|
||||
} else {
|
||||
step.linkLibrary(highway_dep.artifact("highway"));
|
||||
try static_libs.append(highway_dep.artifact("highway").getEmittedBin());
|
||||
}
|
||||
}
|
||||
|
||||
// utfcpp - This is used as a dependency on our hand-written C++ code
|
||||
|
Reference in New Issue
Block a user