Commit graph

13 commits

Author SHA1 Message Date
Matthew Maurer
b983c8971b Revert "rust: Only allow bindgen to produce rlibs."
This reverts commit 53a452d1ff.

Reason for revert: Broken build

Change-Id: I4c1c6f2166c3729ef1916ad7c21e32599c5e692f
2022-08-01 21:59:00 +00:00
Matthew Maurer
53a452d1ff rust: Only allow bindgen to produce rlibs.
Generated bindings are intended to be slim translation layers, usually
consisting of nothing more than type signatures and constants.
Generally, they should also be used in exactly one location by the safe
wrapper for these bindings. By preventing them from building as
`dylib`s, we avoid the per-library overhead of these non-reused pieces
of code.

Additionally, default visibility restrict all bindgen modules to their
subpackages. This is being done both:
* to encourage use of a single safe bindings crate
* to avoid diamond dependency graphs with mixed rlib/dylib dependencies

Bug: 166332519
Test: m; Make sample module use dylib bindgen dependency, see build failure.
Change-Id: I8e9d9cb851c2ec99f4ed63e6e18c4ba26b29721c
2022-08-01 16:28:51 +00:00
David Duarte
b6be48d6c9 rust: Support protobuf wrappers well known types
Test: m nothing

Change-Id: I271474f59745670cbba98704182d0966eae6b0ee
2022-01-04 08:52:45 +00:00
Ivan Lozano
6eff900b67 Merge rust_protobuf and rust_grpcio module types.
To allow grpc protobufs to include non-grpc protos in a singular
library, we need to allow them to be defined as part of the same module.

This CL merges the two previously distinct module types into
rust_protobuf, and adds a new property for declaring which protos
contain grpc definitions.

Bug: 172952239
Test: rust_grpcio modules converted to rust_protobuf modules and build.
Test: Example rust_protobuf module with both proto types builds.
Change-Id: I0e627fd97bc6f74de89d309e3344694a1e76586d
2020-12-11 16:19:02 -05:00
Ivan Lozano
9d74a52706 Rust: WriteFileRule instead of printf for protos
Use WriteFileRule instead of a rule that calls printf for generating the
module source file for rust_protobuf.

Bug: 171361369
Test: rust_protobuf modules compile
Change-Id: Ie83a30e19d7d09875f3d209662526783862d8ea0
2020-12-10 15:35:05 -05:00
Colin Cross
f1a035e6be Pass pctx and ctx to NewRuleBuilder
Enable the RuleBuilder and RuleBuilderCommand methods to access
the BuilderContext by passing it to NewRuleBuilder instead of
RuleBuilder.Build.

Test: genrule_test.go
Test: rule_builder_test.go
Test: m checkbuild
Change-Id: I63e6597e19167393876dc2259d6f521363b7dabc
2020-12-01 16:22:16 -08:00
Ivan Lozano
57f434e858 rust: Add support for multiple protos per module.
This further emulates the rust-protobuf gen_mod_rs flag by providing
support for generating a single module containing multiple protobuf
definitions.

Bug: 171361369
Test: New Soong tests.
Test: Example module containing multiple protos works.
Change-Id: I815f9628a8289ae512758073dac49bc4535abf01
2020-11-30 14:55:00 +00:00
Ivan Lozano
9b44383788 rust: Add header library support to rust_bindgen.
Allow rust_bindgen modules to define dependencies that only provide
headers and may not necessarily need to be linked in.

Bug: 161141999
Test: Soong tests pass.
Test: Example module has appropriate include flags when compiling.
Change-Id: Ic9ce8b1204008ad8dcb18766c914e48bb292d485
2020-11-17 13:40:50 -05:00
Zach Johnson
3df4e6364b rust_grpcio well known types support, default deps
The usage of the well known type Empty requires a hack in the module
above the grpc implementation, this is now the generated stem_mod.rs

This also adds additional implicit dependencies that are required by
the grpc protobuf generated code. This includes the addition of a
'header_libs' property for library dependencies which export include
paths required by protos.

We also now include both the protos and the grpcio in the library
variant via the mod_stem.rs.

Bug: 172592789
Bug: 171504899
Test: m nothing
Test: Example rust_grpcio module build command includes dependencies,
      include paths.
Change-Id: I187a13cd5cdea991828a1020314de16727e4f74e
2020-11-11 12:09:26 -08:00
Matthew Maurer
5819e58fdc rust: Fix GRPC generator invocation
When using the grpc generator, the plugin expects to also have access to
the protobuf generator. This patch ensures that aprotoc will use the
Soong copy of the protobuf generator, rather than trying to use a
locally installed version from PATH.

Test: m nothing
Change-Id: I26da4d18c97017da7d8cd9515a07a2b7b2575342
2020-11-06 01:40:41 +00:00
Ivan Lozano
6a3d1e9831 Add rust_grpcio module type.
Adds a new SourceProvider type to generate grpcio code from protos.
Since it's so similar to protobuf, it's basically just a different type
of rust_protobuf.

Bug: 171504899
Test: Example module compiles.
Change-Id: I9882f3ac4d4aeaae0191f2b557e9612b5c7a9ac9
2020-11-05 08:53:52 -05:00
Chih-Hung Hsieh
c49649c059 Use protobuf-codegen default and add mod_stem.rs
* Upgrade to new protobuf-codegen; use its standard
  default output without local change.
* Allow a sourceProvider to have multiple output files.
  For a stem.proto file, output stem.rs and mod_stem.rs.
* New protobuf-codegen option gen_mod_rs always generates
  output file named "mod.rs". To generate multiple .proto
  files into the same output directory, we need to rename
  mod.rs to mod_<stem>.rs.
* Instead of using the gen_mod_rs option and renaming mod.rs
  to mod_<stem>.rs, we generate the same mod_<stem>.rs
  directly with a simple printf command.

Bug: 170256643
Test: atest -c --host --include-subdirs external/crosvm
Change-Id: Ia09e41029099a6de4d35c96dbabd9ba5514c9019
2020-10-09 13:38:37 -07:00
Treehugger Robot
588aae727b Add rust_protobuf module.
This adds a new SourceProvider module type to handle protobuf code
generation. See the new test for an example of how to call this.

Bug: 143953733
Test: New soong tests pass.
Test: Replacing genrules in crosvm with rust_protobuf modules.
Change-Id: Ie3117129cde37b8736bc18ee09bf5cde27c01c34
2020-08-31 14:05:39 -04:00