Commit Graph

579 Commits

Author SHA1 Message Date
Sim Sun
ecff5ddc84 c2a: Support customizing rustc
The current cargo2android.py doesn't work well w/ `--cargo_bin`. It would use the full path rustc(/<HOME>/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rustc) instead of basename(`rustc`). The `RUSTC_PAT` and `RUSTC_VV_CMD_ARGS` regex doesn't match the full path.

This CL uses `(.*\/)?` to match the path if it exists.

Change-Id: If5e4060410c1cd45ad6c9612ebe856552aa14d08
2023-06-21 14:08:38 -07:00
Samuel Holland
c434deca4e Support gdbclient.py on riscv64
Add the path to the existing architecture-specific runtime directory,
in preparation for when lldb-server is added to the toolchain build by
Iba7efaa62e7d3cc8e3bd1080d9b4a67bc241faf2.

Test: `gdbclient.py -r surfaceflinger` connected to a riscv64 board
Change-Id: I1654378a7ba92fcd7ffe478d2b491f426655e6f1
2023-06-16 09:48:11 -07:00
Andrew Walbran
90bfd75d6b Support Python 3.8.10.
Redshell unfortunately uses this old version, while the union operator
for dictionaries was only added in Python 3.9.

Test: Ran cargo2android.py on a crate with variants
Change-Id: I7a875acde11c23a3b789ef384f3ab32100d7c6d5
2023-06-13 13:06:26 +00:00
Nikita Putikhin
9aa3bc65ba Add --vscode-launch-props to gdbclient.py
The new argument allows the user to pass a JSON of properties to merge
into the generated launch.json config when setting up vscode-lldb
forwarding. This way the user can add pre-build tasks, extra init
commands etc.

Test: atest gdbclient_test
Test: lldbclient.py --setup-forwarding=vscode-lldb
  --vscode-launch-props='{"sourceMap": {"test1": "test2"},
  "postDebugTask": "Stop LLDB client", "processCreateCommands" :
  ["test"]}' -r test
Change-Id: I763dd15dde10421e86bc0a6ddfde974156ef1588
2023-06-10 20:47:31 +00:00
Nikita Putikhin
516960e34e Add type annotations to gdbclient.py
In a couple cases it exposed unused arguments or type errors. This
change fixes those as well.

Test: mypy development/scripts/gdbclient.py
Test: gdbclient -r /system/bin/date
Change-Id: If471a1853b813e01c89e321eab3d424f1c256f2d
2023-05-31 21:57:38 +00:00
Andrew Walbran
59f441224e Add --dependency-suffix flag.
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
2023-05-12 16:47:19 +00:00
Andrew Walbran
aff9481608 Fix handling of tests for variants.
Variant test and cargo flags were being ignored.

Bug: 279614907
Test: Ran on external/rust/crates/serde
Change-Id: I9c6cf71c8d04944cc7c532cfb53b50c2efc3e375
2023-05-12 13:24:37 +00:00
Andrew Walbran
d579a0fa61 Added --no-std and --alloc flags.
These allow most no_std crates to be supported without extra patches.

Bug: 279614907
Test: Ran on external/rust/crates/half
Change-Id: I1a69ff7950fb63320ef7c87d6cd45b20915df801
2023-05-12 13:22:55 +00:00
Peter Collingbourne
462ff76c54 Merge "gdbclient.py: Fix gdb-remote command for non-local $ANDROID_SERIAL." 2023-03-16 00:27:43 +00:00
Peter Collingbourne
b6b58a4d82 gdbclient.py: Fix gdb-remote command for non-local $ANDROID_SERIAL.
As it turns out, gdbclient.py is broken when connecting to a host:port
$ANDROID_SERIAL where the host is something other than localhost,
because it will try to connect to a TCP socket on the host named in
$ANDROID_SERIAL, while lldb-server is not even set up to listen on a TCP
socket on the device (it listens on a Unix socket which gets forwarded
by adb forward to localhost).

Fix it by entirely removing the code that tries to connect directly to
the host if the $ANDROID_SERIAL is of the form host:port.

Change-Id: I91a04aa811b246c9cac82ef3b0779dc284364edf
2023-03-15 14:31:40 -07:00
Christopher Ferris
a47d6d090f Add missing changes from ARCH removal.
I somehow didn't upload these fixes from the review. So doing that
now.

Test: Unit tests pass.
Change-Id: Ia17e480eb972db4f7be6947c0e6567632c65431f
2023-03-13 15:22:47 -07:00
Christopher Ferris
f62a3be63d Remove all ARCH references.
Replaced with ARCH_IS_32BIT since that's the only thing truly
necessary to work.

This also makes the register regex much more lenient, but it appears
to be strict enough that it doesn't seem to capture arbitrary lines
when run through logcat.

Removed the StripPC function and verified that an arm crash that
ends in 1 still works.

Removed the architecture.py script, it is old and I don't see anyone
using it.

Modify the reading of the lines to ignore any errors in the input.

Test: All unit tests pass.
Test: Symbolized arm and arm64 tombstones
Test: Symbolized x86 and x86_64 tombstones
Test: Ran through a logcat and verified it caught the bug but
Test: didn't print any extra information.
Change-Id: I6a65ecaad68da1d56864db32ff434512e4df0d89
2023-03-09 18:44:59 -08:00
Treehugger Robot
098584724b Merge "Upgrade the 'aday' script to python3." 2023-03-09 21:59:13 +00:00
xutianqi
5b4577977a Upgrade the 'aday' script to python3.
Test: Ran with a BUILD_NUMBER as parameter.

Change-Id: I1048cc8bcb6565e14be00563da565eb3b8ce7989
Signed-off-by: xutianqi <xutianqi@xiaomi.corp-partner.google.com>
2023-03-09 11:08:36 +00:00
Elliott Hughes
c94cb65f21 Remove mips.
We aren't going to support riscv32, so we won't even need to reuse any
of this.

Test: treehugger
Change-Id: I80d6285ecbd0dfdeeb496be39ba63e06cbb30acd
2023-03-09 00:36:31 +00:00
Prashanth Swaminathan
01fd4185b1 Support riscv64 in stack tool, remove mips64
Test: atest python-stack_core_test
Test: Manual validation against a crash stack on aosp_riscv64.
Change-Id: Ifc3646486fda9120c30c987f9623e134d3491a9a
2023-03-08 13:21:47 -08:00
Matthew Maurer
4b869316ee cargo2android.py: Default to vendor + product
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
2023-03-06 22:55:36 +00:00
Treehugger Robot
66f9ab6962 Merge "Extend cargo2android.py version matching to include alpha and beta crates" 2023-02-03 22:01:40 +00:00
Colin Cross
602c2483a5 Extend cargo2android.py version matching to include alpha and beta crates
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
2023-02-03 12:39:51 -08:00
Jeff Vander Stoep
b06dd5c7e2 c2a: make Rust version matchin regex less exact
Allow custom version like 1.65.0.p1 (added in aosp/2404317).

Resolves warning:
WARNING: cannot find RustDefaultVersion in
development/scripts/../../build/soong/rust/config/global.go
Change-Id: I6fced7695473e025b0f739f9986df932d2c3f5fe

Test: cargo2android.py --config cargo2android.py
no warning

