diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..3f7c4a9 --- /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.2 + 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: | + pushd examples/basic && zig build && popd + pushd examples/init && zig build && popd \ No newline at end of file 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| { diff --git a/examples/init/src/hello.zig b/examples/init/src/hello.zig index dfc4e02..77f2fd1 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; @@ -18,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);