diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 552c37b..4ab8217 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,13 +6,8 @@ on: - trunk jobs: - examples: - strategy: - matrix: - os: - - ubuntu-latest - - windows-latest - runs-on: "${{ matrix.os }}" + linux: + runs-on: ubuntu-latest steps: - uses: tiawl/spaceporn-action-env@v1.0.3 - uses: actions/checkout@v4 @@ -21,9 +16,48 @@ 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 + 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: - ./examples/zig-out/bin/examples + shell: msys2 {0} + steps: + - uses: tiawl/spaceporn-action-env@v1.0.3 + - 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 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 diff --git a/build.zig b/build.zig index b7e0050..01358d6 100644 --- a/build.zig +++ b/build.zig @@ -53,7 +53,7 @@ fn update (builder: *std.Build, path: *const Paths, 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 (), }); + .{ .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 (), }); @@ -122,13 +122,23 @@ pub fn build (builder: *std.Build) !void .optimize = optimize, }); - const flags = [_][] const u8 - { - "-DIEEE_8087=1", "-D_GNU_SOURCE=1", - }; - toolbox.addInclude (lib, "jq"); + if (lib.rootModuleTarget ().isMinGW ()) + { + 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.linkSystemLibrary ("shlwapi"); + } + lib.linkLibC (); toolbox.addHeader (lib, path.getJqSrc (), ".", &.{ ".h", ".inc", }); @@ -137,6 +147,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", }; var it = jq_src_dir.iterate (); while (try it.next ()) |*entry| { 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", + }, }, } 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); } 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"