Change-Id: I43ff81f061477fc0322f27fef1c950954130dbc6
2023-02-01 14:23:40 +01:00
Jeffrey Vander Stoep
6e50b8e094 Merge "Include non-local tests by path" 2023-02-01 07:42:21 +00:00
Jeff Vander Stoep
408e5db8d9 Include non-local tests by path
Import paths for non-local tests because including tests
directly has proven to be fragile and burdensome. For example,
whenever a project removes or renames a test, all the TEST_MAPPING
files for its reverse dependencies must be updated or we get test
breakages. That can be many tens of projects that must updated to
prevent the reported breakage of tests that no longer exist.
Similarly when a test is added, it won't be run when the reverse
dependencies change unless/until update_crate_tests.py is run for its
depenencies. Importing TEST_MAPPING files instead of tests solves
both of these problems. When tests are removed, renamed, or added,
only files local to the project need to be modified. The downside is
that we potentially miss some tests. But this seems like a reasonable
tradeoff since it's primarily unit tests that are missing, and all
unit tests are always run on the host for every presubmit.

See aosp/2400500 as an example of what test mapping files now
look like after this change.

Test: run it over all projects in external/rust/crates
Change-Id: I2b644f9ebf97968c9928f5b1756b2ab199e8e7ca
2023-01-30 13:10:25 +01:00
Chris Wailes
13b1ca483d Add a rename mapping for libatomic to libatomic_rust
Bug: 229895468
Test: cargo2andoid.py --config cargo2android.json
Change-Id: Icf542d1398f9cd378bba845445b2dab34bb0b317
2023-01-24 16:31:14 -08:00
Shuo Wang Hsu
be3f0d9d11 Support building crate variants.
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
2022-12-28 15:39:42 -08:00
Treehugger Robot
af6aef5d2b Merge "update_crate_tests.py: update location of bazel binary" 2022-12-13 16:22:35 +00:00
Jeff Vander Stoep
2f3afc25d5 update_crate_tests.py: update location of bazel binary
The binary for bazel moved from tools/bazel to build/bazel/bin/bazel.

Test: run update_crate_tests.py in a Rust crate. Verify results.
Change-Id: I2e586b59876bfd7146cd92efc90055828bf60eac
2022-12-13 15:43:05 +01:00
Shaju Mathew
91f544f227 Now ignoring adb shell service return error code in acov-llvm.py
Bug: 261529166

Ignore failures when sending the flush signal.  Some processes may have
exited after we run `adb shell ps` but before we could send the flush signal.

