From 59e7dcf3bc37cd1931f30c9453e7e839f5f26255 Mon Sep 17 00:00:00 2001 From: richerfu Date: Sun, 5 Oct 2025 09:05:25 +0800 Subject: [PATCH 1/6] Add ci to test --- .github/workflows/ci.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..8fa37de --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,31 @@ +name: Build test + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + test: + runs-on: ubuntu-latest + name: Test on ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup OpenHarmony SDK + uses: openharmony-rs/setup-ohos-sdk@v0.1 + id: setup-ohos + with: + version: '5.0.0' + + - name: Setup Zig for OpenHarmony + uses: openharmony-zig/setup-zig-ohos@v0.1.0 + id: setup-zig + + - name: Build + run: | + cd examples/basic && zig build + cd examples/init && zig build \ No newline at end of file From b41d525982c8213a6528290c903d084d1912a54e Mon Sep 17 00:00:00 2001 From: richerfu Date: Sun, 5 Oct 2025 09:08:22 +0800 Subject: [PATCH 2/6] Fix folder --- .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 8fa37de..2d6fb26 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,5 +27,5 @@ jobs: - name: Build run: | - cd examples/basic && zig build - cd examples/init && zig build \ No newline at end of file + pushd examples/basic && zig build && popd + pushd examples/init && zig build && popd \ No newline at end of file From b3e69590172665076fb5a0fab3c757294cd7c480 Mon Sep 17 00:00:00 2001 From: richerfu Date: Sun, 5 Oct 2025 09:10:05 +0800 Subject: [PATCH 3/6] Upgrade setup-ohos-sdk to 0.2 and enable cache --- .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 2d6fb26..3f7c4a9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: uses: actions/checkout@v4 - name: Setup OpenHarmony SDK - uses: openharmony-rs/setup-ohos-sdk@v0.1 + uses: openharmony-rs/setup-ohos-sdk@v0.2 id: setup-ohos with: version: '5.0.0' From 626cdd4e60299b97ed27494b2bf009dd6332a9b1 Mon Sep 17 00:00:00 2001 From: richerfu Date: Sun, 5 Oct 2025 09:17:01 +0800 Subject: [PATCH 4/6] Fix init example --- examples/init/build.zig | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/init/build.zig b/examples/init/build.zig index 9b38d3e..01e1c3c 100644 --- a/examples/init/build.zig +++ b/examples/init/build.zig @@ -11,9 +11,11 @@ pub fn build(b: *std.Build) !void { const result = try napi_build.nativeAddonBuild(b, .{ .name = "hello", - .root_source_file = b.path("./src/hello.zig"), - .target = target, - .optimize = optimize, + .root_module_options = .{ + .root_source_file = b.path("./src/hello.zig"), + .target = target, + .optimize = optimize, + }, }); if (result.arm64) |arm64| { From f9f58f9f970bf78b30052dd302a23a8082202fbc Mon Sep 17 00:00:00 2001 From: richerfu Date: Sun, 5 Oct 2025 09:19:30 +0800 Subject: [PATCH 5/6] Fix init example --- examples/init/src/hello.zig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/init/src/hello.zig b/examples/init/src/hello.zig index dfc4e02..ce237cb 100644 --- a/examples/init/src/hello.zig +++ b/examples/init/src/hello.zig @@ -3,7 +3,9 @@ const std = @import("std"); const ArrayList = std.ArrayList; const number = @import("number.zig"); -pub usingnamespace number; +pub const test_i32 = number.test_i32; +pub const test_f32 = number.test_f32; +pub const test_u32 = number.test_u32; fn fibonacci(n: f64) f64 { if (n <= 1) return n; From 016e222652133c7b585a2606fb5e66a364e8fdde Mon Sep 17 00:00:00 2001 From: richerfu Date: Sun, 5 Oct 2025 09:22:57 +0800 Subject: [PATCH 6/6] Fix init example --- examples/init/src/hello.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/init/src/hello.zig b/examples/init/src/hello.zig index ce237cb..77f2fd1 100644 --- a/examples/init/src/hello.zig +++ b/examples/init/src/hello.zig @@ -20,7 +20,7 @@ fn fibonacci_execute(_: napi.Env, data: f64) void { defer allocator.free(message); } -fn fibonacci_on_complete(_: napi.Env, _: napi.Status, data: f64) void { +fn fibonacci_on_complete(_: napi.Env, data: f64) void { const allocator = std.heap.page_allocator; const message = std.fmt.allocPrint(allocator, "Fibonacci result: {d}", .{data}) catch @panic("OOM"); defer allocator.free(message);