• Home
  • Raw
  • Download

Lines Matching +full:cxxbridge +full:- +full:cmd

22 Create a blank Cargo project: `mkdir cxx-demo`; `cd cxx-demo`; `cargo init`.
29 ...name = "cxx-demo"
69 its size or alignment. In general, a C++ type might have a move-constructor
86 include!("cxx-demo/include/blobstore.h");
90 fn new_blobstore_client() -> UniquePtr<BlobstoreClient>;
100 [*extern "C++"*](extern-c++.md) chapter. In brief: the programmer is **not**
120 …= /bin/ld: target/debug/deps/cxx-demo-7cb7fddf3d67d880.rcgu.o: in function `cxx_demo::ffi::new_blo…
130 `include!("cxx-demo/include/blobstore.h")` above &mdash; we'll be putting the
132 crate is named something other than `cxx-demo` according to the `name` field in
133 Cargo.toml, you will need to use that name everywhere in place of `cxx-demo`
153 #include "cxx-demo/include/blobstore.h"
175 Cargo has a [build scripts] feature suitable for compiling non-Rust code.
177 We need to introduce a new build-time dependency on CXX's C++ code generator in
183 ...name = "cxx-demo"
190 [build-dependencies]
191 cxx-build = "1.0"
194 Then add a build.rs build script adjacent to Cargo.toml to run the cxx-build
206 .compile("cxx-demo");
208 println!("cargo:rerun-if-changed=src/main.rs");
209 println!("cargo:rerun-if-changed=src/blobstore.cc");
210 println!("cargo:rerun-if-changed=include/blobstore.h");
216 ***[Cargo-based builds](build/cargo.md)*** for more details about CXX's Cargo
226 .compile("cxx-demo");
230 [build scripts]: https://doc.rust-lang.org/cargo/reference/build-scripts.html
236 cxx-demo$ cargo run
237 Compiling cxx-demo v0.1.0
239 Running `target/debug/cxx-demo`
241 cxx-demo$
266 fn next_chunk(buf: &mut MultiBuf) -> &[u8];
270 include!("cxx-demo/include/blobstore.h");
274 fn new_blobstore_client() -> UniquePtr<BlobstoreClient>;
275 fn put(&self, parts: &mut MultiBuf) -> u64;
285 considered a method / non-static member function. If there is only one `type` in
302 # fn next_chunk(buf: &mut MultiBuf) -> &[u8];
306 # include!("cxx-demo/include/blobstore.h");
310 # fn new_blobstore_client() -> UniquePtr<BlobstoreClient>;
311 # fn put(&self, parts: &mut MultiBuf) -> u64;
324 pub fn next_chunk(buf: &mut MultiBuf) -> &[u8] {
360 #include "cxx-demo/include/blobstore.h"
361 #include "cxx-demo/src/main.rs.h"
399 # fn next_chunk(buf: &mut MultiBuf) -> &[u8];
403 # include!("cxx-demo/include/blobstore.h");
407 # fn new_blobstore_client() -> UniquePtr<BlobstoreClient>;
408 # fn put(&self, parts: &mut MultiBuf) -> u64;
416 # pub fn next_chunk(buf: &mut MultiBuf) -> &[u8] {
434 cxx-demo$ cargo run
435 Compiling cxx-demo v0.1.0
437 Running `target/debug/cxx-demo`
454 [cargo-expand]. Then run `cargo expand ::ffi` to macro-expand the `mod ffi`
457 [cargo-expand]: https://github.com/dtolnay/cargo-expand
460 cxx-demo$ cargo install cargo-expand
461 cxx-demo$ cargo expand ::ffi
470 target directory under *target/cxxbridge/*.
473 cxx-demo$ exa -T target/cxxbridge/
474 target/cxxbridge
475 ├── cxx-demo
477 │ ├── main.rs.cc -> ../../../debug/build/cxx-demo-11c6f678ce5c3437/out/cxxbridge/sources/cxx-de…
478 │ └── main.rs.h -> ../../../debug/build/cxx-demo-11c6f678ce5c3437/out/cxxbridge/include/cxx-dem…
480 └── cxx.h -> ~/.cargo/registry/src/github.com-1ecc6299db9ec823/cxx-1.0.0/include/cxx.h
491 cxx-demo$ cargo install cxxbridge-cmd
492 cxx-demo$ cxxbridge src/main.rs
502 boundary. Shared structs translate to a C++ aggregate-initialization compatible
522 # fn next_chunk(buf: &mut MultiBuf) -> &[u8];
527 # include!("cxx-demo/include/blobstore.h");
531 # fn new_blobstore_client() -> UniquePtr<BlobstoreClient>;
532 # fn put(&self, parts: &mut MultiBuf) -> u64;
534 fn metadata(&self, blobid: u64) -> BlobMetadata;
542 # pub fn next_chunk(buf: &mut MultiBuf) -> &[u8] {
594 #include "cxx-demo/include/blobstore.h"
595 #include "cxx-demo/src/main.rs.h"
602 // Toy implementation of an in-memory blobstore.
631 ... impl->blobs[blobid] = {std::move(contents), {}};
637 impl->blobs[blobid].tags.emplace(tag);
643 auto blob = impl->blobs.find(blobid);
644 if (blob != impl->blobs.end()) {
645 metadata.size = blob->second.data.size();
646 std::for_each(blob->second.tags.cbegin(), blob->second.tags.cend(),
658 cxx-demo$ cargo run
659 Running `target/debug/cxx-demo`