Skip to content
Merged
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
7 changes: 2 additions & 5 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -473,14 +473,11 @@ jobs:
submodules: true

- name: Build
run: zig build
run: zig build -Dsupport_jit

- name: Test
run: |
# Zig does something weird with the stack - it uses more space than the
# equivalent plain C program.
ulimit -S -s 65536
srcdir=`pwd` pcre2test=`pwd`/zig-out/bin/pcre2test ./RunTest
srcdir=`pwd` pcre2test=`pwd`/zig-out/bin/pcre2test ./RunTest -bigstack

bazel:
# Tests with: Bazel build system
Expand Down
25 changes: 18 additions & 7 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub fn build(b: *std.Build) !void {
const optimize = b.standardOptimizeOption(.{});
const linkage = b.option(std.builtin.LinkMode, "linkage", "whether to statically or dynamically link the library") orelse @as(std.builtin.LinkMode, if (target.result.isGnuLibC()) .dynamic else .static);
const codeUnitWidth = b.option(CodeUnitWidth, "code-unit-width", "Sets the code unit width") orelse .@"8";
const jit = b.option(bool, "JIT", "Enable/disable JIT compiler support") orelse false;
const jit = b.option(bool, "support_jit", "Enable/disable JIT compiler support") orelse false;

const pcre2_header_dir = b.addWriteFiles();
const pcre2_header = pcre2_header_dir.addCopyFile(b.path("src/pcre2.h.generic"), "pcre2.h");
Expand All @@ -26,6 +26,11 @@ pub fn build(b: *std.Build) !void {
.HAVE_UNISTD_H = (target.result.os.tag != .windows),
.HAVE_WINDOWS_H = (target.result.os.tag == .windows),

.HAVE_ATTRIBUTE_UNINITIALIZED = true,
.HAVE_BUILTIN_MUL_OVERFLOW = true,
.HAVE_BUILTIN_UNREACHABLE = true,
.HAVE_VISIBILITY = true,

.HAVE_MEMMOVE = true,
.HAVE_STRERROR = true,

Expand All @@ -48,7 +53,7 @@ pub fn build(b: *std.Build) !void {
},
);

// pcre2-8/16/32.so
// pcre2-8/16/32 library

const lib_mod = b.createModule(.{
.target = target,
Expand Down Expand Up @@ -122,19 +127,19 @@ pub fn build(b: *std.Build) !void {
.link_libc = true,
});

pcre2test_mod.addImport(b.fmt("pcre2-{s}", .{@tagName(codeUnitWidth)}), lib_mod);

pcre2test_mod.addCMacro("HAVE_CONFIG_H", "");
if (linkage == .static) {
pcre2test_mod.addCMacro("PCRE2_STATIC", "");
} else {
pcre2test_mod.addCMacro("PCRE2POSIX_SHARED", "");
}

const pcre2test = b.addExecutable(.{
.name = "pcre2test",
.root_module = pcre2test_mod,
});

// pcre2-posix.so
// pcre2-posix library

if (codeUnitWidth == CodeUnitWidth.@"8") {
const posixLib_mod = b.createModule(.{
Expand All @@ -143,12 +148,12 @@ pub fn build(b: *std.Build) !void {
.link_libc = true,
});

pcre2test_mod.addImport("pcre2_posix", posixLib_mod);

posixLib_mod.addCMacro("HAVE_CONFIG_H", "");
posixLib_mod.addCMacro("PCRE2_CODE_UNIT_WIDTH", @tagName(codeUnitWidth));
if (linkage == .static) {
posixLib_mod.addCMacro("PCRE2_STATIC", "");
} else {
posixLib_mod.addCMacro("PCRE2POSIX_SHARED", "");
}

const posixLib = b.addLibrary(.{
Expand All @@ -167,8 +172,12 @@ pub fn build(b: *std.Build) !void {
},
});

posixLib.linkLibrary(lib);

posixLib.installHeader(b.path("src/pcre2posix.h"), "pcre2posix.h");
b.installArtifact(posixLib);

pcre2test.linkLibrary(posixLib);
}

// pcre2test (again)
Expand All @@ -181,5 +190,7 @@ pub fn build(b: *std.Build) !void {
.file = b.path("src/pcre2test.c"),
});

pcre2test.linkLibrary(lib);

b.installArtifact(pcre2test);
}
Loading