mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-04-20 00:18:53 +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 target = b.standardTargetOptions(.{});
|
||||||
const optimize = b.standardOptimizeOption(.{});
|
const optimize = b.standardOptimizeOption(.{});
|
||||||
|
|
||||||
const upstream = b.dependency("highway", .{});
|
|
||||||
|
|
||||||
const module = b.addModule("highway", .{
|
const module = b.addModule("highway", .{
|
||||||
.root_source_file = b.path("main.zig"),
|
.root_source_file = b.path("main.zig"),
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
});
|
});
|
||||||
|
const dynamic_link_opts: std.Build.Module.LinkSystemLibraryOptions = .{
|
||||||
const lib = b.addStaticLibrary(.{
|
.preferred_link_mode = .dynamic,
|
||||||
.name = "highway",
|
.search_strategy = .mode_first,
|
||||||
.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);
|
|
||||||
}
|
|
||||||
|
|
||||||
var flags = std.ArrayList([]const u8).init(b.allocator);
|
var flags = std.ArrayList([]const u8).init(b.allocator);
|
||||||
defer flags.deinit();
|
defer flags.deinit();
|
||||||
@ -70,8 +57,67 @@ pub fn build(b: *std.Build) !void {
|
|||||||
"-fno-exceptions",
|
"-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(.{
|
lib.addCSourceFiles(.{
|
||||||
.root = upstream.path(""),
|
.root = upstream.path(""),
|
||||||
.flags = flags.items,
|
.flags = flags.items,
|
||||||
@ -91,21 +137,5 @@ pub fn build(b: *std.Build) !void {
|
|||||||
.{ .include_extensions = &.{".h"} },
|
.{ .include_extensions = &.{".h"} },
|
||||||
);
|
);
|
||||||
|
|
||||||
b.installArtifact(lib);
|
return 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
.highway = .{
|
.highway = .{
|
||||||
.url = "https://deps.files.ghostty.org/highway-66486a10623fa0d72fe91260f96c892e41aceb06.tar.gz",
|
.url = "https://deps.files.ghostty.org/highway-66486a10623fa0d72fe91260f96c892e41aceb06.tar.gz",
|
||||||
.hash = "N-V-__8AAGmZhABbsPJLfbqrh6JTHsXhY6qCaLAQyx25e0XE",
|
.hash = "N-V-__8AAGmZhABbsPJLfbqrh6JTHsXhY6qCaLAQyx25e0XE",
|
||||||
|
.lazy = true,
|
||||||
},
|
},
|
||||||
|
|
||||||
.apple_sdk = .{ .path = "../apple-sdk" },
|
.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
|
// generally want a fat binary. This can be overridden with the
|
||||||
// `-fsys` flag.
|
// `-fsys` flag.
|
||||||
for (&[_][]const u8{
|
for (&[_][]const u8{
|
||||||
"freetype",
|
|
||||||
"harfbuzz",
|
|
||||||
"fontconfig",
|
"fontconfig",
|
||||||
"libpng",
|
"freetype",
|
||||||
"zlib",
|
|
||||||
"oniguruma",
|
|
||||||
"gtk4-layer-shell",
|
"gtk4-layer-shell",
|
||||||
|
"harfbuzz",
|
||||||
|
"libpng",
|
||||||
|
"oniguruma",
|
||||||
|
"zlib",
|
||||||
}) |dep| {
|
}) |dep| {
|
||||||
_ = b.systemIntegrationOption(
|
_ = b.systemIntegrationOption(
|
||||||
dep,
|
dep,
|
||||||
@ -380,6 +380,13 @@ pub fn init(b: *std.Build) !Config {
|
|||||||
"spirv-cross",
|
"spirv-cross",
|
||||||
"simdutf",
|
"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
|
// This is default false because it is used for testing
|
||||||
// primarily and not official packaging. The packaging
|
// primarily and not official packaging. The packaging
|
||||||
// guide advises against building the GLFW backend.
|
// guide advises against building the GLFW backend.
|
||||||
|
@ -485,9 +485,14 @@ pub fn add(
|
|||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
})) |highway_dep| {
|
})) |highway_dep| {
|
||||||
|
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"));
|
step.linkLibrary(highway_dep.artifact("highway"));
|
||||||
try static_libs.append(highway_dep.artifact("highway").getEmittedBin());
|
try static_libs.append(highway_dep.artifact("highway").getEmittedBin());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// utfcpp - This is used as a dependency on our hand-written C++ code
|
// utfcpp - This is used as a dependency on our hand-written C++ code
|
||||||
if (b.lazyDependency("utfcpp", .{
|
if (b.lazyDependency("utfcpp", .{
|
||||||
|
Reference in New Issue
Block a user