Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(bindings/c): update docs for CMake replacing #5186

Merged
merged 1 commit into from
Oct 16, 2024
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
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).
Copy link
Member Author

@PragmaTwice PragmaTwice Oct 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Users don't need to manually install/build GTest by themselves now.

- (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
Loading