diff --git a/build.zig b/build.zig index df589189e..bce694224 100644 --- a/build.zig +++ b/build.zig @@ -16,6 +16,24 @@ pub fn build(b: *std.Build) !void { const codeUnitWidth = b.option(CodeUnitWidth, "code-unit-width", "Sets the code unit width") orelse .@"8"; const jit = b.option(bool, "support_jit", "Enable/disable JIT compiler support") orelse false; + const jit_source = if (jit) blk: { + const sljit = b.lazyDependency("sljit", .{}) orelse + return error.MissingDependency; + + const files = b.addWriteFiles(); + + _ = files.addCopyDirectory( + sljit.path("sljit_src"), + "deps/sljit/sljit_src", + .{}, + ); + + break :blk files.addCopyFile( + b.path("src/pcre2_jit_compile.c"), + "src/pcre2_jit_compile.c", + ); + } else b.path("src/pcre2_jit_compile.c"); + const pcre2_h_dir = b.addWriteFiles(); const pcre2_h = pcre2_h_dir.addCopyFile(b.path("src/pcre2.h.generic"), "pcre2.h"); b.addNamedLazyPath("pcre2.h", pcre2_h); @@ -118,7 +136,6 @@ pub fn build(b: *std.Build) !void { "src/pcre2_error.c", "src/pcre2_extuni.c", "src/pcre2_find_bracket.c", - "src/pcre2_jit_compile.c", "src/pcre2_maketables.c", "src/pcre2_match.c", "src/pcre2_match_data.c", @@ -140,6 +157,11 @@ pub fn build(b: *std.Build) !void { .flags = cflags, }); + lib_mod.addCSourceFile(.{ + .file = jit_source, + .flags = cflags, + }); + const lib = b.addLibrary(.{ .name = b.fmt("pcre2-{t}", .{codeUnitWidth}), .root_module = lib_mod, diff --git a/build.zig.zon b/build.zig.zon index 447cc57e5..b20e3ad8a 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -7,7 +7,12 @@ .fingerprint = 0x914b3d63ebab9e21, .minimum_zig_version = "0.15.2", - .dependencies = .{}, + .dependencies = .{ + .sljit = .{ + .url = "git+https://github.com/zherczeg/sljit.git#45f910b78c6605ebf5b53d3ec7cb00f2312fe417", + .hash = "N-V-__8AAIUFRABdZku3bW_1S5GOC4iaFh17LsRurEDR1lvv", + }, + }, .paths = .{ "build.zig", "build.zig.zon", "src/", "doc/",