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 92e0aefe docs: add dev dependency section (#2021)
92e0aefe is described below

commit 92e0aefe0f7eceae11a6f45c6b8088764c5c780c
Author: Lei, HUANG <[email protected]>
AuthorDate: Mon Apr 17 22:37:33 2023 +0800

    docs: add dev dependency section (#2021)
    
    * doc: add dev dependency section
    
    * doc: move build section to bindings/c
---
 bindings/c/README.md |  4 ++++
 bindings/c/build.rs  | 11 +++++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/bindings/c/README.md b/bindings/c/README.md
index fbe7c554..0096ac69 100644
--- a/bindings/c/README.md
+++ b/bindings/c/README.md
@@ -2,6 +2,10 @@
 
 # Build C bindings
 
+To compile OpenDAL from source code, you'll need:
+- C/C++ Toolchain: provides basic tools for compiling and linking OpenDAL C 
binding. This is available as `build-essential` on Ubuntu and similar names on 
other platforms.
+- `clang-format`: OpenDAL uses clang-format to keep C binding code base clean.
+
 ```bash
 make
 make format
diff --git a/bindings/c/build.rs b/bindings/c/build.rs
index e5b01158..c82ba643 100644
--- a/bindings/c/build.rs
+++ b/bindings/c/build.rs
@@ -17,6 +17,7 @@
 
 extern crate cbindgen;
 
+use std::io::ErrorKind;
 use std::{path::Path, process::Command};
 
 fn main() {
@@ -26,11 +27,17 @@ fn main() {
         .expect("Unable to generate bindings")
         .write_to_file(header_file);
 
-    Command::new("clang-format")
+    if let Err(e) = Command::new("clang-format")
         .arg("--style=WebKit")
         .arg("--verbose")
         .arg("-i")
         .arg("include/opendal.h")
         .spawn()
-        .expect("clang-format must succeed");
+    {
+        if e.kind() == ErrorKind::NotFound {
+            panic!("\x1b[31mclang-format\x1b[0m not found, please install it 
through package manager first");
+        } else {
+            panic!("Failed to run build.rs: {}", e)
+        }
+    }
 }

Reply via email to