tree: 4bce19a5034383daa505b3ee817dce350ff41ca2 [path history] [tgz]
  1. test/
  2. ast_consumer.cc
  3. ast_consumer.h
  4. ast_visitor.cc
  5. ast_visitor.h
  6. ast_visitor_test.cc
  7. ffi_types.cc
  8. ffi_types.h
  9. ffi_types.rs
  10. frontend_action.cc
  11. frontend_action.h
  12. ir.cc
  13. ir.h
  14. ir.rs
  15. ir_from_cc.cc
  16. ir_from_cc.h
  17. ir_from_cc_test.rs
  18. ir_test.cc
  19. ir_testing.rs
  20. json_from_cc.cc
  21. README.md
  22. rs_bindings_from_cc.cc
  23. src_code_gen.cc
  24. src_code_gen.h
  25. src_code_gen.rs
  26. src_code_gen_test.cc
  27. token_stream_printer.rs
rs_bindings_from_cc/README.md

rs_bindings_from_cc

Disclaimer: This project is experimental, under heavy development, and should be used yet.

:rs_bindings_from_cc parses C++ headers and generates:

  • a Rust source file with bindings for the C++ API
  • a C++ source file with the implementation of the bindings

For convenience, :test_wrapper is a shell script that passes all Clang command line flags from the current Blaze C++ toolchain:

bazel run //rs_bindings_from_cc:test_wrapper -- --public_headers=hello_world.h

or:

bazel build //rs_bindings_from_cc:test_wrapper
bazel-bin/rs_bindings_from_cc/test_wrapper --public_headers=hello_world.h

Testing

Write unit tests in the language of the code they cover, and put them next to (in the same package as) the code they cover.

Put integration tests into test package as follows:

  • Write tests for the command line interface of interop tools as sh_tests.
  • Write tests verifying that interop tools and Blaze rules generate outputs that can be built and executed by C++ or Rust rules as small projects with a rust_test or cc_test on top in subpackages of test.
  • Write tests verifying that intermediate outputs created by building outputs of interop tools (for example checking that an object file produced by compiling rs_api_impl.cc file has a specific symbol defined) as small projects with a sh_test on top.