Commit Graph

406 Commits

Author SHA1 Message Date
Joel Galenson
cb5f2f0bd7 Add a lib blocklist and an option to force rust_library_rlib.
Test: Use in some crates.
Change-Id: I5d098ce9b0f1fc37c5d8408524c0755869657992
2021-06-08 15:08:29 -07:00
Joel Galenson
3d6d1e78b5 Allow blocklisting cfgs.
Test: Use it for a crate.
Change-Id: I72e383ce58f64c7e545db3049376feea8ac006d1
2021-06-07 15:00:24 -07:00
Joel Galenson
f6b3c91d21 Allow blocklisting tests.
This allows you to give cargo2android.py a list of test files to ignore.

Test: Use on a couple crates.
Change-Id: Id9422c496de6693029754f32d9805f1cb92d33cb
2021-06-03 16:00:54 -07:00
Joel Galenson
97e414af12 Allow blocklisting dependencies.
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
2021-06-02 15:49:04 -07:00
Joel Galenson
7e8247e2eb Abort cargo2android.py if the patch fails.
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
2021-05-24 15:31:08 -07:00
Joel Galenson
5774c85c70 Raise an exception if we encountered an error.
This allows the caller to handle it if they wish.

Test: Call with an error.
Change-Id: Ia2e0d38e8e486a2b78e42d154654332e88909e9f
2021-05-24 15:31:08 -07:00
Roland Levillain
1f1a79d97d Merge "Print the coverage report location at the end of acov-llvm.py report." 2021-05-21 19:28:39 +00:00
Roland Levillain
d2f1236a6e Print the coverage report location at the end of acov-llvm.py report.
This makes it easier to identify the directory where the coverage
report data of the latest `acov-llvm.py report` was written,
especially when the current directory already contains previous
coverage reports.

Test: acov-llvm.py report
Bug: 160401633
Change-Id: I96fc860940f5be11c4c3b702dfce74226afabfce
2021-05-21 17:36:13 +01:00
Julien Desprez
59189ecc35 Merge "Attempt to run python-stack_core_test" 2021-05-21 01:04:24 +00:00
Treehugger Robot
0b1aa4958f Merge "When cargo errors, print an error about cargo.out." 2021-05-18 04:05:19 +00:00
Joel Galenson
6bf54e3abb When cargo errors, print an error about cargo.out.
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
2021-05-17 10:54:50 -07:00
Roland Levillain
d203b9e692 Fix adb root invocations in script acov-llvm.py.
Test: acov-llvm.py clean-device
Bug: 160401633
Change-Id: Ie41e13a7ab81994b8fed91ac07e32c6b90b91e74
2021-05-13 16:20:54 +01:00
Julien Desprez
fd06c732e1 Attempt to run python-stack_core_test
Test: presubmit
Bug: 185900237
Change-Id: I7c41545d4e1fbdeebd729615b5b12ee64ba6a8b9
2021-05-06 09:17:45 -07:00
Pirama Arumuga Nainar
4851047a4c Merge "Send coverage flush signal to only processes that handle signal 37." 2021-05-04 03:54:46 +00:00
Pirama Arumuga Nainar
beb6fb7493 Send coverage flush signal to only processes that handle signal 37.
Bug: http://b/160401633

Also:
- fix regexp to find clang prebuilt version to allow a suffix.
- call `adb root` before any operation.

Test: acov-llvm.py flush
Change-Id: I9287610ee2ccfec165b0a0bc2e3b24e0eb84ca31
2021-04-30 15:06:39 -07:00
Joel Galenson
367360cdaf Do not write out the --no-test-mapping option.
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
2021-04-29 14:33:13 -07:00
David Srbecky
ec44e57e10 Merge "Make the stack script python3.5 compatible." 2021-04-29 16:48:07 +00:00
David Srbecky
fd1e41623d Make the stack script python3.5 compatible.
Ensure that the script works on buildbots.

