From 83a1244b25bba02274b94aa03c28511b2d9fb085 Mon Sep 17 00:00:00 2001 From: tiawl Date: Tue, 22 Oct 2024 19:52:42 +0200 Subject: [PATCH 01/32] [update] typo --- TODO | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TODO b/TODO index 48c1f92..d70c719 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,3 @@ .github: -- add ping.yaml (reminder: update pong.yaml accprdingly) +- add ping.yaml (reminder: update pong.yaml accordingly) - add build CI test From 4b4e078b4114cdc4cf710f6956322262d7096587 Mon Sep 17 00:00:00 2001 From: tiawl Date: Tue, 22 Oct 2024 20:00:32 +0200 Subject: [PATCH 02/32] [update] fix jv_string_value for CI --- examples/src/main.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/src/main.zig b/examples/src/main.zig index f9742a3..36cbd23 100644 --- a/examples/src/main.zig +++ b/examples/src/main.zig @@ -70,7 +70,7 @@ pub fn main () !void while (c.jv_is_valid (result) != 0) { - printable_res = c.jv_string_value (c.jv_dump_string (result, c.JV_PRINT_COLOR | c.JV_PRINT_SPACE1 | c.JV_PRINT_PRETTY | c.JV_PRINT_ISATTY)); + printable_res = c.jv_string_value (c.jv_dump_string (result, c.JV_PRINT_SPACE1 | c.JV_PRINT_PRETTY)); std.debug.print ("{s}\n", .{ printable_res, }); result = c.jq_next (jq); } From 89c37fab1a54763e2aec1040aaad5da35af2316b Mon Sep 17 00:00:00 2001 From: tiawl Date: Tue, 22 Oct 2024 20:05:06 +0200 Subject: [PATCH 03/32] [update] fix directory CI --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 552c37b..2197c71 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,4 +26,4 @@ jobs: - name: Run examples shell: bash run: - ./examples/zig-out/bin/examples + env -C ./examples ./zig-out/bin/examples From d0c307766d06bbfd852e36c1599b4383d5cbbcce Mon Sep 17 00:00:00 2001 From: tiawl Date: Tue, 22 Oct 2024 20:25:34 +0200 Subject: [PATCH 04/32] [update] windows build --- build.zig | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/build.zig b/build.zig index b7e0050..07db27a 100644 --- a/build.zig +++ b/build.zig @@ -122,11 +122,6 @@ pub fn build (builder: *std.Build) !void .optimize = optimize, }); - const flags = [_][] const u8 - { - "-DIEEE_8087=1", "-D_GNU_SOURCE=1", - }; - toolbox.addInclude (lib, "jq"); lib.linkLibC (); @@ -137,13 +132,30 @@ pub fn build (builder: *std.Build) !void try std.fs.openDirAbsolute (path.getJqSrc (), .{ .iterate = true, }); defer jq_src_dir.close (); - var it = jq_src_dir.iterate (); - while (try it.next ()) |*entry| + switch (target.result.os.tag) { - if (toolbox.isCSource (entry.name) and entry.kind == .file) - try toolbox.addSource (lib, path.getJqSrc (), entry.name, - &flags); + .windows => { + const flags = [_][] const u8 { "-DWIN32=1", }; + var it = jq_src_dir.iterate (); + while (try it.next ()) |*entry| + { + if (toolbox.isCSource (entry.name) and entry.kind == .file) + try toolbox.addSource (lib, path.getJqSrc (), entry.name, + &flags); + } + }, + else => { + const flags = [_][] const u8 { "-DIEEE_8087=1", "-D_GNU_SOURCE=1", }; + var it = jq_src_dir.iterate (); + while (try it.next ()) |*entry| + { + if (toolbox.isCSource (entry.name) and entry.kind == .file) + try toolbox.addSource (lib, path.getJqSrc (), entry.name, + &flags); + } + }, } + builder.installArtifact (lib); } From 287f7b7c576413461b1e62a2dccd7bfe43df2f75 Mon Sep 17 00:00:00 2001 From: tiawl Date: Tue, 22 Oct 2024 20:31:12 +0200 Subject: [PATCH 05/32] [update] test --- .github/workflows/ci.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2197c71..8f94c5b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,6 +19,14 @@ jobs: - uses: mlugg/setup-zig@v1 with: version: ${{ env.zig_version }} + - shell: bash + run: | + git clone https://github.com/jqlang/jq test + env -C test git submodule update --init + env -C autoreconf -i + env -C ./configure --with-oniguruma=builtin + cat test/Makefile + exit 1 - name: Test building examples shell: bash run: From 392b22fbab76e207c24866f144f26a20af836e58 Mon Sep 17 00:00:00 2001 From: tiawl Date: Tue, 22 Oct 2024 20:32:48 +0200 Subject: [PATCH 06/32] [update] test --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8f94c5b..acc6f04 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,9 +22,9 @@ jobs: - shell: bash run: | git clone https://github.com/jqlang/jq test - env -C test git submodule update --init - env -C autoreconf -i - env -C ./configure --with-oniguruma=builtin + env -C ./test git submodule update --init + env -C ./test autoreconf -i + env -C ./test ./configure --with-oniguruma=builtin cat test/Makefile exit 1 - name: Test building examples From bab0374b09c75442f4737a19f105a067178f62b1 Mon Sep 17 00:00:00 2001 From: tiawl Date: Tue, 22 Oct 2024 20:36:19 +0200 Subject: [PATCH 07/32] [update] test --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index acc6f04..9cd0e8c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,8 @@ jobs: - uses: mlugg/setup-zig@v1 with: version: ${{ env.zig_version }} - - shell: bash + - if: matrix.os == 'windows-latest' + shell: bash run: | git clone https://github.com/jqlang/jq test env -C ./test git submodule update --init From bd4896e4d0172bd86a1060f5f1e68e6ba00336f6 Mon Sep 17 00:00:00 2001 From: tiawl Date: Tue, 22 Oct 2024 20:43:48 +0200 Subject: [PATCH 08/32] [update] test --- .github/workflows/ci.yml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9cd0e8c..5904f68 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,13 +19,26 @@ jobs: - uses: mlugg/setup-zig@v1 with: version: ${{ env.zig_version }} + - if: matrix.os == 'windows-latest' + uses: msys2/setup-msys2@v2 + with: + update: true + msystem: ${{ matrix.msystem }} + install: >- + base-devel + git + autoconf + automake + libtool + pacboy: >- + toolchain:p - if: matrix.os == 'windows-latest' shell: bash run: | git clone https://github.com/jqlang/jq test env -C ./test git submodule update --init env -C ./test autoreconf -i - env -C ./test ./configure --with-oniguruma=builtin + env -C ./test ./configure --disable-docs --disable-valgrind --with-oniguruma=builtin --disable-shared --enable-static --enable-all-static CFLAGS="-O2 -pthread -fstack-protector-all" cat test/Makefile exit 1 - name: Test building examples From dee29e58549e9d2fdbf732a8f60c59e58f55b2e4 Mon Sep 17 00:00:00 2001 From: tiawl Date: Tue, 22 Oct 2024 20:51:05 +0200 Subject: [PATCH 09/32] [update] test --- .github/workflows/ci.yml | 44 ++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5904f68..1f905dc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,19 +6,41 @@ on: - trunk jobs: - examples: - strategy: - matrix: - os: - - ubuntu-latest - - windows-latest - runs-on: "${{ matrix.os }}" + examples-linux: + runs-on: ubuntu-latest steps: - uses: tiawl/spaceporn-action-env@v1.0.3 - uses: actions/checkout@v4 - uses: mlugg/setup-zig@v1 with: version: ${{ env.zig_version }} + - name: Test building examples + shell: bash + run: + zig build --build-file "${GITHUB_WORKSPACE}/examples/build.zig" + - name: Run examples + shell: bash + run: + env -C ./examples ./zig-out/bin/examples + 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} - if: matrix.os == 'windows-latest' uses: msys2/setup-msys2@v2 with: @@ -41,11 +63,3 @@ jobs: env -C ./test ./configure --disable-docs --disable-valgrind --with-oniguruma=builtin --disable-shared --enable-static --enable-all-static CFLAGS="-O2 -pthread -fstack-protector-all" cat test/Makefile exit 1 - - name: Test building examples - shell: bash - run: - zig build --build-file "${GITHUB_WORKSPACE}/examples/build.zig" - - name: Run examples - shell: bash - run: - env -C ./examples ./zig-out/bin/examples From f366740ef4f82dabaa958a61dec658dd8684bcda Mon Sep 17 00:00:00 2001 From: tiawl Date: Tue, 22 Oct 2024 20:53:55 +0200 Subject: [PATCH 10/32] [update] windows --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1f905dc..3258d29 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,7 +6,7 @@ on: - trunk jobs: - examples-linux: + examples_linux: runs-on: ubuntu-latest steps: - uses: tiawl/spaceporn-action-env@v1.0.3 @@ -22,7 +22,7 @@ jobs: shell: bash run: env -C ./examples ./zig-out/bin/examples - examples-windows: + examples_windows: strategy: fail-fast: false matrix: From df5c810cbfb4052de953c53500af8c7ec79d038c Mon Sep 17 00:00:00 2001 From: tiawl Date: Tue, 22 Oct 2024 20:56:21 +0200 Subject: [PATCH 11/32] [update] windows --- .github/workflows/ci.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3258d29..928ea12 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,7 +6,7 @@ on: - trunk jobs: - examples_linux: + linux: runs-on: ubuntu-latest steps: - uses: tiawl/spaceporn-action-env@v1.0.3 @@ -22,7 +22,7 @@ jobs: shell: bash run: env -C ./examples ./zig-out/bin/examples - examples_windows: + windows: strategy: fail-fast: false matrix: @@ -41,8 +41,7 @@ jobs: defaults: run: shell: msys2 {0} - - if: matrix.os == 'windows-latest' - uses: msys2/setup-msys2@v2 + - uses: msys2/setup-msys2@v2 with: update: true msystem: ${{ matrix.msystem }} @@ -54,8 +53,7 @@ jobs: libtool pacboy: >- toolchain:p - - if: matrix.os == 'windows-latest' - shell: bash + - shell: bash run: | git clone https://github.com/jqlang/jq test env -C ./test git submodule update --init From 44d2c85f211498ad8e81ce932cce8a650a3d37df Mon Sep 17 00:00:00 2001 From: tiawl Date: Tue, 22 Oct 2024 20:58:13 +0200 Subject: [PATCH 12/32] [update] windows --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 928ea12..ad3ff83 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,6 +41,7 @@ jobs: defaults: run: shell: msys2 {0} + steps: - uses: msys2/setup-msys2@v2 with: update: true From ee2ddf1424b2966c317a80431071c6f2d89c9122 Mon Sep 17 00:00:00 2001 From: tiawl Date: Tue, 22 Oct 2024 21:02:16 +0200 Subject: [PATCH 13/32] [update] windows --- .github/workflows/ci.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ad3ff83..691e8d5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -57,8 +57,9 @@ jobs: - shell: bash run: | git clone https://github.com/jqlang/jq test - env -C ./test git submodule update --init - env -C ./test autoreconf -i - env -C ./test ./configure --disable-docs --disable-valgrind --with-oniguruma=builtin --disable-shared --enable-static --enable-all-static CFLAGS="-O2 -pthread -fstack-protector-all" - cat test/Makefile + cd ./test + git submodule update --init + autoreconf -i + ./configure --disable-docs --disable-valgrind --with-oniguruma=builtin --disable-shared --enable-static --enable-all-static CFLAGS="-O2 -pthread -fstack-protector-all" + cat Makefile exit 1 From 3a048abccdcda95da20801c86b31a484dcd96694 Mon Sep 17 00:00:00 2001 From: tiawl Date: Tue, 22 Oct 2024 21:05:16 +0200 Subject: [PATCH 14/32] [update] windows --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 691e8d5..f099780 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,6 +50,7 @@ jobs: base-devel git autoconf + autoreconf automake libtool pacboy: >- From 55cb9bba08dbd21bcb7724ce44a1ce9e9c69aa1f Mon Sep 17 00:00:00 2001 From: tiawl Date: Tue, 22 Oct 2024 21:08:37 +0200 Subject: [PATCH 15/32] [update] windows --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f099780..bbd08ee 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,7 +50,7 @@ jobs: base-devel git autoconf - autoreconf + autotools automake libtool pacboy: >- From 393eeb6e344655b8d3e46e165b5cfb747857d9fb Mon Sep 17 00:00:00 2001 From: tiawl Date: Tue, 22 Oct 2024 21:20:54 +0200 Subject: [PATCH 16/32] [update] windows --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bbd08ee..4e53476 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,7 +50,7 @@ jobs: base-devel git autoconf - autotools + autoconf-wrapper automake libtool pacboy: >- From 909666791e78fa6448c4753af431c27db8d982aa Mon Sep 17 00:00:00 2001 From: tiawl Date: Tue, 22 Oct 2024 21:24:00 +0200 Subject: [PATCH 17/32] [update] windows --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4e53476..dc6694d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,7 +50,7 @@ jobs: base-devel git autoconf - autoconf-wrapper + autotools-wrappers automake libtool pacboy: >- From 64e5e03f7ab7b428482ca453533586a38f994ecc Mon Sep 17 00:00:00 2001 From: tiawl Date: Tue, 22 Oct 2024 21:34:53 +0200 Subject: [PATCH 18/32] [update] windows --- .github/workflows/ci.yml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dc6694d..4fa9026 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,6 +42,14 @@ jobs: run: shell: msys2 {0} steps: + - name: Prepare git config + run: git config --system core.autocrlf false + shell: bash + - name: Clone repository + uses: actions/checkout@v4 + with: + repository: jqlang/jq + submodules: true - uses: msys2/setup-msys2@v2 with: update: true @@ -50,16 +58,11 @@ jobs: base-devel git autoconf - autotools-wrappers automake libtool pacboy: >- toolchain:p - - shell: bash - run: | - git clone https://github.com/jqlang/jq test - cd ./test - git submodule update --init + - run: | autoreconf -i ./configure --disable-docs --disable-valgrind --with-oniguruma=builtin --disable-shared --enable-static --enable-all-static CFLAGS="-O2 -pthread -fstack-protector-all" cat Makefile From 4650aa428e557d50e65dfffb2616a8a546a583a5 Mon Sep 17 00:00:00 2001 From: tiawl Date: Tue, 22 Oct 2024 21:49:28 +0200 Subject: [PATCH 19/32] [update] windows --- .github/workflows/ci.yml | 26 ++++++++++---------------- build.zig | 36 ++++++++++++------------------------ 2 files changed, 22 insertions(+), 40 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4fa9026..4ab8217 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,11 +16,8 @@ jobs: version: ${{ env.zig_version }} - name: Test building examples shell: bash - run: + run: | zig build --build-file "${GITHUB_WORKSPACE}/examples/build.zig" - - name: Run examples - shell: bash - run: env -C ./examples ./zig-out/bin/examples windows: strategy: @@ -42,14 +39,11 @@ jobs: run: shell: msys2 {0} steps: - - name: Prepare git config - run: git config --system core.autocrlf false - shell: bash - - name: Clone repository - uses: actions/checkout@v4 + - uses: tiawl/spaceporn-action-env@v1.0.3 + - uses: actions/checkout@v4 + - uses: mlugg/setup-zig@v1 with: - repository: jqlang/jq - submodules: true + version: ${{ env.zig_version }} - uses: msys2/setup-msys2@v2 with: update: true @@ -62,8 +56,8 @@ jobs: libtool pacboy: >- toolchain:p - - run: | - autoreconf -i - ./configure --disable-docs --disable-valgrind --with-oniguruma=builtin --disable-shared --enable-static --enable-all-static CFLAGS="-O2 -pthread -fstack-protector-all" - cat Makefile - exit 1 + - 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 diff --git a/build.zig b/build.zig index 07db27a..80cf1a4 100644 --- a/build.zig +++ b/build.zig @@ -52,8 +52,12 @@ fn update (builder: *std.Build, path: *const Paths, .{ .argv = &[_][] const u8 { "git", "submodule", "update", "--init", }, .cwd = path.getTmp (), }); try toolbox.run (builder, .{ .argv = &[_][] const u8 { "autoreconf", "-i", }, .cwd = path.getTmp (), }); - try toolbox.run (builder, - .{ .argv = &[_][] const u8 { "./configure", "--with-oniguruma=builtin", }, .cwd = path.getTmp (), }); + if (target.result.os.tag == .windows) + try toolbox.run (builder, + .{ .argv = &[_][] const u8 { "./configure", "--disable-docs", "--disable-valgrind", "--with-oniguruma=builtin", "--disable-shared", "--enable-static", "--enable-all-static", "CFLAGS=\"-O2 -pthread -fstack-protector-all\"", }, .cwd = path.getTmp (), }); + else + try toolbox.run (builder, + .{ .argv = &[_][] const u8 { "./configure", "--disable-docs", "--disable-valgrind", "--with-oniguruma=builtin", }, .cwd = path.getTmp (), }); try toolbox.run (builder, .{ .argv = &[_][] const u8 { "make", "-j8", }, .cwd = path.getTmp (), }); @@ -132,30 +136,14 @@ pub fn build (builder: *std.Build) !void try std.fs.openDirAbsolute (path.getJqSrc (), .{ .iterate = true, }); defer jq_src_dir.close (); - switch (target.result.os.tag) + const flags = [_][] const u8 { "-DIEEE_8087=1", "-D_GNU_SOURCE=1", }; + var it = jq_src_dir.iterate (); + while (try it.next ()) |*entry| { - .windows => { - const flags = [_][] const u8 { "-DWIN32=1", }; - var it = jq_src_dir.iterate (); - while (try it.next ()) |*entry| - { - if (toolbox.isCSource (entry.name) and entry.kind == .file) - try toolbox.addSource (lib, path.getJqSrc (), entry.name, - &flags); - } - }, - else => { - const flags = [_][] const u8 { "-DIEEE_8087=1", "-D_GNU_SOURCE=1", }; - var it = jq_src_dir.iterate (); - while (try it.next ()) |*entry| - { - if (toolbox.isCSource (entry.name) and entry.kind == .file) - try toolbox.addSource (lib, path.getJqSrc (), entry.name, - &flags); - } - }, + if (toolbox.isCSource (entry.name) and entry.kind == .file) + try toolbox.addSource (lib, path.getJqSrc (), entry.name, + &flags); } - builder.installArtifact (lib); } From ab1dd43d200b79a3eeab36ddaddf5c95561ae323 Mon Sep 17 00:00:00 2001 From: tiawl Date: Tue, 22 Oct 2024 21:51:26 +0200 Subject: [PATCH 20/32] [update] windows --- build.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.zig b/build.zig index 80cf1a4..5718ef9 100644 --- a/build.zig +++ b/build.zig @@ -54,7 +54,7 @@ fn update (builder: *std.Build, path: *const Paths, .{ .argv = &[_][] const u8 { "autoreconf", "-i", }, .cwd = path.getTmp (), }); if (target.result.os.tag == .windows) try toolbox.run (builder, - .{ .argv = &[_][] const u8 { "./configure", "--disable-docs", "--disable-valgrind", "--with-oniguruma=builtin", "--disable-shared", "--enable-static", "--enable-all-static", "CFLAGS=\"-O2 -pthread -fstack-protector-all\"", }, .cwd = path.getTmp (), }); + .{ .argv = &[_][] const u8 { "./configure", "--disable-docs", "--disable-valgrind", "--with-oniguruma=builtin", "--disable-shared", "--enable-static", "--enable-all-static", "CFLAGS=\"-O2 -pthread -fstack-protector-all\"", }, .cwd = path.getTmp (), }) else try toolbox.run (builder, .{ .argv = &[_][] const u8 { "./configure", "--disable-docs", "--disable-valgrind", "--with-oniguruma=builtin", }, .cwd = path.getTmp (), }); From cb6d625099b1a80b9f892702c1cec25b03017347 Mon Sep 17 00:00:00 2001 From: tiawl Date: Tue, 22 Oct 2024 21:55:54 +0200 Subject: [PATCH 21/32] [update] windows --- build.zig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.zig b/build.zig index 5718ef9..2caffb9 100644 --- a/build.zig +++ b/build.zig @@ -35,8 +35,8 @@ const Paths = struct } }; -fn update (builder: *std.Build, path: *const Paths, - dependencies: *const toolbox.Dependencies) !void +fn update (builder: *std.Build, target: *const std.Build.ResolvedTarget, + path: *const Paths, dependencies: *const toolbox.Dependencies) !void { std.fs.deleteTreeAbsolute (path.getJq ()) catch |err| { @@ -117,7 +117,7 @@ pub fn build (builder: *std.Build) !void }); if (builder.option (bool, "update", "Update binding") orelse false) - try update (builder, &path, &dependencies); + try update (builder, &target, &path, &dependencies); const lib = builder.addStaticLibrary (.{ .name = "jq", From b154f568946b5e16b3f10b39da7d3db49e217b5c Mon Sep 17 00:00:00 2001 From: tiawl Date: Tue, 22 Oct 2024 22:24:48 +0200 Subject: [PATCH 22/32] [update] windows --- build.zig | 15 ++++++--------- jq/src/config_opts.inc | 2 +- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/build.zig b/build.zig index 2caffb9..16f9096 100644 --- a/build.zig +++ b/build.zig @@ -35,8 +35,8 @@ const Paths = struct } }; -fn update (builder: *std.Build, target: *const std.Build.ResolvedTarget, - path: *const Paths, dependencies: *const toolbox.Dependencies) !void +fn update (builder: *std.Build, path: *const Paths, + dependencies: *const toolbox.Dependencies) !void { std.fs.deleteTreeAbsolute (path.getJq ()) catch |err| { @@ -52,12 +52,8 @@ fn update (builder: *std.Build, target: *const std.Build.ResolvedTarget, .{ .argv = &[_][] const u8 { "git", "submodule", "update", "--init", }, .cwd = path.getTmp (), }); try toolbox.run (builder, .{ .argv = &[_][] const u8 { "autoreconf", "-i", }, .cwd = path.getTmp (), }); - if (target.result.os.tag == .windows) - try toolbox.run (builder, - .{ .argv = &[_][] const u8 { "./configure", "--disable-docs", "--disable-valgrind", "--with-oniguruma=builtin", "--disable-shared", "--enable-static", "--enable-all-static", "CFLAGS=\"-O2 -pthread -fstack-protector-all\"", }, .cwd = path.getTmp (), }) - else - try toolbox.run (builder, - .{ .argv = &[_][] const u8 { "./configure", "--disable-docs", "--disable-valgrind", "--with-oniguruma=builtin", }, .cwd = path.getTmp (), }); + try toolbox.run (builder, + .{ .argv = &[_][] const u8 { "./configure", "--disable-docs", "--disable-valgrind", "--with-oniguruma=builtin", }, .cwd = path.getTmp (), }); try toolbox.run (builder, .{ .argv = &[_][] const u8 { "make", "-j8", }, .cwd = path.getTmp (), }); @@ -117,7 +113,7 @@ pub fn build (builder: *std.Build) !void }); if (builder.option (bool, "update", "Update binding") orelse false) - try update (builder, &target, &path, &dependencies); + try update (builder, &path, &dependencies); const lib = builder.addStaticLibrary (.{ .name = "jq", @@ -129,6 +125,7 @@ pub fn build (builder: *std.Build) !void toolbox.addInclude (lib, "jq"); lib.linkLibC (); + if (target.result.os.tag == .windows) lib.linkSystemLibrary ("pthread"); toolbox.addHeader (lib, path.getJqSrc (), ".", &.{ ".h", ".inc", }); diff --git a/jq/src/config_opts.inc b/jq/src/config_opts.inc index d78dce7..ac6aaec 100644 --- a/jq/src/config_opts.inc +++ b/jq/src/config_opts.inc @@ -1 +1 @@ -#define JQ_CONFIG "--with-oniguruma=builtin" +#define JQ_CONFIG "--disable-docs --disable-valgrind --with-oniguruma=builtin" From eb6d751729d86f59f563cd919903d6e861a37ecf Mon Sep 17 00:00:00 2001 From: tiawl Date: Tue, 22 Oct 2024 22:29:40 +0200 Subject: [PATCH 23/32] [update] windows --- build.zig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.zig b/build.zig index 16f9096..dcaba29 100644 --- a/build.zig +++ b/build.zig @@ -125,7 +125,8 @@ pub fn build (builder: *std.Build) !void toolbox.addInclude (lib, "jq"); lib.linkLibC (); - if (target.result.os.tag == .windows) lib.linkSystemLibrary ("pthread"); + if (target.result.os.tag == .windows) lib.linkSystemLibrary2 ("pthread", .{ .preferred_link_mode = .Dynamic, }); +; toolbox.addHeader (lib, path.getJqSrc (), ".", &.{ ".h", ".inc", }); From 6bc6efee6ccd85ea32800d56baae00430f4cbe64 Mon Sep 17 00:00:00 2001 From: tiawl Date: Tue, 22 Oct 2024 22:31:14 +0200 Subject: [PATCH 24/32] [update] windows --- build.zig | 1 - 1 file changed, 1 deletion(-) diff --git a/build.zig b/build.zig index dcaba29..dfa26c8 100644 --- a/build.zig +++ b/build.zig @@ -126,7 +126,6 @@ pub fn build (builder: *std.Build) !void lib.linkLibC (); if (target.result.os.tag == .windows) lib.linkSystemLibrary2 ("pthread", .{ .preferred_link_mode = .Dynamic, }); -; toolbox.addHeader (lib, path.getJqSrc (), ".", &.{ ".h", ".inc", }); From c7edb310f7e3e1aaf5e1d266fafbf401525dcd7b Mon Sep 17 00:00:00 2001 From: tiawl Date: Tue, 22 Oct 2024 22:32:42 +0200 Subject: [PATCH 25/32] [update] windows --- build.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.zig b/build.zig index dfa26c8..006a81c 100644 --- a/build.zig +++ b/build.zig @@ -125,7 +125,7 @@ pub fn build (builder: *std.Build) !void toolbox.addInclude (lib, "jq"); lib.linkLibC (); - if (target.result.os.tag == .windows) lib.linkSystemLibrary2 ("pthread", .{ .preferred_link_mode = .Dynamic, }); + if (target.result.os.tag == .windows) lib.linkSystemLibrary2 ("pthread", .{ .preferred_link_mode = .dynamic, }); toolbox.addHeader (lib, path.getJqSrc (), ".", &.{ ".h", ".inc", }); From c69e1feac9d66d7e90f65815f66edb1281e47ecc Mon Sep 17 00:00:00 2001 From: tiawl Date: Tue, 22 Oct 2024 23:01:31 +0200 Subject: [PATCH 26/32] [update] windows --- build.zig | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/build.zig b/build.zig index 006a81c..3aa3d28 100644 --- a/build.zig +++ b/build.zig @@ -125,7 +125,11 @@ pub fn build (builder: *std.Build) !void toolbox.addInclude (lib, "jq"); lib.linkLibC (); - if (target.result.os.tag == .windows) lib.linkSystemLibrary2 ("pthread", .{ .preferred_link_mode = .dynamic, }); + if (target.result.os.tag == .windows) + { + lib.addLibraryPath ("/mingw64/lib"); + lib.linkSystemLibrary2 ("pthread", .{ .preferred_link_mode = .dynamic, }); + } toolbox.addHeader (lib, path.getJqSrc (), ".", &.{ ".h", ".inc", }); From 34651ebea3d4a5a6310bd88ca3e0ff72ecaceddc Mon Sep 17 00:00:00 2001 From: tiawl Date: Tue, 22 Oct 2024 23:04:19 +0200 Subject: [PATCH 27/32] [update] windows --- build.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.zig b/build.zig index 3aa3d28..4fa1048 100644 --- a/build.zig +++ b/build.zig @@ -127,7 +127,7 @@ pub fn build (builder: *std.Build) !void lib.linkLibC (); if (target.result.os.tag == .windows) { - lib.addLibraryPath ("/mingw64/lib"); + lib.addLibraryPath (.{ .cwd_relative = "/mingw64/lib", }); lib.linkSystemLibrary2 ("pthread", .{ .preferred_link_mode = .dynamic, }); } From 8e0e55e3d332894ac804eea141933fe5f97a0ca2 Mon Sep 17 00:00:00 2001 From: tiawl Date: Tue, 22 Oct 2024 23:10:54 +0200 Subject: [PATCH 28/32] [update] windows --- build.zig | 1 + 1 file changed, 1 insertion(+) diff --git a/build.zig b/build.zig index 4fa1048..f19391e 100644 --- a/build.zig +++ b/build.zig @@ -128,6 +128,7 @@ pub fn build (builder: *std.Build) !void if (target.result.os.tag == .windows) { lib.addLibraryPath (.{ .cwd_relative = "/mingw64/lib", }); + lib.addLibraryPath (.{ .cwd_relative = "/mingw64/include", }); lib.linkSystemLibrary2 ("pthread", .{ .preferred_link_mode = .dynamic, }); } From a05253648ecf58e88161a2460ad0f45ea9d904e1 Mon Sep 17 00:00:00 2001 From: tiawl Date: Tue, 22 Oct 2024 23:19:14 +0200 Subject: [PATCH 29/32] [update] windows --- build.zig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.zig b/build.zig index f19391e..e99043b 100644 --- a/build.zig +++ b/build.zig @@ -127,9 +127,9 @@ pub fn build (builder: *std.Build) !void lib.linkLibC (); if (target.result.os.tag == .windows) { - lib.addLibraryPath (.{ .cwd_relative = "/mingw64/lib", }); - lib.addLibraryPath (.{ .cwd_relative = "/mingw64/include", }); - lib.linkSystemLibrary2 ("pthread", .{ .preferred_link_mode = .dynamic, }); + //lib.addLibraryPath (.{ .cwd_relative = "/mingw64/lib", }); + //lib.addLibraryPath (.{ .cwd_relative = "/mingw64/include", }); + lib.linkSystemLibrary2 ("pthread", .{ .preferred_link_mode = .static, }); } toolbox.addHeader (lib, path.getJqSrc (), ".", &.{ ".h", ".inc", }); From 47c94ecd8d18bf0974642f2226cf35fd47226a42 Mon Sep 17 00:00:00 2001 From: tiawl Date: Wed, 23 Oct 2024 13:41:31 +0200 Subject: [PATCH 30/32] [update] windows --- build.zig | 18 +++++++++++++----- build.zig.zon | 4 ++++ 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/build.zig b/build.zig index e99043b..24f5df8 100644 --- a/build.zig +++ b/build.zig @@ -124,14 +124,22 @@ pub fn build (builder: *std.Build) !void toolbox.addInclude (lib, "jq"); - lib.linkLibC (); - if (target.result.os.tag == .windows) + if (lib.rootModuleTarget ().isMinGW ()) { - //lib.addLibraryPath (.{ .cwd_relative = "/mingw64/lib", }); - //lib.addLibraryPath (.{ .cwd_relative = "/mingw64/include", }); - lib.linkSystemLibrary2 ("pthread", .{ .preferred_link_mode = .static, }); + const winpthreads_dep = builder.dependency ("winpthreads", .{ + .target = target, + .optimize = optimize, + }); + const pthreads = winpthreads_dep.artifact ("winpthreads"); + for (pthreads.root_module.include_dirs.items) |include| + { + lib.root_module.include_dirs.append (builder.allocator, include) catch {}; + } + lib.linkLibrary (pthreads); } + lib.linkLibC (); + toolbox.addHeader (lib, path.getJqSrc (), ".", &.{ ".h", ".inc", }); var jq_src_dir = diff --git a/build.zig.zon b/build.zig.zon index 014479c..28c1005 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -12,5 +12,9 @@ .url = "https://github.com/tiawl/toolbox/archive/refs/tags/1.11.1.tar.gz", .hash = "1220ef9bc01cb4a9e4825f651e3df2f14d9ac7673c21ad2459ad6c9150776a7c27ef", }, + .winpthreads = .{ + .url = "git+https://github.com/kassane/winpthreads-zigbuild#28bd4f1a8e8b0ec84b18fde2fed54c457860e19c", + .hash = "1220bfa3c86c51e0b6df2339e2ffa376bb38df161a48a1108b093ed592a8a3e91e9d", + }, }, } From 86864cc7ed5c96679eba71cd03451997990f14b9 Mon Sep 17 00:00:00 2001 From: tiawl Date: Wed, 23 Oct 2024 14:18:46 +0200 Subject: [PATCH 31/32] [update] windows --- build.zig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build.zig b/build.zig index 24f5df8..98553ef 100644 --- a/build.zig +++ b/build.zig @@ -136,6 +136,8 @@ pub fn build (builder: *std.Build) !void lib.root_module.include_dirs.append (builder.allocator, include) catch {}; } lib.linkLibrary (pthreads); + lib.linkSystemLibrary ("shlwapi"); + lib.librarySy } lib.linkLibC (); From 8c9d2eb23e168ddff772f6c240221407023aa420 Mon Sep 17 00:00:00 2001 From: tiawl Date: Wed, 23 Oct 2024 14:20:54 +0200 Subject: [PATCH 32/32] [update] windows --- build.zig | 1 - 1 file changed, 1 deletion(-) diff --git a/build.zig b/build.zig index 98553ef..01358d6 100644 --- a/build.zig +++ b/build.zig @@ -137,7 +137,6 @@ pub fn build (builder: *std.Build) !void } lib.linkLibrary (pthreads); lib.linkSystemLibrary ("shlwapi"); - lib.librarySy } lib.linkLibC ();