Skip to content

Commit

Permalink
[update #1] CI: fix it for linux and add new workflows for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
tiawl authored Oct 23, 2024
2 parents 2693578 + 8c9d2eb commit 9c86b25
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 20 deletions.
56 changes: 45 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion TODO
Original file line number Diff line number Diff line change
@@ -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
23 changes: 17 additions & 6 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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 (), });

Expand Down Expand Up @@ -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", });
Expand All @@ -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|
{
Expand Down
4 changes: 4 additions & 0 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
},
}
2 changes: 1 addition & 1 deletion examples/src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion jq/src/config_opts.inc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define JQ_CONFIG "--with-oniguruma=builtin"
#define JQ_CONFIG "--disable-docs --disable-valgrind --with-oniguruma=builtin"

0 comments on commit 9c86b25

Please sign in to comment.