Skip to content

Commit

Permalink
[update #9] add oniguruma
Browse files Browse the repository at this point in the history
  • Loading branch information
tiawl authored Nov 2, 2024
2 parents 6a9d39f + 6ee1728 commit 8c8b220
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 44 deletions.
84 changes: 42 additions & 42 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,45 +19,45 @@ jobs:
run: |
zig build --build-file "${GITHUB_WORKSPACE}/examples/build.zig"
env -C ./examples ./zig-out/bin/examples
windows:
strategy:
fail-fast: false
matrix:
arch:
- amd64
- i386
include:
- arch: amd64
msystem: UCRT64
- arch: i386
msystem: MINGW32
runs-on: windows-2022
env:
LDFLAGS: -s
SUFFIX: windows-${{ matrix.arch }}
defaults:
run:
shell: msys2 {0}
steps:
- uses: tiawl/[email protected]
- uses: actions/checkout@v4
- uses: mlugg/setup-zig@v1
with:
version: ${{ env.zig_version }}
- uses: msys2/setup-msys2@v2
with:
update: true
msystem: ${{ matrix.msystem }}
install: >-
base-devel
git
autoconf
automake
libtool
pacboy: >-
toolchain:p
- name: Test building and running examples
shell: bash
run: |
zig build --build-file "${GITHUB_WORKSPACE}/examples/build.zig"
env -C "${GITHUB_WORKSPACE}/examples" ./zig-out/bin/examples
# windows:
# strategy:
# fail-fast: false
# matrix:
# arch:
# - amd64
# - i386
# include:
# - arch: amd64
# msystem: UCRT64
# - arch: i386
# msystem: MINGW32
# runs-on: windows-2022
# env:
# LDFLAGS: -s
# SUFFIX: windows-${{ matrix.arch }}
# defaults:
# run:
# shell: msys2 {0}
# steps:
# - uses: tiawl/[email protected]
# - uses: actions/checkout@v4
# - uses: mlugg/setup-zig@v1
# with:
# version: ${{ env.zig_version }}
# - uses: msys2/setup-msys2@v2
# with:
# update: true
# msystem: ${{ matrix.msystem }}
# install: >-
# base-devel
# git
# autoconf
# automake
# libtool
# pacboy: >-
# toolchain:p
# - name: Test building and running examples
# shell: bash
# run: |
# zig build --build-file "${GITHUB_WORKSPACE}/examples/build.zig"
# env -C "${GITHUB_WORKSPACE}/examples" ./zig-out/bin/examples
1 change: 1 addition & 0 deletions .github/workflows/pong.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
repository_dispatch:
types:
- ping-from-toolbox
- ping-from-oniguruma.zig
- ping-from-spaceporn-action-bot
- ping-from-spaceporn-action-ci
- ping-from-spaceporn-action-cd-pong
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ These repositories are automatically updated when a new release is available:
This repository is automatically updated when a new release is available from these repositories:
* [jqlang/jq][1]
* [tiawl/toolbox][3]
* [tiawl/oniguruma.zig][9]
* [tiawl/spaceporn-action-env][8]
* [tiawl/spaceporn-action-bot][4]
* [tiawl/spaceporn-action-ci][5] (TODO)
Expand Down Expand Up @@ -60,3 +61,4 @@ The parts of this repository originated from this repository are dedicated to th
[6]:https://github.com/tiawl/spaceporn-action-cd-ping
[7]:https://github.com/tiawl/spaceporn-action-cd-pong
[8]:https://github.com/tiawl/spaceporn-action-env
[9]:https://github.com/tiawl/oniguruma.zig
15 changes: 14 additions & 1 deletion build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ pub fn build (builder: *std.Build) !void
.host = toolbox.Repository.Host.github,
.ref = toolbox.Repository.Reference.tag,
},
.oniguruma = .{
.name = "tiawl/oniguruma.zig",
.host = toolbox.Repository.Host.github,
.ref = toolbox.Repository.Reference.commit,
},
.winpthreads = .{
.name = "kassane/winpthreads-zigbuild",
.host = toolbox.Repository.Host.github,
Expand Down Expand Up @@ -144,6 +149,14 @@ pub fn build (builder: *std.Build) !void
lib.linkSystemLibrary ("shlwapi");
}

const oniguruma_dep = builder.dependency ("oniguruma", .{
.target = target,
.optimize = optimize,
});

lib.linkLibrary (oniguruma_dep.artifact ("oniguruma"));
lib.installLibraryHeaders (oniguruma_dep.artifact ("oniguruma"));

lib.linkLibC ();

toolbox.addHeader (lib, path.getJqSrc (), ".", &.{ ".h", ".inc", });
Expand All @@ -152,7 +165,7 @@ pub fn build (builder: *std.Build) !void
try std.fs.openDirAbsolute (path.getJqSrc (), .{ .iterate = true, });
defer jq_src_dir.close ();

const flags = [_][] const u8 { "-DIEEE_8087=1", "-D_GNU_SOURCE=1", };
const flags = [_][] const u8 { "-DIEEE_8087=1", "-D_GNU_SOURCE=1", "-DHAVE_LIBONIG=1" };
var it = jq_src_dir.iterate ();
while (try it.next ()) |*entry|
{
Expand Down
4 changes: 4 additions & 0 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
.url = "https://github.com/tiawl/toolbox/archive/refs/tags/1.11.2.tar.gz",
.hash = "122037046680450473adc3670f08c8695638d05f07c00be18e94ff3f7e21edf9ed9e",
},
.oniguruma = .{
.url = "https://github.com/tiawl/oniguruma.zig/archive/refs/tags/v6.9.9.tar.gz",
.hash = "1220901998824e7f2ba9469c64caa8841993d7a9fce51309db50b818af2f1b60bd5d",
},
.winpthreads = .{
.url = "https://github.com/kassane/winpthreads-zigbuild/archive/909ce0eacf5513be493837d13f2ef84f935bf9a8.tar.gz",
.hash = "1220c08bf3c940723ee12a0c14bb761cb14c63bdae54ce34d47450eed168daa62780",
Expand Down
2 changes: 1 addition & 1 deletion examples/src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub fn main () !void
defer c.jq_util_input_free (&input_state);
c.jq_set_input_cb (jq, c.jq_util_input_next_input_cb, input_state);

const program = ".data[].firstName";
const program = ".data[].firstName | sub(\"Sher\"; \"Un\")";
const compiled = c.jq_compile (jq, try allocator.dupeZ (u8, program));

if (compiled == 0) return error.JqCompileError;
Expand Down

0 comments on commit 8c8b220

Please sign in to comment.