Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ jobs:
startsWith(github.ref, 'refs/tags/pcre2-'))
run: maint/UpdateDates.py

# The zig version from minimum_zig_version in build.zig.zon will be installed.
- name: Install zig
uses: mlugg/setup-zig@d1434d08867e3ee9daa34448df10607b98908d29 # v2.2.1

- name: UpdateAlways
run: maint/UpdateAlways

Expand Down
24 changes: 23 additions & 1 deletion build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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",
Expand All @@ -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,
Expand Down
7 changes: 6 additions & 1 deletion build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -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/",
Expand Down
9 changes: 9 additions & 0 deletions maint/UpdateAlways
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,15 @@ perl maint/CheckTxt "${txt_files[@]}"
perl maint/CheckTxt -ascii "${c_files[@]}"
perl maint/CheckTxt -crlf "${crlf_files[@]}"

SLJIT_COMMIT=`git ls-tree HEAD deps/sljit | awk '{print $3}'`
if [ -z "$SLJIT_COMMIT" ] ; then
echo "Warning: could not find deps/sljit in the tree; not updating build.zig.zon"
elif ! grep -q "sljit.git#$SLJIT_COMMIT" build.zig.zon ; then
echo "Updating SLJIT pin in build.zig.zon to $SLJIT_COMMIT"
zig fetch --save=sljit "git+https://github.com/zherczeg/sljit.git#$SLJIT_COMMIT"
if [ $? != 0 ] ; then exit 1; fi
fi

# Verify the version number in the Bazel file
if ! grep -E "version = \"$CURRENT_RELEASE\"" MODULE.bazel >/dev/null ; then
echo "Version number in MODULE.bazel does not match current release"
Expand Down