Test: adb shell debuggerd -b <pid> | development/scripts/stack
Change-Id: I3fd4a0ed78ff3245d1ab2f6e842446888c5c7b8b
2021-04-27 22:24:36 +01:00
Joel Galenson
d9c4de6fe3 Let cargo2android.py generate apex_available and min_sdk_version.
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
2021-04-26 11:34:15 -07:00
Joel Galenson
0fbdafe016 Allow cargo2android.py to use a config file instead of command-line options.
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
2021-04-26 11:33:52 -07:00
Krzysztof Kosiński
b136111f17 Upgrade the 'stack' script to python3.
Also hook up the test to Android.bp.

Test: unit test
Test: Ran with a tombstone file as parameter.
Test: Ran pasting in stack to stdin.
Change-Id: I25f40569cc49b7487553611bcc25d061179bfa8d
2021-04-09 13:21:32 -07:00
Thiébaud Weksteen
a5a728b4c8 cargo2android: Use cfgs property
Test: Run cargo2android on multiple crates, verify Android.bp
Bug: 183727250
Change-Id: I087ffb0de33db7a09735d2e9c668d991c9f5bb49
2021-04-08 14:23:49 +02:00
Treehugger Robot
ad8e4d2a7e Merge "NFC: Refactor a string so we can add a comment to it." 2021-04-07 22:15:50 +00:00
Joel Galenson
4d82acfeee Merge "Add a cargo2android flag to disable generating TEST_MAPPING." 2021-04-07 21:41:15 +00:00
Treehugger Robot
dddc6e0873 Merge "Fix cargo2android's license block preservation" 2021-04-07 21:39:51 +00:00
Joel Galenson
3f42f80970 NFC: Refactor a string so we can add a comment to it.
Test: Run cargo2android.py
Change-Id: Id833bd3292a4cd9f8c348aee9725e0924d826d97
2021-04-07 12:42:17 -07:00
Joel Galenson
cf4ebb00a6 Add a cargo2android flag to disable generating TEST_MAPPING.
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
2021-04-07 08:39:51 -07:00
Joel Galenson
d9d13b8309 Fix cargo2android's license block preservation
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
2021-04-07 08:20:58 -07:00
Treehugger Robot
dbde427be6 Merge "Add Ring test timeout." 2021-04-06 20:55:52 +00:00
Joel Galenson
4f9d11f6b1 Sort Rust TEST_MAPPING tests.
We currently seem to emit TEST_MAPPING files in an arbitrary order,
which causes diffs to look confusing even when nothing has changed.
Let's sort them by the test name, which is both stable and easier to
read.

Test: Run cargo2android multiple times and see no TEST_MAPPING diff.
Change-Id: I398aa84a4891380e4292223445bd53959c024421
2021-04-06 10:18:21 -07:00
Joel Galenson
a0d4c5e5a5 Add Ring test timeout.
This test looks like it basically never passed without this.

Test: Run cargo2android.py and see timeout.
Change-Id: Ic7ef5576efb84d78130dd45db67e50ebe41f6d9a
2021-04-06 09:36:47 -07:00
Pirama Arumuga Nainar
c41549f3d2 Add acov-llvm.py script
Bug: http://b/160401633

This is a tool for gathering coverage information from a device and
generating an LLVM coverage report from that information.  See top of
the file for usage instructions.

Also redirect acov users to acov-llvm when CLANG_COVERAGE is set.

Test: acov-llvm.py wih clean-device, flush and report subcommands.

Change-Id: I5dba3a669bb6ac2797093903536f346228625c05
2021-03-30 14:58:06 -07:00
Haibo Huang
0f72c95e70 [cargo2android.py] Reserve all lines before the first rust_* rule
Change-Id: Ic3cffcc7f34d878b7cc627f10361d42271b12f1e
2021-03-19 15:17:42 -07:00
Krzysztof Kosiński
dd45e18f94 Make the "stack" script work for device tests.
The path where the tests are uploaded by atest differs from the
path to unstripped binaries in the out directory. As a result,
the script can't symbolize the parts of the stack trace that
correspond to code in the test binary. Add a fixup to use the
correct path.

