mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
don't build oniguruma when system integration is enabled
This commit is contained in:
@ -5,36 +5,59 @@ pub fn build(b: *std.Build) !void {
|
|||||||
const target = b.standardTargetOptions(.{});
|
const target = b.standardTargetOptions(.{});
|
||||||
const optimize = b.standardOptimizeOption(.{});
|
const optimize = b.standardOptimizeOption(.{});
|
||||||
|
|
||||||
const module = b.addModule("oniguruma", .{ .root_source_file = b.path("main.zig") });
|
const module = b.addModule("oniguruma", .{
|
||||||
|
.root_source_file = b.path("main.zig"),
|
||||||
|
.target = target,
|
||||||
|
.optimize = optimize,
|
||||||
|
});
|
||||||
|
|
||||||
const upstream = b.dependency("oniguruma", .{});
|
// For dynamic linking, we prefer dynamic linking and to search by
|
||||||
const lib = try buildOniguruma(b, upstream, target, optimize);
|
// mode first. Mode first will search all paths for a dynamic library
|
||||||
module.addIncludePath(upstream.path("src"));
|
// before falling back to static.
|
||||||
b.installArtifact(lib);
|
const dynamic_link_opts: std.Build.Module.LinkSystemLibraryOptions = .{
|
||||||
|
.preferred_link_mode = .dynamic,
|
||||||
|
.search_strategy = .mode_first,
|
||||||
|
};
|
||||||
|
|
||||||
|
var test_exe: ?*std.Build.Step.Compile = null;
|
||||||
if (target.query.isNative()) {
|
if (target.query.isNative()) {
|
||||||
const test_exe = b.addTest(.{
|
test_exe = b.addTest(.{
|
||||||
.name = "test",
|
.name = "test",
|
||||||
.root_source_file = b.path("main.zig"),
|
.root_source_file = b.path("main.zig"),
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
});
|
});
|
||||||
test_exe.linkLibrary(lib);
|
const tests_run = b.addRunArtifact(test_exe.?);
|
||||||
const tests_run = b.addRunArtifact(test_exe);
|
|
||||||
const test_step = b.step("test", "Run tests");
|
const test_step = b.step("test", "Run tests");
|
||||||
test_step.dependOn(&tests_run.step);
|
test_step.dependOn(&tests_run.step);
|
||||||
|
|
||||||
// Uncomment this if we're debugging tests
|
// Uncomment this if we're debugging tests
|
||||||
b.installArtifact(test_exe);
|
b.installArtifact(test_exe.?);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (b.systemIntegrationOption("oniguruma", .{})) {
|
||||||
|
module.linkSystemLibrary("oniguruma", dynamic_link_opts);
|
||||||
|
|
||||||
|
if (test_exe) |exe| {
|
||||||
|
exe.linkSystemLibrary2("oniguruma", dynamic_link_opts);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const lib = try buildLib(b, module, .{
|
||||||
|
.target = target,
|
||||||
|
.optimize = optimize,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (test_exe) |exe| {
|
||||||
|
exe.linkLibrary(lib);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn buildOniguruma(
|
pub fn buildLib(b: *std.Build, module: *std.Build.Module, options: anytype) !*std.Build.Step.Compile {
|
||||||
b: *std.Build,
|
const target = options.target;
|
||||||
upstream: *std.Build.Dependency,
|
const optimize = options.optimize;
|
||||||
target: std.Build.ResolvedTarget,
|
|
||||||
optimize: std.builtin.OptimizeMode,
|
const upstream = b.dependency("oniguruma", .{});
|
||||||
) !*std.Build.Step.Compile {
|
|
||||||
const lib = b.addStaticLibrary(.{
|
const lib = b.addStaticLibrary(.{
|
||||||
.name = "oniguruma",
|
.name = "oniguruma",
|
||||||
.target = target,
|
.target = target,
|
||||||
@ -43,6 +66,7 @@ fn buildOniguruma(
|
|||||||
const t = target.result;
|
const t = target.result;
|
||||||
lib.linkLibC();
|
lib.linkLibC();
|
||||||
lib.addIncludePath(upstream.path("src"));
|
lib.addIncludePath(upstream.path("src"));
|
||||||
|
module.addIncludePath(upstream.path("src"));
|
||||||
|
|
||||||
if (target.result.isDarwin()) {
|
if (target.result.isDarwin()) {
|
||||||
const apple_sdk = @import("apple_sdk");
|
const apple_sdk = @import("apple_sdk");
|
||||||
@ -134,5 +158,7 @@ fn buildOniguruma(
|
|||||||
.{ .include_extensions = &.{".h"} },
|
.{ .include_extensions = &.{".h"} },
|
||||||
);
|
);
|
||||||
|
|
||||||
|
b.installArtifact(lib);
|
||||||
|
|
||||||
return lib;
|
return lib;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user