Commit Graph

605 Commits

Author SHA1 Message Date
Bruce Lee
5efbf7fe97 Add -p option when flush coverage
This is to enable flush coverage from select process on the device by process id:

$ acov-llvm.py flush -p [list of process pids]

Change-Id: I14cf30c80f6d1f7faa0d23f752994f0172ee3ce5
2023-11-16 02:55:19 +00:00
Matt Schulte
055ccb3c49 Add MPL support to add3prf.py
This adds the ability to detect and generate the correct METADATA file
for MPL licensed crates.

Bug: 308477037
Test: atest --host add3prf_test; Ran against https://crates.io/crates/fdt
Change-Id: I2b1765a08b68c5eb59e4f52b33c1df337e8c148b
2023-10-30 14:34:33 -07:00
Treehugger Robot
3187152e8f Merge "Update to use main for new Rust 3p projects." into main 2023-10-20 20:53:10 +00:00
Stephen Hines
ce488a7d20 Update to use main for new Rust 3p projects.
Test: N/A
Change-Id: I3009db547d9ef4a2f6c3645d4276f9542823abcf
2023-10-19 00:34:53 -07:00
Andrei Homescu
7afe14e9d8 Fix cargo2rulesmk.py dependency bug in sandbox
Remove the check performed by cargo2rulesmk.py
whether the external/rust/crates/{name} directories
exist for all dependencies of the current crate.
These directories only exist in the Android tree,
not in the minimal checkout inside the redshell sandbox.

Bug: 281857510
Test: cargo2rulesmk.py on thiserror-impl
Change-Id: I1e5d46b4de3129770ab87ebc5e58563010ae6605
2023-10-19 07:09:00 +00:00
Jeongik Cha
a18bd3c1ca Set <partition>_available only if it is for device
it is meaningful only if it is installed in the device

Bug: 277909042
Test: cargo2android.py with/without device, and then check
product/vendor_available

Change-Id: I9ca7328ac953849db224949089412e181b659945
2023-09-27 02:28:55 +09:00
David Srbecky
bfda306156 Fix build-id lookup for libraries loaded directly from apk
Use only the part after "!" as the filename to lookup.

Test: symbolize local crash
Change-Id: I70840ffcc07dc7d449b726a91c08d12529125d78
2023-09-19 17:09:33 +01:00
Jeongik Cha
3151ae84ef Fix the order of suffix in Android.bp
rust_library + host_suffix + rlib_suffix is the right order
For example, rust_library_host_dylib, rust_library_host_rlib

Bug: 277909042
Test: cargo2android --run --force-rlib
Change-Id: Ib156b96853eb51bae1f68229ebe76b87b0f8b363
2023-09-18 20:00:58 +09:00
James Farrell
56475b17c5 Support adding suffixes to module names and deps.
This is helpful for crates like protobuf and syn for which we have
multiple versions, and will let us eliminate several patch files

Test: Ran it on everything in external/rust/crates.
Change-Id: I29ac1ee69be99b7164e1458e0d8fc1cb028b15a0
2023-09-13 18:00:42 +00:00
James Farrell
a5c22d559c Add some type annotations, mainly to help the IDE.
No functional changes.

Test: Ran it.
Change-Id: Ifedf1c42628dae03968eeefd5101ae75456acd32
2023-09-12 21:14:33 +00:00
Joey Jiao
ddd7c0ff87 Fix covreport folder permission
Change-Id: I671c0ddc1cd0632c3d81c9ec68825decc92b065a
2023-09-08 08:56:27 +08:00
Martin Geisler
6f634869e6 Merge "Revert "Rename libsyn to libsyn2"" into main 2023-09-07 14:01:47 +00:00
Martin Geisler
a6fe26c146 Revert "Rename libsyn to libsyn2"
This reverts commit 7705ea6d36.

Reason for revert: I believe this is stale since `libsyn` is version 2 now:

https://cs.android.com/android/platform/superproject/+/main:external/rust/crates/syn/Android.bp;l=41;drc=fcd71dcc29ef325341ea7c1a145591b349018eb3

