Skip to content

Comments

feat(bindings/cpp): init cpp binding#2980

Merged
Xuanwo merged 3 commits intomainfrom
cpp-binding
Aug 31, 2023
Merged

feat(bindings/cpp): init cpp binding#2980
Xuanwo merged 3 commits intomainfrom
cpp-binding

Conversation

@silver-ymz
Copy link
Member

A demo for cpp binding

We use cxx to interop between Rust and C++.

About build system, rust side still use cargo. For better integration with google test, we use cmake and ninja to build c++ code. All build scripts are written in cmake, so ninja can be replaced by make or bazel. I choose it just because it looks like faster.

Example

#include "opendal.hpp"
#include <vector>

int main() {
    auto op = opendal::Operator("memory");
    std::vector<uint8_t> data = {1, 2, 3, 4, 5};
    op.write("test", data);
    auto result = op.read("test");  // result == data
}

Exist Problem

Now I can only build static library, failed to build dynamic library.

@silver-ymz silver-ymz changed the title Cpp binding feat(bindings/cpp): init cpp binding Aug 30, 2023
@github-actions github-actions bot added the releases-note/feat The PR implements a new feature or has a title that begins with "feat" label Aug 30, 2023
Copy link
Member

@Xuanwo Xuanwo left a comment

Choose a reason for hiding this comment

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

Mostly LGTM!

Signed-off-by: silver-ymz <[email protected]>
Copy link
Member

@Xuanwo Xuanwo left a comment

Choose a reason for hiding this comment

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

Let's move!

@Xuanwo Xuanwo merged commit 149edd5 into main Aug 31, 2023
@Xuanwo Xuanwo deleted the cpp-binding branch August 31, 2023 01:55
This was referenced Aug 31, 2023
@XinyuZeng
Copy link

Hi, I was wondering why at the beginning you guys did not wrap the C++ binding using the exising C binding? I guess it is more likely because of safety and ergonomics benefit of cxx, but having separate C and C++ bindings on the other hand may introduce code duplication and has less control over the code. We are discussing similar issues here: vortex-data/vortex#3720 Would be really helpful if you can provide some lessons/insights. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

releases-note/feat The PR implements a new feature or has a title that begins with "feat"

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants