Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 5 additions & 3 deletions examples/init/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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| {
Expand Down
6 changes: 4 additions & 2 deletions examples/init/src/hello.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down