A downstream project has an invalid branching structure, so we can't
actually rename `libsyn` to `libsyn-legacy` like we normally would.
Instead, we must allow the legacy package to squat on the `libsyn` name
until the branching structure is fixed to unblock the upgrade to
syn-2.x.
Test: TreeHugger
Bug: 276463929
Bug: 278978404
Change-Id: If72d389dd5238299cc1b35818e0b5596b0469cb1
This adds a suffix to all dependencies, which may be useful for no_std
crates.
Bug: 279614907
Test: Ran on external/rust/crates/ciborium
Change-Id: I4d504fbfdcd079a946814dcf953b42baa0ca3563
Variant test and cargo flags were being ignored.
Bug: 279614907
Test: Ran on external/rust/crates/serde
Change-Id: I9c6cf71c8d04944cc7c532cfb53b50c2efc3e375
These allow most no_std crates to be supported without extra patches.
Bug: 279614907
Test: Ran on external/rust/crates/half
Change-Id: I1a69ff7950fb63320ef7c87d6cd45b20915df801
This is used for managing 3p crates, and the vast majority of them
should be available to both vendor and product. Enable support by
default.
Bug: 270690570
Test: Regenerate external/rust/crates/*
Change-Id: Ie5cb4b8d00de5e6ae37c5a69cb2ee0c0cc6f573a
The ring crate hasn't had a non-alpha release in over two years, and
may need to be updated to an alpha release. Modify the version regex
in cargo2android.py to recognize the alpha version as part of the
version suffix.
Test: manually run cargo2android.py in redshell
Change-Id: If48d5be339d10bc3e6651485b0038b7219403077
The cargo2android.json config file now supports the key "variants" with
a list of entries containing keys and build name suffix. Each entry
will produce a different library (or binary). Keys supplied for each
variant will overwrite any existing ones specified in the config file.
See an example of the protobuf crate on aosp/2368788.
Test: None
Change-Id: Iaca67c7f22718c27b3cb118d9794f1ff01d31c84
* Removed import of print function - we only support py3 now
* Switched from set() to a set literal
Bug: None
Test: Regenerated argh_derive
Change-Id: I78bc86ad22c747c5f6ad88e2caa5e707e1ffc381
Cargo now outputs
'unittests src/lib.rs'
where before it output
'unittests'.
Bug: 246384761
Test: Add "test": true to argh_derive, regenerate, observe same bp file
Change-Id: Ieeab83761f5fe7cff88af1ce8293818736a6bb9b
Don't fail the generation of the Android.bp file when those flags are
encountered.
Bug: 243662244
Test: Used on gdbstub, which fixed issues seen in aosp/2191020
Change-Id: I80a6ecd8df7980234552a98ddb1149dc29542ac7
Prevent the script from missing flags (minus-prefixed arguments) due to
the CLI argument being quoted (making the "-" its second character).
This removes the need to manually unquote the args in the few cases
where the code already handles them being in quotes.
Bug: 243662244
Test: -
Change-Id: I37b9aa96dcbbeb04616bddfca657d066b998d7c7
Example where it failed:
tests::sock_send_recv_event: test
1 test, 0 benchmarks
Doc-tests vm_control
0 tests, 0 benchmarks
the "1 test, 0 benchmarks" line wouldn't match the test regex, so it
would mistakenly parse the doc tests line instead and then fail to
generate a rust_test module.
Test: ran on crosvm repo
Change-Id: Id0286165405b58bf84b7261db842e272442c91e8
If the last line of a Cargo.toml was a `[*]`, then appending
`[workspace]` without newlines would result in an invalid toml file.
external/crosvm/tracing/Cargo.toml is an example.
Test: ran on crosvm
Change-Id: Ib949e7f92d0205b1bc6433d1e231924832ddb536
This reverts commit 2adbd7ed89.
Reason for revert: This doesn't work in all cases. For now I'll
instead use local patches for Cargo.toml :(
Change-Id: I0621796e694e2654a01fe9a38a307fd0a4ab8b15
`Cargo --publish` strips dev-dependencies from Cargo.toml, an issue
that won't be fixed until [1] is resolved, which doesn't seem
likely as it has been open for ~5 years now.
cargo2android needs dev-dependencies listed in Cargo.toml in order
to generate the rust_test in Android.bp, add an option that tells
cargo2android to use the cargo.toml.orig instead of the cargo.toml.
With this change there are now two options that temporarily
update Cargo.toml, so I've pulled these out into a separate class
to clean up the code a bit.
[1] https://github.com/rust-lang/cargo/issues/4242
Test: run against projects with --add_workspace and
--orig-cargo-toml
Change-Id: I3b8633a807c9734981ebde0bef9b73868acf6774
Bug: 234744235
Test: Run cargo2android.py without --cargo_bin
Test: Run in the sandbox without providing --cargo_bin
Change-Id: I4c3744e0e391ab7e4fb6a857483fde5c0015f0ff
string-typed result groups would cause the comparison to fail with a
type error. Explicitly casting results to integer for comparison, then
back to string for concatenation causes things to work again.
Bug: 234744235
Test: Run tool with no --cargo_bin option (and the following patch)
(thus using local cargo version detection) and observe success.
Change-Id: I91d8de925c1b6eca7c9905ea85e1ad90e01fb1f9
The bulk of Rust packages in external/ are OS agnostic and do not care
about individual platform features. This change is intended to reduce
the churn of repeatedly adding new `apex_available` attributes to crates
by defaulting to availability. When landing a new crate which is either
platform revision specific or has an unstable file format, prefer to
set `apex_available: ["//apex_available:platform"]` until you have
thought things through.
Bug: 174862583
Test: Regenerate with no apex_available, see universal availability
Test: Regenerate with apex_available: [], see []
Test: Regenerate with apex_available: [foo], see [foo]
Change-Id: I958597789bfc966caec043d051996284dab7a927
The prebuilt cargo (or more precisely, its libstd) cannot be used when
running cargo2android.py. Ensure that the upstream cargo binary is used.
This is automatically set when using the sandbox for Googlers. For
external contributors, raise an error if the option is not provided.
Test: As a googler, execute cargo2android.py directly; an error is
raised.
Test: As a googler, use the sandbox; cargo2android.py is executed
correctly.
Test: As an external contributor, execute cargo2android.py; an error is
raised if cargo_bin is not provided.
Bug: 217810523
Change-Id: Id42ba777b3960b13f6ef91d36eaad94df939f48e
For some unknown reason the change to merge rust_test and rust_test_host
targets caused some crosvm tests to be run (and fail) in prebsubmit which
were not previously being run, so this is necessary to work around it.
Test: Ran cargo2android.py on various crosvm crates.
Change-Id: I9b94d270148d8ce5fa97f88f460d8c03eac3873c
With b/196306316 hopefully fixed, we should be able to use a single
rust_test entry for both device and host tests. This modifies
cargo2android.py so it generates these shared tests.
Test: Run on crates with simple tests, those with defaults, host-only,
and device-only tests.
Change-Id: Icfe8d1fb26a61bc9ed65b8a7b116a4ebcd782ce4
A recent change to remove empty tests runs cargo test --list. A few
crates produce build errors this way that they did not previously do.
This currently causes cargo2android.py to produce illegal Android.bp
files for these crates even though these should not be fatal errors.
We thus detect these errors and emit them as comments in the
Android.bp file, so developers can see them but the crate can still
compile.
Test: Run on crates with and without such errors.
Change-Id: I8664d3ca9a6b4c513ce0ef35821aa64d22949fc7
cargo2android.py prints out all of its arguments to the top of the
Android.bp file (and into a config file if that option was set) as a
way of persisting them. However, we do not want to persist the
--cargo_bin directory, as this is a proprety of the local setup and
not the crate itself. Thus ensure we don't print this.
Test: Run with argument.
Change-Id: If5292d1d740b08755ba6d31654239e93232fdc49
This reverts commit 4f4ac2f8f3.
This did not work for all crates (specifically, those with build.rs,
as they don't get passed RUSTFLAGS, as well as proc-macros, since they
get the flag but can't use LTO), so we're using a different approach
where this is not desired.
Test: Run script
Change-Id: Ib1a86d4822f51978cd8ec15ad657eb25c84e01a4
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