This is useful when experimenting with new compiler flags that the
existing compiler does not support.
Change-Id: I45b8a2980b247d60a7f4e2ba55169267aeceef2b
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
If -x c++ is passed through a modules cflags, it will be overridden by a
-x c and -std flag added by the build system if the extension is not
.hpp/.hh and cpp_std is not set. This leads to confusing behavior.
Instead, add a helpful error message to guide developers towards the
correct way to specify when a header is a C++ header and which std
version should be used.
Bug: 171011490
Test: m nothing
Change-Id: I7e7cba504798d47ce1c753ba8699d7475a95095b
* 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
Adds the "static_executable" property to rust_binary modules which
allows for building fully static executables. This only impacts bionic
targets.
Bug: 169434439
Test: rust_binary module with static_executable true builds, runs on
device.
Change-Id: I83c19fddd070859b7e56d248237cfd73e1768519
rust_bindgen modules can't inherit properties in cc_defaults that would
be useful for generating bindings (such as cflags). This CL moves these
common properties out into a new struct in cc and adds that struct to
cc_default.
Additionally, Cppflags is added to rust_bindgen to make sure that these
get picked up as well from cc_defaults.
Bug: 163598610
Test: rust_bindgen module uses cflags in cc_defaults.
Test: New Soong test passes
Change-Id: I702442a355244dc01954083f98a2eebbcea12e47
Until now, source provider modules duplicated the rule to generate the
source for each variant. Add a inter-variant dependency between the
source and the other variants (e.g. rlib, dylib) to avoid this
duplication. Add documentation on this behaviour.
Bug: 162588681
Test: m
Change-Id: I41c9e2220f8875245415e17374852e540dfd47ec
Adds the c_std and cpp_std properties to rust_bindgen, and use the
default values from cc if these are undefined.
This assumes by default that the header extension indicates whether
the header is a C or C++ header file. This default can be overridden
by setting either c_std or cpp_std.
Test: Soong tests pass, "-std=" arg included in bindgen calls
Bug: 163580541
Change-Id: I5b0d3b8eae9a54dd91d8a0aca583d7803a344f27
The LIBCLANG_PATH provided to bindgen should point to the directory
containing libclang, not the file itself.
Bug: 167977778
Test: m profcollectd
Change-Id: Iabd9970a763c192249b401a618a2d6990b02eab0
rust_bindgen implicits currently include dependency-exported include
directories. This is incorrect, and causes issues when the include
directory is a generated directory.
Instead, remove the dependency-exported include directories from the
implicits list, and also add dependency-exported headers to the
implicits to handle these correctly.
Bug: 166779501
Test: Rust projects continue to build, test-case no longer failing.
Change-Id: Ia2da25de9e712b7306f19603dc9d14de6bac3fb3
The cc toolchain information is required when using cc.Stripper.
Move to a Module method to avoid importing the cc package everywhere.
Test: m nothing
Bug: 153430439
Change-Id: I497dcdff4e767ecb8b8688c73cf88850c302683d
The AIDL compiler now uses SourceProvider to compiler the generated Rust
code from system/tools/aidl/build/aidl_interface.go using its own
SourceProvider object, which needs access to baseSourceProvider and all
methods of SourceProvider.
Test: mmma system/tools/aidl with 1357705 applied
Change-Id: I226609a7fccca2e7e1bfbad5d69d1821d37e43a1
In some cases customized logic is required to generate the expected
bindgen bindings. This adds support for rust_bindgen modules to define a
HostTool module to use instead of bindgen.
Bug: 161816141
Test: New Soong tests pass.
Test: Local test case shows custom_binary module being used for bindgen
generation.
Change-Id: Id52aec4f25c38206d7e585d8e662be7836aa1d4b
bindgen generated code may not pass clippy checks, so preemptively
disable clippy for these.
Bug: 162828070
Test: clippy is not called when compiling rust_bindgen library variants.
Change-Id: I9632c889417bdfd1adf96d9cfbccbe6340824205
Bindgen generated bindings will not pass lints, so we need to disable
them when building bindings crates.
Test: m libbinder_ndk_bindgen
Change-Id: I4536f15f8505ff8d5436f1e6cbc2035e6801276d
Bindgen flags and cflags should be escaped, as they may contain shell
globs or other special characters.
Test: Updated Soong test passes.
Change-Id: I3df8ef25391f53a191f0494c5ff8c641d4d4b6f8
This allows SourceProvider modules to create rust_library variants so
that generated source can be referenced as an external crate rather than
via an include macro. This is done by including rust_bindgen modules
like any other library, as a dependency in either rlibs, dylibs, or
rustlibs.
This renames the stem and flags properties for rust_bindgen modules to
source_stem and bindgen_flags, respectively. This deconflicts with the
usage in baseCompiler.
This also removes 'subName' from the Module struct and moves it over to
SourceProvider, which was the only user. This allows us to set it in
baseSourceProvider's AndroidMk; setting it in Module's AndroidMk was
causing problems finding NOTICE files for bindgen library variants.
Bug: 159064919
Test: New Soong tests pass.
Test: Local test rust_binary can use rust_bindgen module as a crate.
Change-Id: Ieb2cb614c2dd0b5aa7120541d77f6f822a6a1806
rust_bindgen was not hermetic previously as it would pull in host
headers for device targets. This fixes that by using the same flags we
use when compiling with Clang. This also makes sure our rust_bindgen
headers are built as similar as possible to their respective
cc_libraries.
This also pulls in the bionic dependencies as well, which provide the
headers required for device targets.
Bug: 162007475
Test: device rust_bindgen deps file does not reference host headers.
Change-Id: I4efdf333e011a6c6d73a0345e5485823f166d17a
This makes debugging easier when the bindings contain errors.
Bug: 161730753
Test: Generated bindings are formatted.
Change-Id: Ic46f69d8b6d07b4dc6912b7f02d7427ea6c11cde
Add SourceProvider modules which provides a base interface for more
complex code generation usecases such as bindgen. Also adds the
rust_bindgen module type which calls bindgen to generate Rust FFI
bindings to C.
Bug: 159064919
Test: Local test module generates bindings.
Test: New Soong tests pass.
Change-Id: Ie31467bbbe423497666ad837cf5fe1acd1e76bd8