Skip to content

Commit

Permalink
docs(bindings/c): update docs for CMake replacing (#5186)
Browse files Browse the repository at this point in the history
  • Loading branch information
PragmaTwice authored Oct 16, 2024
1 parent 9d0f715 commit 9f5f3ce
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 26 deletions.
4 changes: 2 additions & 2 deletions bindings/c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CARGO_DIST_DIR "${PROJECT_SOURCE_DIR}/target/release")
endif()

set(OPENDAL_STATIC_LIB "${CARGO_DIST_DIR}/libopendal_c.a")
set(OPENDAL_SHARED_LIB "${CARGO_DIST_DIR}/libopendal_c.so")
set(OPENDAL_STATIC_LIB "${CARGO_DIST_DIR}/libopendal_c${CMAKE_STATIC_LIBRARY_SUFFIX}")
set(OPENDAL_SHARED_LIB "${CARGO_DIST_DIR}/libopendal_c${CMAKE_SHARED_LIBRARY_SUFFIX}")
message(NOTICE "-- OpenDAL C static lib: ${OPENDAL_STATIC_LIB}")
message(NOTICE "-- OpenDAL C shared lib: ${OPENDAL_SHARED_LIB}")

Expand Down
12 changes: 8 additions & 4 deletions bindings/c/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The fastest way is:

To build OpenDAL C binding, the following is all you need:

- **A C++ compiler** that supports **c++14**, _e.g._ clang++ and g++
- A compiler that supports **C11** and **C++14**, _e.g._ clang and gcc

- To format the code, you need to install **clang-format**

Expand Down Expand Up @@ -55,7 +55,9 @@ sudo ln -s /usr/lib/libgtest_main.a /usr/local/lib/libgtest_main.a
To build the library and header file.

```shell
make build
mkdir build && cd build
cmake ..
make
```

- The header file `opendal.h` is under `./include`
Expand All @@ -64,15 +66,17 @@ make build
To clean the build results.

```shell
make clean
cargo clean
cd build && make clean
```

## Test

To build and run the tests. (Note that you need to install GTest)

```shell
make test
cd build
make tests && ./tests
```

## Documentation
Expand Down
31 changes: 11 additions & 20 deletions bindings/c/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ int main()
};

/* Write this into path "/testpath" */
opendal_error *error = opendal_operator_write(op, "/testpath", data);
opendal_error *error = opendal_operator_write(op, "/testpath", &data);
assert(error == NULL);

/* We can read it out, make sure the data is the same */
Expand Down Expand Up @@ -56,14 +56,13 @@ For more examples, please refer to `./examples`

To build OpenDAL C binding, the following is all you need:

- **A C++ compiler** that supports **c++14**, _e.g._ clang++ and g++
- A compiler that supports **C11** and **C++14**, _e.g._ clang and gcc

- To format the code, you need to install **clang-format**

- The `opendal.h` is not formatted by hands when you contribute, please do not format the file. **Use `make format` only.**
- If your contribution is related to the files under `./tests`, you may format it before submitting your pull request. But notice that different versions of `clang-format` may format the files differently.

- **GTest(Google Test)** need to be installed to build the BDD (Behavior Driven Development) tests. To see how to build, check [here](https://github.com/google/googletest).
- (optional) **Doxygen** need to be installed to generate documentations.

For Ubuntu and Debian:
Expand All @@ -83,27 +82,16 @@ sudo apt-get install cmake

# install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

# If you run the tests, install additional components

# install Valgrind
sudo apt-get install Valgrind

# install GTest
cd /usr/src/gtest
sudo cmake CMakeLists.txt
sudo make
sudo cp lib/*.a /usr/lib
sudo ln -s /usr/lib/libgtest.a /usr/local/lib/libgtest.a
sudo ln -s /usr/lib/libgtest_main.a /usr/local/lib/libgtest_main.a
```

## Makefile

- To **build the library and header file**.

```sh
make build
mkdir build && cd build
cmake ..
make
```

- The header file `opendal.h` is under `./include`
Expand All @@ -113,19 +101,22 @@ sudo ln -s /usr/lib/libgtest_main.a /usr/local/lib/libgtest_main.a
- To **clean** the build results.

```sh
make clean
cargo clean
cd build && make clean
```

- To build and run the **tests**. (Note that you need to install Valgrind and GTest)

```sh
make test
cd build
make tests && ./tests
```

- To build the **examples**

```sh
make examples
cd build
make basic error_handle
```

## Documentation
Expand Down

0 comments on commit 9f5f3ce

Please sign in to comment.