The latest compiler roll also enabled LTO. This broke
cargo2android.py, as the test prebuit uses LTO and so cannot be linked
with code built without. We fix this by enabling it in
cargo2android.py (and ensuring it doesn't add the flag into
Android.bp).
Test: Run
Change-Id: I6c6a813ff58a9e5064752aa59b78247c4af77a26
To work with the updater, these files must have a certain prefix.
Test: Run with --help and upgrade a crate.
Change-Id: Icdc492479223865c39d6c6f10b84fe3d762f5d1d
cargo2android.py currently builds whatever cargo does, which includes
empty tests. We can filter those out by parsing the output of "cargo
test" and looking for things with no tests.
Fixes: 159039990
Test: Run on a crate with empty integration tests, one with empty unit
tests, and one with no empty tests.
Change-Id: If8b1126d82ce6c2851b90de738ea24b129b81feb
Previously we would keep the +x.y.z part, which caused errors in Soong.
See the diff between the first two patchsets in aosp/1833319 for an
example.
Test: Fix the above CL and run on a crate without a +.
Change-Id: I791c85545e67b54e2c8952428211688e7bbf580d
If you passed --no-pkg-vers to cargo2android.py, it would still
generate cargo_pkg_version with an empty string. Instead, simply
don't generate anything.
Test: Use with and without argument.
Change-Id: I544e4789312ccc3481da73c78f0f2cae2ad6619c
The existing code only adds it to things without defaults. This adds
it to the defaults module itself, which should not overlap the
existing code.
Test: Run and see new entries.
Change-Id: Iaf3d0b47193bb1f54cdc605c88c2cd68034d963a
This argument has already been deprecated, but now there should be no
more uses of it. Let's remove it and the remaining logic.
Test: Run the updater.
Change-Id: I8ab6f6fadba3b462567237d18ddc02cc4c22e62f
When generating a config file from a commandline, cargo2android.py
should not dump the --config argument, as the point of the dump is to
generate a config file to use. This would not normally matter, but it
could help in scripts.
Test: Run and do not see --config in the dumped file.
Change-Id: Idc2911ba674e67272c9cf836c89607e10ca0dddd
Image support doesn't make sense for test modules.
Bug: 178565008
Test: Generate rustc-demangle-capi
Change-Id: Ie5a1d85f9828e0c105c3a3e994b22ef7664fe1db
staticlib and cdylib crate types generally want to export header files
for use by C code. Allow the location of these headers to be provided to
c2a for inclusion in blueprint.
Bug: 178565008
Test: Generate rustc-demangle-capi
Change-Id: I0aa9acfb081ea39a7e13315bfc8029d06b8f55d3
We no longer use the --dependencies argument, but it is still used in
a number of places. Let's remove its functionality but keep the
command-line option as a no-op so we can remove the uses over time.
Test: Run on crate that uses the option.
Change-Id: I954f68faf11d1a926f0ccf070afa8332385e3671
Only run cargo metadata on the main crate, not all of its dependencies.
Pass it the --format-version argument to avoid a warning and be
future-proof.
Test: Run.
Change-Id: Icdf88bc3b633d18266772ae813fc04b529b95765
Older versions of Python's subprocess do not have capture_output, so
just get stdout directly.
Also pass the full path to cargo in case it is not on PATH.
Test: Run
Change-Id: I368e905a93b344bca6635c6ab7a60def809e88d5
If there are multiple packages present in the workspace, attempt
to determine what the current package is by checking the emitted
crate_name value against the package name. If this still fails, a new
`--no-pkg-vers` flag is added to skip this behavior.
Bug: 196803495
Test: New logic finds package if package.name is used for crate_name
Test: New flag prevents emitting the pkg version.
Change-Id: I152e94a0520f09f37622a6cec340ae35842d56ea
This parses a module's Cargo.toml file for package version number,
setting it to cargo_pkg_version. Also sets cargo_env_compat true by
default.
Bug: 171011485
Test: generated Android.bp includes cargo_env_compat, cargo_pkg_version.
Change-Id: Ibb8021633719650e2021b90806374a5d3c6a161a
Some tests load data from files. These files thus need to be copied
to the correct location on the host/device so that the tests can
access them. This adds an option to cargo2android.py so that it can
generate these data properties.
Bug: 171710847
Test: Use for a crate.
Change-Id: I14a1ad8aca4625cc5f09807d19ffd7499fcf3689
Adds flags to emit vendor_available and vendor_ramdisk_available flags
to generated modules.
Bug: 194078853
Test: Calling script with new flags generates intended properties.
Change-Id: I4f7a6870b4f210b6627054c98962f50e98bc3e03
The test blocklist was failing when multiple tests were merged into
one. To fix this, when merging tests we prefer ones that are not
blocklisted.
Fixes: 193790055
Test: Run on the previously failing crate and another.
Change-Id: I53d1179bebef824ce80ac4f977015b04a26f8607
This patch ensures that rust_defaults for tests have _tests in the
name. This can make the Android.bp file a bit more readable.
Test: Run on a crate and build it.
Change-Id: I5d034c456052b892bd01c3c041b2572bc9364692
Do not generate TEST_MAPPING when running cargo2android.py. Still accept
the command line argument so current users/wrappers continue working.
Bug: 192348260
Test: Run cargo2android.py manually on ahash
Change-Id: I1975119f8fdd3ae850649b105678dec92fa67518
You can either add the blocks to the toplevel of the file or into the
main module. The blocks are given in separate files.
Test: Use both for some crates.
Change-Id: I74204867d4e348c83c7adc2a833be166956bfb7e
This allows you to give cargo2android.py a list of test files to ignore.
Test: Use on a couple crates.
Change-Id: Id9422c496de6693029754f32d9805f1cb92d33cb
A few crates have patches that manually remove a dependency that
cargo2android.py adds. This option can allow us to remove those
patches.
Test: Use when running on a few crates.
Change-Id: Ie8337789ab232fb726ccfe361df489acfdd31b20
This allows the external_updater to understand that an error occurred.
The pre-patched version of the file will still exist.
Test: Run when a patch fails.
Change-Id: I59cc12eeaa751b5e3e2956060f58981d27875748
Currently if cargo produces an error it's not obvious how to debug it.
Add a message telling the user to look at the cargo.out file, which
has its output.
Test: Ran on crates with and without errors
Change-Id: Ib681a8e87f60467c7425aed5f7e5277a0603bcc8
This option is only intended to be temporary, so if it is used it
should not "propagate" itself by being added to the Android.bp header
or the config file.
Test: Do not see it in the header or config file.
Change-Id: Ibb18c76bdab26aa47b38ac75ea3c410ddc612856
This commit adds an --apex-available option to cargo2android.py. It
takes in multiple strings that are included in the generated block.
It also adds --min-sdk-version.
Test: Use flags.
Change-Id: I319a32fc5e8be11015ba4484b0ab1665ee457326
The command-line options to c2a are already long and will only get
longer as new arguments are added. This allows it to load them from a
config file. For simplicity of implementation, the config file
supplements the command-line arguments and uses the same format they
do, although it ideally will replace them over time.
This also adds an option to dump the current set of command-line
arguments to a config file and exit. This is intended to ease
migration over to the config file: for a given crate, we can call c2a
with its command-line arguments plus this new flag to generate the
config file and then use just that instead.
Test: Dump and load some config files.
Change-Id: I63b29dd20bcff5d5832dbd380d7c6eb273547ed0
Generating a TEST_MAPPING file uses Bazel, which can be quite slow
(multiple minutes). Add a flag to allow skipping it. This is off by
default as it ideally will only be used for debugging.
Test: Run all four configurations of --tests and this flag.
Change-Id: I08bde29ea298fcf677addd86f6d953b6695e147f
The code that preserves license blocks currently also preserves
genrules if they come before a rust_ rule, causing them to be
duplicated. Let's fix that.
Test: Upgrade some crates
Change-Id: Ie4f62cd04c2f1dd0de788db0ca5e77502fb3b4c8