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 2023/03/29 14:55:03 UTC
[incubator-opendal] branch main updated: binding/c: build: add build.rs and cbindgen as dep to gen header (#1793)
This is an automated email from the ASF dual-hosted git repository.
xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git
The following commit(s) were added to refs/heads/main by this push:
new 3ac7f07f binding/c: build: add build.rs and cbindgen as dep to gen header (#1793)
3ac7f07f is described below
commit 3ac7f07fd4f85b757be5552270fec2af7cf900cc
Author: Wei Zhang <kw...@gmail.com>
AuthorDate: Wed Mar 29 22:54:57 2023 +0800
binding/c: build: add build.rs and cbindgen as dep to gen header (#1793)
Signed-off-by: Wei Zhang <kw...@gmail.com>
---
Cargo.lock | 36 ++++++++++++++++++++++++++++++++++--
bindings/c/Cargo.toml | 3 +++
bindings/c/build.rs | 28 ++++++++++++++++++++++++++++
3 files changed, 65 insertions(+), 2 deletions(-)
diff --git a/Cargo.lock b/Cargo.lock
index 255bb5d2..2a92f442 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -442,6 +442,25 @@ version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5"
+[[package]]
+name = "cbindgen"
+version = "0.24.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a6358dedf60f4d9b8db43ad187391afe959746101346fe51bb978126bec61dfb"
+dependencies = [
+ "clap 3.2.23",
+ "heck",
+ "indexmap",
+ "log",
+ "proc-macro2",
+ "quote",
+ "serde",
+ "serde_json",
+ "syn 1.0.109",
+ "tempfile",
+ "toml 0.5.11",
+]
+
[[package]]
name = "cc"
version = "1.0.79"
@@ -531,9 +550,12 @@ version = "3.2.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71655c45cb9845d3270c9d6df84ebe72b4dad3c2ba3f7023ad47c144e4e473a5"
dependencies = [
+ "atty",
"bitflags 1.3.2",
"clap_lex 0.2.4",
"indexmap",
+ "strsim",
+ "termcolor",
"textwrap",
]
@@ -2173,7 +2195,7 @@ dependencies = [
"predicates 2.1.5",
"serde",
"tokio",
- "toml",
+ "toml 0.7.3",
"url",
]
@@ -2252,6 +2274,7 @@ dependencies = [
name = "opendal-c"
version = "0.1.0"
dependencies = [
+ "cbindgen",
"opendal",
]
@@ -2746,7 +2769,7 @@ dependencies = [
"indoc",
"libc",
"memoffset",
- "parking_lot 0.11.2",
+ "parking_lot 0.12.1",
"pyo3-build-config",
"pyo3-ffi",
"pyo3-macros",
@@ -3890,6 +3913,15 @@ dependencies = [
"tracing",
]
+[[package]]
+name = "toml"
+version = "0.5.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234"
+dependencies = [
+ "serde",
+]
+
[[package]]
name = "toml"
version = "0.7.3"
diff --git a/bindings/c/Cargo.toml b/bindings/c/Cargo.toml
index fdb3f80c..d5e30e87 100644
--- a/bindings/c/Cargo.toml
+++ b/bindings/c/Cargo.toml
@@ -29,5 +29,8 @@ version = "0.1.0"
crate-type = ["cdylib"]
doc = false
+[build-dependencies]
+cbindgen = "0.24.0"
+
[dependencies]
opendal = { version = "0.30", path = "../../core" }
diff --git a/bindings/c/build.rs b/bindings/c/build.rs
new file mode 100644
index 00000000..47b27812
--- /dev/null
+++ b/bindings/c/build.rs
@@ -0,0 +1,28 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+extern crate cbindgen;
+
+use std::path::Path;
+
+fn main() {
+ let header_file = Path::new("include").join("opendal.h");
+
+ cbindgen::generate(".")
+ .expect("Unable to generate bindings")
+ .write_to_file(header_file);
+}