Test: Successful run of coverage metrics using acov-llvm (as documented in go/android-native-coverage-local-workflow

Change-Id: I2fc0f71bf5f6d810b4124e28d7dd69ebfc2579b3
Signed-off-by: Shaju Mathew <shaju@google.com>
2022-12-06 19:31:22 +00:00
Treehugger Robot
cc18ab77b1 Merge "Get latest stable version rather than absolute latest." 2022-11-28 16:55:39 +00:00
Andrew Walbran
b5ef53e335 Get latest stable version rather than absolute latest.
We don't want to import alpha versions, generally.

Test: get_rust_pkg.py -add3prf zerocopy
Change-Id: If51a5f9786ccbae8b8f858ae51153a0ffb5ffe7f
2022-11-18 15:35:09 +00:00
Christopher Ferris
e6e02b0e22 Only add files in GlobSymbolsDir.
I previously skipped directories, but that can still lead to problems.
So instead, only add paths that are files.

Test: Ran over a stack that failed when trying to run llvm-readelf
Test: on a directory. After this fix, everything get line numbers.
Change-Id: Ide39c5a118d78a822057cc3977d0f532595f798b
2022-11-08 17:47:37 -08:00
Christopher Ferris
29fcc84e82 Fix build id check for libraries.
The current build id check uses the file utility. Unfortunately, it
doesn't work on all systems. Replace with a call to llvm-readelf and
get the bitness and build id using that data.

Other small modifications:
- Only attempt to get the full path for a library once for each library.
- Do not add directories into the symbol libraries.

Test: Unit tests pass.
Test: Running using a libart.so that file doesn't understand and
Test: verifying the line numbers are correct.
Change-Id: I12c3d3c4599d201c3c01feeb48448fee6c633d71
2022-11-02 17:55:57 -07:00
Treehugger Robot
a063ff34e4 Merge "Use gdb-remote without host if not given" 2022-10-19 18:38:57 +00:00
Florian Mayer
b61f795aa4 Use gdb-remote without host if not given
Test: lldbclient.py -r ls
Change-Id: I162d318fa30c44f180b6104b31e61e7521fb6a48
2022-10-19 01:16:11 +00:00
Elliott Hughes
f8b9b91130 Remove scripts that haven't yet been updated for python3.
That seems like a sign none of these are used. (Two of them haven't been
touched since their initial import in 2009!)

Test: treehugger
Change-Id: I76042f6c8fab84669c83aa72cd0b5df13f01ed7c
2022-10-18 21:41:59 +00:00
Christopher Ferris
99d580a123 Remove obsolete script.
In addition, remove the test for it and the test file.

Test: NA
Change-Id: Ib5124749c523177805f494d9a6daf2400b6fc84c
2022-10-13 16:38:34 -07:00
Krzysztof Kosiński
45c7ebda06 Remove Python enables identical to global defaults.
Bug: 245854393
Test: presubmit
Change-Id: I9bb5cbd972432a26afcb13d7c2a6bbc73fb0991f
2022-09-17 11:33:50 +00:00
Matthew Maurer
b59698e2e9 c2a: Legacy cleanup
* 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
2022-09-12 13:03:32 -07:00
Matthew Maurer
ae5da710b3 c2a: Parse new cargo output
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
2022-09-12 12:55:47 -07:00
Pierre-Clément Tosi
fd12b5feed c2a: Clean-up no-ops with 'pass'
Bug: 243662244
Test: -
Change-Id: Ib62b19c18da7e3a44c74303a72a9c27f9d8b3315
2022-08-24 17:41:08 +01:00
Pierre-Clément Tosi
e5342d134a c2a: Crate: Don't parse -Wclippy, -D, and -W flags
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
2022-08-24 17:41:08 +01:00
Pierre-Clément Tosi
435dfe58d1 c2a: Crate: Parse unquoted rustc args
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
2022-08-24 17:40:23 +01:00
Pierre-Clément Tosi
dde806f72d c2a: Extend unquote() to single quotes
Bug: 243662244
Test: -
Change-Id: I4de409b3135369425f8fa934f490e701505cd55d
2022-08-24 16:36:34 +01:00
Frederick Mayle
9f0dd71b8a cargo2android: fix test detection when there is exactly 1 test
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
2022-08-17 20:36:45 +00:00
Matthew Maurer
b1d8a2de5f Merge changes I4c3744e0,I91d8de92
* changes:
  c2a: Our cargo works again, re-enable defaulting.
  c2a: Fix rust_version calculation
2022-08-17 16:08:32 +00:00
Matthew Maurer
51ec016f76 rust: addr3prf: Support COPYING files
Previously, we only looked for LICENSE* files. This adds support for
detecting COPYING* files as an alternate representation of the license.

Bug: 234563254
Test: get_rust_pkg.py -add3prf quiche
Change-Id: Ic04ef42f349879be18a4307bd863288dfa81b5fc
2022-08-10 15:29:24 -07:00
Frederick Mayle
71722b10e5 cargo2android: Fix edge case in --add_workspace feature
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
2022-07-27 00:13:52 +00:00
Jeffrey Vander Stoep
3a293c7bba Merge "Revert "c2a: add option to use Cargo.toml.orig"" 2022-07-07 08:24:42 +00:00
Jeffrey Vander Stoep
6529bcaf6a Revert "c2a: add option to use Cargo.toml.orig"
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
2022-07-06 12:34:37 +00:00
Treehugger Robot
1da99cc99e Merge "c2a: add option to use Cargo.toml.orig" 2022-06-23 15:34:41 +00:00
Jeff Vander Stoep
2adbd7ed89 c2a: add option to use Cargo.toml.orig
`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
2022-06-23 16:38:08 +02:00