Test: Used the script on example crashes in framework and vendor
device tests - appears to work and give correct line numbers.

Change-Id: I5470e6342afb801ac596cbc0c0bf067850b1e09a
2021-03-11 18:09:15 -08:00
Thiébaud Weksteen
8da491134a Update add3prf.py
Change the license detection logic to return if a dual-license was
found. Update the metadata comment as discussed in b/179902335.
Add unit tests for add_module_license and decide_license_type.

Bug: 179902335
Test: atest --host add3prf_test; manually run add3prf.py in {ahash,
  libloading, parking_lot, ring}
Change-Id: I3184b5cf0955d124170b9e5987308507bdef6e9a
2021-02-19 12:20:34 +01:00
Joel Galenson
56446748cf Have cargo2android put warning not to modify Android.bp files
Test: Run cargo2android
Test: Run upgrader script
Change-Id: Idd9fc9b8ad7a7c4fb3da954178d0221c95132fd3
2021-02-18 09:36:53 -08:00
Bob Badour
f7cf305656 [LSC] Add LOCAL_LICENSE_KINDS to development
Added SPDX-license-identifier-Apache-2.0 to:
  apps/BluetoothDebug/Android.bp
  apps/BuildWidget/Android.bp
  apps/CustomLocale/Android.bp
  apps/DevelopmentSettings/Android.bp
  apps/Fallback/Android.bp
  apps/GestureBuilder/Android.bp
  apps/NinePatchLab/Android.bp
  apps/OBJViewer/Android.bp
  apps/PushApiAuthenticator/Android.bp
  apps/PushApiTestAppOne/Android.bp
  apps/PushApiTestAppTwo/Android.bp
  apps/SdkSetup/Android.bp
  apps/SettingInjectorSample/Android.bp
  apps/WidgetPreview/Android.bp
  apps/launchperf/Android.bp
  cmds/monkey/Android.mk
  gsi/gsi_util/Android.bp
  gsi/repack_super_image/Android.bp
  host/windows/Android.bp
  python-packages/Android.bp
  samples/AccelerometerPlay/Android.bp
  samples/AdaptiveIconSample/Android.bp
  samples/AliasActivity/Android.bp
  samples/AndroidBeamDemo/Android.bp
  samples/AppNavigation/Android.bp
  samples/AutofillKeyboard/Android.bp
  samples/BackupRestore/Android.bp
  samples/BasicGLSurfaceView/Android.bp
  samples/BluetoothChat/Android.bp
  samples/BrokenKeyDerivation/Android.bp
  samples/BrokenKeyDerivation/tests/Android.bp
  samples/BusinessCard/Android.bp
  samples/Compass/Android.bp
  samples/ContactManager/Android.bp
  samples/CubeLiveWallpaper/Android.bp
  samples/DataWiper/Android.bp
  samples/DeviceAdminWhitelistedAccount/Android.bp
  samples/FixedGridLayout/Android.bp
  samples/HeavyWeight/Android.bp
  samples/HelloActivity/Android.bp
  samples/HelloActivity/tests/Android.bp
  samples/HelloEffects/Android.bp
  samples/Home/Android.bp
  samples/HoneycombGallery/Android.bp
  samples/InlineFillService/Android.bp
  samples/JetBoy/Android.bp
  samples/LceDemo/Android.bp
  samples/LunarLander/Android.bp
  samples/LunarLander/tests/Android.bp
  samples/MultiResolution/Android.bp
  samples/MultiWindow/Android.bp
  samples/MySampleRss/Android.bp
  samples/NotePad/Android.bp
  samples/Obb/Android.bp
  samples/RSSReader/Android.bp
  samples/ReceiveShareDemo/Android.bp
  samples/SampleSyncAdapter/Android.bp
  samples/SimpleJNI/Android.bp
  samples/SimpleJNI/jni/Android.bp
  samples/SipDemo/Android.bp
  samples/SkeletonApp/Android.bp
  samples/SkeletonApp/tests/Android.bp
  samples/Snake/Android.bp
  samples/Snake/tests/Android.bp
  samples/SoftKeyboard/Android.bp
  samples/SpellChecker/HelloSpellChecker/Android.bp
  samples/SpellChecker/SampleSpellCheckerService/Android.bp
  samples/StackWidget/Android.bp
  samples/ThemedNavBarKeyboard/Android.bp
  samples/ToyVpn/Android.bp
  samples/TtsEngine/Android.bp
  samples/USB/AdbTest/Android.bp
  samples/USB/MissileLauncher/Android.bp
  samples/UiAutomator/Android.mk
  samples/Vault/Android.bp
  samples/Vault/tests/Android.bp
  samples/VoiceRecognitionService/Android.bp
  samples/VoicemailProviderDemo/Android.bp
  samples/WeatherListWidget/Android.bp
  samples/WiFiDirectDemo/Android.bp
  samples/WiFiDirectServiceDiscovery/Android.bp
  samples/Wiktionary/Android.bp
  samples/WiktionarySimple/Android.bp
  samples/XmlAdapters/Android.bp
  samples/apkcachetest/Android.bp
  samples/training/NsdChat/Android.bp
  scripts/Android.bp
  testrunner/Android.mk
  testrunner/tests/Android_native.mk
  tools/apkcheck/Android.bp
  tools/bugreport/Android.bp
  tools/etc1tool/Android.bp
  tools/idegen/Android.bp
  tools/mkstubs/Android.bp
  tools/rmtypedefs/Android.bp
  vndk/Android.bp
  vndk/tools/Android.bp
  vndk/tools/elfcheck/Android.bp
  vndk/tools/header-checker/Android.bp
  vndk/tools/header-checker/src/repr/protobuf/proto/Android.bp
  vndk/tools/header-checker/tests/integration/ifunc/Android.bp
  vndk/tools/header-checker/tests/integration/version_script_example/Android.bp
  vndk/tools/image-diff-tool/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD
    SPDX-license-identifier-CPL-1.0 SPDX-license-identifier-MIT
    SPDX-license-identifier-Unicode-DFS SPDX-license-identifier-W3C
    legacy_restricted legacy_unencumbered
to:
  Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-CPL-1.0
to:
  samples/SearchableDictionary/Android.bp

Added SPDX-license-identifier-Apache-2.0 legacy_unencumbered
to:
  tools/Android.bp

Added SPDX-license-identifier-BSD SPDX-license-identifier-CPL-1.0
    SPDX-license-identifier-MIT SPDX-license-identifier-Unicode-DFS
    SPDX-license-identifier-W3C
to:
  sdk/Android.bp

Added legacy_restricted
to:
  samples/KeyChainDemo/Android.bp
  tools/line_endings/Android.bp
  vndk/tools/definition-tool/datasets/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all

Exempt-From-Owner-Approval: janitorial work
Change-Id: I9847e00fb4278bc083b4debbc751003c995ea45c
2021-02-12 17:13:45 -08:00
Jeff Vander Stoep
82ee11ae77 update_crate_tests.py: don't use sys.exit()
If the TEST_MAPPING cannot be generated, print the reason, but
exit without error. It's not uncommon for the output of cargo2android
to fail to build e.g. if a new depencency is not satisfied, so we can
fall back to the previous TEST_MAPPING, or run update_crate_tests
locally once all dependencies are present.

Bug: 179132533
Test: tools/external_updater/updater.sh update rust/crates/textwrap
Test: tools/external_updater/updater.sh update rust/crates/libc
Change-Id: I4802c77332d1ab1d6604d48c47365f40bdbd1122
2021-02-04 12:10:39 +01:00
Jeff Vander Stoep
1b24dc3f71 update_crate_tests: fail gracefully
Allow this script to accept a path to the crate being updated.
This allows it to be run separately from cargo2android.

Also, fail gracefully on error. TEST_MAPPING update failures should
not block crate updates.

