rust_bindgen modules which defined cpp_std with a .h file were not
correctly emitting the `-x c++` flag. This CL addresses that, and
ensures that if either cpp_std or c_std is set then the appropriate
behavior occurs no matter the file extension.
Bug: 304269101
Test: Soong tests
Change-Id: I71a8ae30ac0ed502d9d3fbf2f3039b0c56529d39
Add a new Bindgen_flag_files property to bindgen modules
that let users specify files that contain extra flags for
bindgen.
Bug: 242243245
Test: presubmit
Change-Id: I21d987c08ac417c04aaa3bfb3b75d563fc662d5b
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
This reverts commit 323dc60712.
Reason for revert: Possible cause of test instability
Bug: 170513220
Test: soong tests
Change-Id: Iee168e9fbb4210569e6cffcc23e60d111403abb8
Putting t.Parallel() in each test makes them run in parallel.
Additional t.Parallel() could be added to each subtest, although
that requires making a local copy of the loop variable for
table driven tests.
Test: m checkbuild
Change-Id: I5d9869ead441093f4d7c5757f2447385333a95a4
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
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 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
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