Change-Id: I31892447cf95d094e4bb201c4d86a28c70085467
2023-09-01 14:08:46 +00:00
Jeongik Cha
4e8edb4a2c Update add3prf for MetadataURLValid
url field has been deprecated in favor of the identifier field.

Test: check output
Change-Id: I1d642d74f51244d59de4d5c44c4b9878873dd0d6
2023-08-29 11:26:17 +09:00
Andrei Homescu
e88e4d6a5f cargo2rulesmk.py: Support customizing rustc
Port aosp/2633771 to cargo2rulesmk.py.

Bug: 281857510
Test: Run in sandbox on bitflags crate
Change-Id: I85b884351f621a6d96cd2b01ee5113687eb72f32
2023-08-24 22:13:45 +00:00
Andrei Homescu
fb0b60ff12 cargo2rulesmk.py: Remove Python match usage
The script uses Python match which was introduced
in Python 3.10. The sandbox only has 3.8, so we need
to remove match so the script can run.

Bug: 281857510
Test: Run in sandbox on bitflags crate
Change-Id: Id03b0e02f8593b551f2aca201fe0ed2659d58d21
2023-08-24 22:13:39 +00:00
Vinh Tran
46e085a961 Fix path to add3prf.py when calling from get_rust_pkg.py
When --add3prf is set, `get_rust_pkg.py` script `cd` into the crate directory and run `add3prf.py`. However, `add3prf.py` doesn't exist in the newly downloaded crate directory. This CL ensures that we reference to the existing `add3prf.py` script.

Test: development/scripts/get_rust_pkg.py -add3prf -v -o /tmp tinyjson-2.5.1
Change-Id: I4273d4f2b6a1f353960adbbab9abbb96bf3e68f3
2023-08-18 10:21:56 -04:00
Treehugger Robot
8449944a50 Merge "Rename libsyn to libsyn2" into main 2023-08-16 17:10:05 +00:00
Treehugger Robot
6f7ecff37c Merge "Update OWNERS to add new per-file line for script" into main 2023-07-21 13:24:42 +00:00
Treehugger Robot
3062194792 Merge "scripts: Add cargo2rulesmk.py to generate rules.mk" into main 2023-07-20 13:58:57 +00:00
Per Larsen
e1a65278e9 Update OWNERS to add new per-file line for script
Adding per-file line for cargo2rulesmk.py such that
it can be maintained by members of the platsec Rust
and Trusty teams.

Bug: 281857510
Change-Id: I9aedee5a76c4d463d4cf3d0851c60193d96a7696
2023-07-20 00:49:43 +00:00
Per Larsen
7b03617a54 scripts: Add cargo2rulesmk.py to generate rules.mk
Add script that generates rules.mk files from Rust crates.
Based on and inspired by cargo2android.py script to generate
blueprint files for the Android build system.

The script has only been tested on the vendored crates used to
build Trusty (see external/rust/crates) and does not support
the full range of crate types or cargo features.

Bug: 281857510
Change-Id: I1951f75476c36b9a1b794c4a51483f2c7387b1f5
2023-07-20 00:15:39 +00:00
Nikita Putikhin
eea06cf609 Merge "Add --vscode-launch-file to gdbclient.py" into main 2023-07-18 14:24:18 +00:00
AdityaK
50c9af7a63 Clarify meaning of --port flag
Also, edited error message when lunch menu is incorrect.

Change-Id: Ie9f5a00b8560d938212eb2b38713a6343d175958
2023-07-14 16:55:55 -07:00
Nikita Putikhin
7da179ef34 Add --vscode-launch-file to gdbclient.py
The new argument makes the generator write the VSCode launch.json config
into a file instead of stdout.

The generator uses marker lines to insert the config. This way the user
can control where in the file the launch config is written.

Test: atest gdbclient_test
Test: lldbclient.py --setup-forwarding vscode-lldb \
  --vscode-launch-props= \
  '{"internalConsoleOptions" : "openOnSessionStart"}' \
  --vscode-launch-file=.vscode/launch.json -r test

Change-Id: I92b3f479b5ebcb722933938f52d0f23ff098beac
2023-07-13 13:48:37 +00:00
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
Matthew Maurer
7705ea6d36 Rename libsyn to libsyn2
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
2023-05-22 21:21:02 +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