Test: tools/external_updater/updater.sh update rust/crates/libc
Bug: 179132533
Change-Id: I3a4229f479ab3d2793df16b470f0a0632b9ee495
2021-02-03 21:42:40 +01:00
Jeff Vander Stoep
0b0e24f201 update_crate_tests.py: allow excluding tests by name or path
The aidl tests and ChromeOS tests are not intended to be run in
presubmit, so exclude them.

Test: run cargo2android in external/rust/crates/libc.
Change-Id: I1ed92ed6e88886e3fea38612325ce5349db0fb69
2021-01-24 22:19:50 +01:00
Jeff Vander Stoep
cec8bac2cb Cargo2Android: add rdep tests to TEST_MAPPING
This is important because:
1. Some crates do not have their own tests enabled in presubmit.
2. As much as possible, we try to stick with one version of each
   crate. This often results in using different versions of
   dependencies than a crate has specified in its Cargo.toml.

Ensuring that a crate's tests continue to pass when its dependencies
are upgraded improves our confidence that the update is safe.

The underlying implementation uses the new Bazel queryview
to query modules and reverse dependencies.

Bug: 168167373
Test: Run cargo2android.py on a number of crates including rusqlite,
scopeguard, lock_api.

Change-Id: Id24f2d3267cf8d5e0369ece2442f8971d4ab1343
2021-01-15 20:56:59 +01:00
Treehugger Robot
169b7827ed Merge "Cleanup cargo2android.py." 2021-01-13 20:47:40 +00:00
Joel Galenson
4319a7e8a5 Cleanup cargo2android.py.
Followup to aosp/1548356 to remove the now unused host parameter to add_test.

Test: Manually run script and verify the output.
Change-Id: Id00e56a2dc5523a44dc3cb473702c1ae8785d3db
2021-01-13 08:36:31 -08:00
Treehugger Robot
a727e45813 Merge "Do not generate TEST_MAPPINGs for host tests" 2021-01-13 16:20:27 +00:00
Joel Galenson
e261a15598 Do not generate TEST_MAPPINGs for host tests
Instead of generating TEST_MAPPING entries for host tests, we add a
test_options section to its Android.bp entry.

Fixes: 176097100
Test: Manually run cargo2android on a few crates and verify the output
Change-Id: Ia57a53dad6910410c7e7aab6d592fba79720f998
2021-01-12 11:31:53 -08:00
Ivan Lozano
5b757feed9 Merge "rust: Use rust_ffi for Rust generated C libraries." 2021-01-09 03:31:19 +00:00
Stephen Hines
013e0ed53e Update Rust OWNERS.
Test: N/A
Change-Id: I1cef9c237479dc289ff57148ce901f4f522a5465
2021-01-08 17:38:34 -08:00
Alex Light
a8f224d606 lldb-vscode
Add support for using lldb with vscode.

Test: lldbclient.py --setup-forwarding vscode -r dalvikvm
Bug: 176158605

Change-Id: I92a08b3b02a27a14be586582fe57acdd670a9ada
2020-12-28 11:30:39 -08:00
Ivan Lozano
0c057ade57 rust: Use rust_ffi for Rust generated C libraries.
We no longer have the rust_library_shared and rust_library_static module
types. They've been renamed to rust_ffi_* instead. This brings
cargo2android.py up to date.

Bug: 175155132
Test: cargo2android's Android.bp for libquiche contains rust_ffi modules
Change-Id: I01bb8b4e56c41d36481ffd363f96aecb770d7cb8
2020-12-15 10:41:26 -05:00
Christopher Ferris
49eda0e908 Remove gcc tools from script.
Replace all references to gcc tools with llvm tools. This change still
uses c++filt until llvm-cxxfilt is put in the prebuilts.

Test: Ran a backtrace through this script and the old script and verified
Test: no major differences.
Test: Ran unittests for symbol.py and stack_core.py.
Change-Id: Ic31c1a0707dae11c5037f9637943cd7932badf46
2020-12-09 14:34:01 -08:00