You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by xu...@apache.org on 2024/09/08 14:18:30 UTC
(opendal) branch fix-zig created (now 52e5d5a751)
This is an automated email from the ASF dual-hosted git repository.
xuanwo pushed a change to branch fix-zig
in repository https://gitbox.apache.org/repos/asf/opendal.git
at 52e5d5a751 Add docs
This branch includes the following new commits:
new aba0999157 ci(bindings/zig): Fix build and test of zig on 0.13
new 52e5d5a751 Add docs
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(opendal) 01/02: ci(bindings/zig): Fix build and test of zig on 0.13
Posted by xu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xuanwo pushed a commit to branch fix-zig
in repository https://gitbox.apache.org/repos/asf/opendal.git
commit aba0999157bb473af6ef60330a3f6cae8b2108f9
Author: Xuanwo <gi...@xuanwo.io>
AuthorDate: Sun Sep 8 22:17:44 2024 +0800
ci(bindings/zig): Fix build and test of zig on 0.13
Signed-off-by: Xuanwo <gi...@xuanwo.io>
---
.github/workflows/ci_bindings_zig.yml | 4 +--
bindings/zig/.gitignore | 1 +
bindings/zig/build.zig | 49 ++++++++++++-----------------------
bindings/zig/build.zig.zon | 9 +++++++
bindings/zig/test/bdd.zig | 12 ++++-----
5 files changed, 35 insertions(+), 40 deletions(-)
diff --git a/.github/workflows/ci_bindings_zig.yml b/.github/workflows/ci_bindings_zig.yml
index 4e3f8f42ec..7d48339ea0 100644
--- a/.github/workflows/ci_bindings_zig.yml
+++ b/.github/workflows/ci_bindings_zig.yml
@@ -22,7 +22,7 @@ on:
branches:
- main
tags:
- - '*'
+ - "*"
pull_request:
branches:
- main
@@ -47,7 +47,7 @@ jobs:
- uses: actions/checkout@v4
- uses: korandoru/setup-zig@v1
with:
- zig-version: 0.11.0
+ zig-version: 0.13.0
- name: Setup Rust toolchain
uses: ./.github/actions/setup
diff --git a/bindings/zig/.gitignore b/bindings/zig/.gitignore
index e73c965f8f..9c8ce95726 100644
--- a/bindings/zig/.gitignore
+++ b/bindings/zig/.gitignore
@@ -1,2 +1,3 @@
zig-cache/
zig-out/
+.zig-cache/
diff --git a/bindings/zig/build.zig b/bindings/zig/build.zig
index 327945de04..fc1623ddce 100644
--- a/bindings/zig/build.zig
+++ b/bindings/zig/build.zig
@@ -23,36 +23,40 @@ pub fn build(b: *std.Build) void {
// This function creates a module and adds it to the package's module set, making
// it available to other packages which depend on this one.
- _ = b.addModule("opendal", .{
- .source_file = .{
- .path = "src/opendal.zig",
- },
- .dependencies = &.{},
+ const opendal_module = b.addModule("opendal", .{
+ .root_source_file = b.path("src/opendal.zig"),
+ .target = target,
+ .optimize = optimize,
});
+ opendal_module.addIncludePath(b.path("../c/include"));
// Creates a step for building the dependent C bindings
- const libopendal_c = buildLibOpenDAL(b);
+ const libopendal_c = b.addSystemCommand(&[_][]const u8{
+ "make",
+ "-C",
+ "../c",
+ "build",
+ });
const build_libopendal_c = b.step("libopendal_c", "Build OpenDAL C bindings");
build_libopendal_c.dependOn(&libopendal_c.step);
// Creates a step for unit testing. This only builds the test executable
// but does not run it.
const unit_tests = b.addTest(.{
- .root_source_file = .{
- .path = "test/bdd.zig",
- },
+ .root_source_file = b.path("test/bdd.zig"),
.target = target,
.optimize = optimize,
});
- unit_tests.addIncludePath(.{ .path = "../c/include" });
- unit_tests.addModule("opendal", module(b));
+
+ unit_tests.addIncludePath(b.path("../c/include"));
if (optimize == .Debug) {
- unit_tests.addLibraryPath(.{ .path = "../c/target/debug" });
+ unit_tests.addLibraryPath(b.path("../c/target/debug"));
} else {
- unit_tests.addLibraryPath(.{ .path = "../c/target/release" });
+ unit_tests.addLibraryPath(b.path("../c/target/release"));
}
unit_tests.linkSystemLibrary("opendal_c");
unit_tests.linkLibCpp();
+ unit_tests.root_module.addImport("opendal", opendal_module);
// Creates a step for running unit tests.
const run_unit_tests = b.addRunArtifact(unit_tests);
@@ -60,22 +64,3 @@ pub fn build(b: *std.Build) void {
test_step.dependOn(&libopendal_c.step);
test_step.dependOn(&run_unit_tests.step);
}
-
-fn buildLibOpenDAL(b: *std.Build) *std.Build.Step.Run {
- const basedir = comptime std.fs.path.dirname(@src().file) orelse null;
- const c_bindings_dir = basedir ++ "/../c";
- return b.addSystemCommand(&[_][]const u8{
- "make",
- "-C",
- c_bindings_dir,
- "build",
- });
-}
-
-pub fn module(b: *std.Build) *std.Build.Module {
- return b.createModule(.{
- .source_file = .{
- .path = "src/opendal.zig",
- },
- });
-}
diff --git a/bindings/zig/build.zig.zon b/bindings/zig/build.zig.zon
new file mode 100644
index 0000000000..7d7ab51407
--- /dev/null
+++ b/bindings/zig/build.zig.zon
@@ -0,0 +1,9 @@
+.{
+ .name = "opendal",
+ .version = "0.0.1",
+ .paths = .{
+ "build.zig",
+ "build.zig.zon",
+ "src",
+ },
+}
diff --git a/bindings/zig/test/bdd.zig b/bindings/zig/test/bdd.zig
index 68548d1f9f..98d49525ce 100644
--- a/bindings/zig/test/bdd.zig
+++ b/bindings/zig/test/bdd.zig
@@ -35,12 +35,12 @@ test "Opendal BDD test" {
self.path = "test";
self.content = "Hello, World!";
- var options: [*c]opendal.c.opendal_operator_options = opendal.c.opendal_operator_options_new();
+ const options: [*c]opendal.c.opendal_operator_options = opendal.c.opendal_operator_options_new();
defer opendal.c.opendal_operator_options_free(options);
opendal.c.opendal_operator_options_set(options, "root", "/myroot");
// Given A new OpenDAL Blocking Operator
- var result = opendal.c.opendal_operator_new(self.scheme, options);
+ const result = opendal.c.opendal_operator_new(self.scheme, options);
testing.expectEqual(result.@"error", null) catch unreachable;
self.p = result.op;
@@ -67,14 +67,14 @@ test "Opendal BDD test" {
try testing.expectEqual(result, null);
// The blocking file "test" should exist
- var e: opendal.c.opendal_result_is_exist = opendal.c.opendal_operator_is_exist(testkit.p, testkit.path);
+ const e: opendal.c.opendal_result_is_exist = opendal.c.opendal_operator_is_exist(testkit.p, testkit.path);
try testing.expectEqual(e.@"error", null);
try testing.expect(e.is_exist);
// The blocking file "test" entry mode must be file
- var s: opendal.c.opendal_result_stat = opendal.c.opendal_operator_stat(testkit.p, testkit.path);
+ const s: opendal.c.opendal_result_stat = opendal.c.opendal_operator_stat(testkit.p, testkit.path);
try testing.expectEqual(s.@"error", null);
- var meta: [*c]opendal.c.opendal_metadata = s.meta;
+ const meta: [*c]opendal.c.opendal_metadata = s.meta;
try testing.expect(opendal.c.opendal_metadata_is_file(meta));
// The blocking file "test" content length must be 13
@@ -82,7 +82,7 @@ test "Opendal BDD test" {
defer opendal.c.opendal_metadata_free(meta);
// The blocking file "test" must have content "Hello, World!"
- var r: opendal.c.opendal_result_read = opendal.c.opendal_operator_read(testkit.p, testkit.path);
+ const r: opendal.c.opendal_result_read = opendal.c.opendal_operator_read(testkit.p, testkit.path);
defer opendal.c.opendal_bytes_free(r.data);
try testing.expect(r.@"error" == null);
try testing.expectEqual(std.mem.len(testkit.content), r.data.*.len);
(opendal) 02/02: Add docs
Posted by xu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xuanwo pushed a commit to branch fix-zig
in repository https://gitbox.apache.org/repos/asf/opendal.git
commit 52e5d5a7515efc0ba13e6ff7d4e7d8e0ba8cada3
Author: Xuanwo <gi...@xuanwo.io>
AuthorDate: Sun Sep 8 22:18:16 2024 +0800
Add docs
Signed-off-by: Xuanwo <gi...@xuanwo.io>
---
bindings/zig/README.md | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/bindings/zig/README.md b/bindings/zig/README.md
index 48fa5c1791..b049373fcd 100644
--- a/bindings/zig/README.md
+++ b/bindings/zig/README.md
@@ -8,11 +8,7 @@
To compile OpenDAL from source code, you need:
-- [Zig](https://ziglang.org/download) 0.11.0 or higher
-
-> **Note**:
->
-> 0.11.0 is not released yet. You can use master instead before the official 0.11.0 released.
+- [Zig](https://ziglang.org/download) 0.13.0 or higher
```bash
# build libopendal_c (underneath call make -C ../c)