commit | ebcc12352005bc32c101c341aad4b30ad1a6ea4c | [log] [tgz] |
---|---|---|
author | Sam McCall <sammccall@google.com> | Fri Jul 14 11:36:44 2023 -0700 |
committer | Copybara-Service <copybara-worker@google.com> | Fri Jul 14 11:37:43 2023 -0700 |
tree | 42474ce464c6d043f37b328c7e54a80d058cfd80 | |
parent | 1bcd0133064bd5ec8c26deab300ced3e7aed7370 [diff] |
Make collectEvidence callback based, cache USR, API tweaks The callback solves a few problems: - USR computation is heavyweight, and can become the bottleneck in indexing tasks if not cached. The callback is a natural place to put this cache. - inside the heuristics, passing Decl& etc is more convenient than USR - both producing evidence (heuristics) and consuming (feeding into a mapreduce) want to process evidence one at a time, so buffering/unbuffering is pure hassle While touching these APIs, a few other random "improvements": - collectEvidence => collectEvidenceFromImplementation, because we'll have declaration evidence too - take Decl instead of FunctionDecl, we may have other impl types in the future and the caller doesn't need to know - drop ASTContext param where it can be derived from decl - only analyze function decls that actually have a body, don't go looking for one PiperOrigin-RevId: 548179699 Change-Id: I8bd44cba1e82b513beb4337688584e5049a1242a
Crubit is an experimental bidirectional bindings generator for C++ and Rust.
Please don‘t use, this is an experiment and we don’t yet know where will it take us. There will be breaking changes without warning. Unfortunately, we can't take contributions at this point.
Crubit allows for C++ code and Rust code to call each other without manually wrapping the APIs in an FFI-friendly interop layer. For example, a C++ function like this:
bool IsAbsPath(std::string_view path);
... becomes callable from Rust as if it were defined as:
pub fn IsAbsPath(path: std::string_view) -> bool {...}
Crubit automatically generates ABI-compatible bindings for structs (which can be passed both by value and by reference), functions, and methods, for a large variety of types. (Trivial types, nontrivial types, templated types, etc.)
$ apt install clang lld bazel $ git clone git@github.com:google/crubit.git $ cd crubit $ bazel build --linkopt=-fuse-ld=/usr/bin/ld.lld //rs_bindings_from_cc:rs_bindings_from_cc_impl
$ git clone https://github.com/llvm/llvm-project $ cd llvm-project $ CC=clang CXX=clang++ cmake -S llvm -B build -DLLVM_ENABLE_PROJECTS='clang' -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=install $ cmake --build build -j $ # wait... $ cmake --install build $ cd ../crubit $ LLVM_INSTALL_PATH=../llvm-project/install bazel build //rs_bindings_from_cc:rs_bindings_from_cc_impl