Commit Graph

524 Commits

Author SHA1 Message Date
Treehugger Robot
682fb39f4c Merge "Allow passing arguments with -- in addition to -." am: 6999b11924 am: 316661da78
Original change: https://android-review.googlesource.com/c/platform/development/+/1324434

Change-Id: I5bed3af520a0225e7d21c6fffe51322ed9dc30b5
2020-06-05 00:04:42 +00:00
Joel Galenson
70da55bef5 Allow passing arguments with -- in addition to -.
This allows the Unix-like command-line argument --show.  We keep the
existing -show.

Test: get_rust_pkg.py -show foo
Test: get_rust_pkg.py --show foo
Change-Id: I5906e0c59ef6f9e4ad33b0a9645a1fc4d9d9e1aa
2020-06-04 08:49:46 -07:00
Haibo Huang
3052e34b3c Merge "Updates gdbclient.py for lldb" am: b5727d3e0e am: 36981ede3b
Change-Id: Ifbd280408477aacabf6c87cb07a5f10b31b1d65e
2020-05-13 21:51:05 +00:00
Haibo Huang
07e17073c5 Updates gdbclient.py for lldb
1. Sets up source mapping so that people can run from other directories.
2. Removes PYTHONHOME. It is embedded into the binary.

Change-Id: Ic7a7f1483dc645d890b7e0f3dcbb0ebb169794ac
2020-05-12 16:51:29 -07:00
Treehugger Robot
2496a5da3b Merge "Miscellaneous coding style and output improvements" am: 856b7fc7d1 am: 137218a565
Change-Id: I648a68ff30eee6a919e412fe1a12f0b171a60c3b
2020-05-12 20:22:50 +00:00
Treehugger Robot
856b7fc7d1 Merge "Miscellaneous coding style and output improvements" 2020-05-12 19:49:12 +00:00
Chih-hung Hsieh
71eb527474 Merge "Ensure unique name for non-merged modules." am: 489013b6c0 am: 8d973bd2f8
Change-Id: I9113a3834136fb7c1f28a4df9c7d02f06ee757c9
2020-05-12 18:40:53 +00:00
Chih-Hung Hsieh
185052a369 Ensure unique name for non-merged modules.
* Do not emit relative_install_path;
  use default unique module name.
* Copy errors in cargo output to Android.bp.
  Some Rust packages are incomplete at crates.io
  and fail to run through cargo test.
* Apply pyformat.

Bug: 156014698
Test: in external/rust/crates/*, cargo2android.py --run --tests
Change-Id: Ide77ca34e47048a8bc03b18eebbe92fb17666784
2020-05-08 12:31:04 -07:00
Chih-Hung Hsieh
2f22d1cb80 Miscellaneous coding style and output improvements
* Call print with flush=True to get immediate output to piped files.
* Simplify code with functools.reduce or for-loops.
* Clarify error handling and messages.
* Skip output of empty dependent lists.
* Suppress output of repeated dependent lists.
* Move "revisit" logic from recursive add_non_dev_dependencies to
  a while loop in add_indirect_build_deps.
  This is less efficient, but more complete and easier to understand.
* Align table captions to something like:
    build_deps[k] = # of non-dev-dependent packages of pkg[k]
      dev_deps[k] = # of all dependent packages of pkg[k]
all_build_deps[k] = # of non-dev-dependent ... of pkg[1] to pkg[k]
  all_dev_deps[k] = # of all dependent ... of pkg[1] to pkg[k]

Test: get_rust_pkg.py -h
Test: get_rust_pkg.py -v -show remain syn quote
Test: get_rust_pkg.py -v -show glob libloading
Change-Id: I6171b6be8806bcdd1129f52e7e5ccf7b274e2e8c
2020-05-06 18:22:17 -07:00
Chih-hung Hsieh
02861af0a4 Merge "Show number of dependent packages" am: 7dc3f534a0 am: 15fbb9c2ea
Change-Id: I030a3a9cf015e566090657ae9d057d6641f43682
2020-05-06 17:46:43 +00:00
Chih-Hung Hsieh
783dfd4c64 Show number of dependent packages
* With flag "-show" and a list of package names,
  call crates.io api to count dependent packages.
  * The packages are NOT fetched.
  * Optional dependent packages are not counted.
  * Indirect non-dev dependent packages are counted.
  * Finally all non-dev dependent packages are also
    included in the report.
  * The report is a table like this:

  build_deps[k] = # of non-dev-dependent packages of pkg[k]
  dev_deps[k] = # of all dependent packages of pkg[k]
  all_build_deps[k] = # of non-dev-dependent ... of pkg[1] to pkg[k]
  all_dev_deps[k] = # of all dependent ... of pkg[1] to pkg[k]
    k pkg         build_deps   dev_deps all_build_deps   all_dev_deps
    1 unicode-xid          0          0              0              0
    2 proc-macro2          1          3              0              1
    3 syn                  2        107              0            104
    4 quote                2         18              0            107
    5 remain               4         18              0            107

  Packages are sorted topologically by the non-dev-dependencies.
  The column all_build_deps should be 0 if the topological sort
  did not find cyclic dependency.

* Simplify find_dl_path with a crates.io api call to get max_version.
* Handle urllib.error.HTTPError exception
* Formatted by pyformat.

Test: get_rust_pkg.py -h
Test: get_rust_pkg.py -show syn remain quote
Test: get_rust_pkg.py -v -show remain syn quote

Change-Id: Ib4ece8dd391558fb5fd866b153f30cd2ef59f6b3
2020-05-05 17:13:34 -07:00
Chih-hung Hsieh
babf3b6db0 Merge "Accept and fetch multiple packages" am: 066b315b2c am: 0bb869f863
Change-Id: Iac261b4ef886350548aca1ff1fb15200fbd71235
2020-04-28 17:58:00 +00:00
Chih-Hung Hsieh
23a7406de1 Accept and fetch multiple packages
* Duplicated package names are skipped.
* A package name can be a simple base name like 'syn',
  or with version number like 'syn-1.0.5'.

Test: get_rust_pkg.py -h
Test: get_rust_pkg.py pkg1 pkg2 pkg3
Test: get_rust_pkg.py -o tmp -v pkg1 pkg2 pkg1
Change-Id: I5757f20c9a7cb244dc4b06113e28fcf4585c0703
2020-04-24 13:24:14 -07:00
Chih-hung Hsieh
d0af31058e Merge "Accept multiple --crate-type and fix for new cargo." am: 8833757764 am: c81d221b0c
Change-Id: Icc61ecc41977b84b3f2a089a26a985856b185a60
2020-04-07 19:40:05 +00:00
Chih-Hung Hsieh
8a1a2300ed Accept multiple --crate-type and fix for new cargo.
* Change crate_type string to crate_types list.
  In dump_android_module, iterate over crate_types and
  call dump_one_android_module for each crate type.
* In decide_one_module_type, add mapping of Rust crate types:
        lib => rlib         (no change)
        rlib => rlib        (new)
        dylib => dylib      (new)
        cdylib => shared    (changed)
        staticlib => static (new)
  Maybe we should change and map 'lib' to 'lib',
  but before that, crate_types should not contain
  both 'lib' and 'rlib'.
* Accept new cargo output format, which can
  call rustc with the main source file name after
  other flags, not always after the "--crate-name" flag.
* Work around duplicated test module name problem;
  call self.runner.claim_module_name for every named test module.

Bug: 153118477
Test: fetch quiche-0.3.0, bindgen-0.53.2 and other Rust crates
Test: cargo2android.py --run --vv --device --tests
Change-Id: Id65c3929b5c593df73f26f1510ad7e89194b209e
2020-04-07 10:49:08 -07:00
Treehugger Robot
4aed385cbb Merge "Skip yanked packages and use newest version number." am: f50e489c40 am: 42a7aeb008
Change-Id: Icca8b90c38dacd8f2774f60fc1dd4299484ec8a4
2020-04-02 21:58:42 +00:00
Chih-Hung Hsieh
7c6362a96b Skip yanked packages and use newest version number.
* crates.io keeps yanked packages with the "yanked" attribute.
  For example, log-0.4.9 and log-0.4.10 were yanked so
  "get_rust_pkg log" should skip them.
* Compare version numbers before the publish id number.
  For example, lazy_static-1.1.1 was published after lazy_static-1.4.0,
  but "get_rust_pkg lazy_static" should fetch 1.4.0.

Test: get_rust_pkg.py -v log  # get log.0.4.8
Test: get_rust_pkg.py -v log-0.4.10  # get log.0.4.10
Test: get_rust_pkg.py -v lazy_static  # get lazy_static-1.4.0
Change-Id: Id005a91b75c0885285a76136bd6de19d0dafa5c1
2020-04-02 10:23:48 -07:00
Chih-hung Hsieh
6d03b47f67 Merge "Pass --no-default-features to cargo build" am: ebfb3a9927 am: 7a56a6c23e
Change-Id: Icf56a490dae40ed98a8a0b2d29a22b773bd5b164
2020-03-31 19:02:34 +00:00
Chih-Hung Hsieh
6c8d52f6eb Pass --no-default-features to cargo build
* When --features is specified,
  pass --no-default-features to cargo.
* When a dependent Rust package is imported to AOSP,
  if not all "default" features are needed, run
  cargo2android.py with empty or a list of specific features.

Test: cargo2android.py --run # use default features
Test: cargo2android.py --run --features=''  # no default
Test: cargo2android.py --run --features='default,std'
Change-Id: I854f1ecb7d7466490ff34e229ec14a07c1273c6d
2020-03-31 10:08:06 -07:00
Chih-hung Hsieh
ae62411fe4 Merge "add get_rust_pkg.py" am: e95677343a am: b415c21248
Change-Id: Ia088e70176b474c0a9af0114d975d675b32f7e92
2020-03-30 21:13:44 +00:00
Chih-Hung Hsieh
8a3e910fee add get_rust_pkg.py
Test: get_rust_pkg.py syn
Test: get_rust_pkg.py -v -o /tmp bitflags-1.2.0
Change-Id: I540b757a9dab56d4216015513d649b23063fb901
2020-03-27 12:41:29 -07:00
Automerger Merge Worker
7b95be8430 Merge "Update acov script to handle new coverage file locations." am: 834c8442cb am: 0b6aee253a
Change-Id: I6b4c2b75f047af0ec285094fe007d28e93f0c7d3
2020-03-12 18:24:07 +00:00
Oliver Nguyen
f7421ae9db Update acov script to handle new coverage file locations.
Test: Build with native coverage and run acov, check report contents.
Change-Id: I47afd35216cfcc7df7da2378cccdf8dba23bd8e2
2020-03-11 10:54:07 -07:00
Automerger Merge Worker
c726424b42 Merge "Add support for xxx.so!xxx.so lines." am: 197cd3d795 am: dc6db11f99 am: 094e559462
Change-Id: I55765fa70a454a849f53d59a255f225f7f49aa23
2020-02-01 04:53:20 +00:00
Christopher Ferris
5e4b37213d Add support for xxx.so!xxx.so lines.
When seeing a line like:
  #01 pc 0012ea14  /system/lib/libart.so!libart.so (offset 0x134000)

Treat it like this line instead:
  #01 pc 0012ea14  /system/lib/libart.so

This will allow the symbolizer to properly figure out the line numbers.

Bug: 148657674

Test: Ran lines with xxx.so!xxx.so lines and verified that they decode.
Change-Id: Ieea516b46a00b414c740d0b4302a5cc73da2b0a8
2020-01-31 14:38:07 -08:00
Automerger Merge Worker
e751f5190d Merge "Add --lldb to gdbclient.py" am: f8514fe646 am: 21114c9277 am: a0e42ece44
Change-Id: I7f0209175ad32a574f791a3d6f3f28176a69e0c4
2020-01-07 22:36:23 +00:00
Haibo Huang
e194fcecf9 Add --lldb to gdbclient.py
Test: `gdbclient.py --lldb -r /system/bin/toybox` and try `b main` `c`
Test: `/data/local/tmp/arm64-lldb-server gdbserver :5039 /system/bin/toybox` and `gdbclient.py --lldb -p 4909`
Change-Id: If7b6895e9c778cdee3764a4058cf70238bdd6b8a
2020-01-06 14:55:28 -08:00
Stephen Hines
84fde73031 resolve merge conflicts of 6cfe24fbf7 to master
Bug: None
Test: I solemnly swear I tested this conflict resolution.
Change-Id: Ifba1d4d26287799e5decbd3c5cb56490d8c99afb
Exempt-From-Owner-Approval: fix merge conflict
2019-12-11 08:03:21 +00:00
Chih-Hung Hsieh
09539599a0 Add new cargo2android.py owners
* add new cargo2android.py owners
* remove obsolete email address

Bug: 142209566
Test: make
Change-Id: I22e348b45c25ccc82e59fdddf1978462ba2a8e49
2019-12-10 09:19:47 -08:00
Chih-Hung Hsieh
2978204d14 Auto-build/update codegen
Exempt-From-Owner-Approval: introduces separate utility; doesn't touch
anything around it
Test: 1. Manually enter version/presence of build artifact,
and ensure `codegen FILENAME` still works
2. run codegen again without altering version, ensure no build triggered
Change-Id: Iaa253a430e627d0e7c25781cde535958f77db97f
(cherry picked from commit 8ca7673cfc)
Merged-In: Iaa253a430e627d0e7c25781cde535958f77db97f
2019-12-10 09:17:42 -08:00
Chih-hung Hsieh
484bb18f31 Merge "A script to run cargo and generate Android.bp." am: 45ffc27e13 am: b492126ff1
am: 7a2bce40f7

Change-Id: I76f844be97537f201c17ff5f0b55f94a06777f6e
2019-12-06 13:24:24 -08:00
Chih-Hung Hsieh
e888737544 A script to run cargo and generate Android.bp.
* Usage note and help for command flags in the script.
  * Run cargo -v multiple times and collect output in cargo.out.
  * Use target.tmp as temporary working directory.
  * Generate multiple Android.bp files into subdirectories.
  * Simplified package names, without version number.
* Merged Android.bp modules.
  * Use --device flag to generate both host and device build targets
    in a combined module.
  * Use --tests flag to generate rust_test modules, with auto_gen_config,
    and multiple unit tests merged in one module.
* Generate cc_library_static modules for rust packages that call
  'cc' and 'ar' to build static C/C++ libraries.
  * Use the --vv flag to call cargo with -vv.
* Limitations:
  * Cargo.toml and its build scripts might need fix for Android first.
  * Depending on user given cargo parameters.
* TODOs:
  * Handle multiple crate types in one rustc command line.
  * Smart merge of host and device rust_test modules,
    to handle device tests that depend on dynamic libraries.
  * Handle special Rust packages that use only build scripts
    and C/C++ compilers to generate included files.

Bug: 142209566
Test: In rust project directories: cargo2android.py --run
Change-Id: Id54652b1e0a6e5fc16619cd05f5b057eee79d610
2019-12-02 15:43:04 -08:00
Mårten Kongstad
c0d319a8c3 codegen: execute using bash
On Ubuntu 18.04, /bin/sh is symlinked to dash. Executing codegen under
dash results in the following error:

  codegen: Syntax error: "(" unexpected

To prevent this, explicitly use bash.

Test: manual ($ANDROID_BUILD_TOP/development/scripts/codegen --help)
Change-Id: I11bd5e41757a8d26f5e9d7d3340306d5ff4da1f9
2019-10-04 16:48:38 -07:00
Eugene Susla
8ca7673cfc Auto-build/update codegen
Exempt-From-Owner-Approval: introduces separate utility; doesn't touch anything around it
Test: 1. Manually enter version/presence of build artifact,
and ensure `codegen FILENAME` still works
2. run codegen again without altering version, ensure no build triggered
Change-Id: Iaa253a430e627d0e7c25781cde535958f77db97f
2019-07-29 22:15:05 +00:00
Ryan Prichard
1415cbdc4e Merge "gdbclient: support various PT_INTERP values" am: 87001e7ad7
am: 018cac60a1

Change-Id: I673ceecb5e52f513fecfa7643f03435ae6ef6ae1
2019-06-12 13:13:04 -07:00
Ryan Prichard
5d1c3cb157 gdbclient: support various PT_INTERP values
gdb looks for an executable's dynamic linker using the PT_INTERP setting
from the executable. That value can be various things:
 - /system/bin/linker[64]
 - /system/bin/linker_asan[64]
 - /system/bin/bootstrap/linker[64]

Currently, only the bootstrap linker is available in the sysroot/symbols
directory. The ordinary and ASAN linkers are symlinks on the target and
are missing from the sysroot (aka symbols) directory.

Use the executable's PT_INTERP value to find the symbolized linker binary
and add it to the solib search path. If necessary, copy or pull a linker
binary.

Test: gdbclient.py -r ls
  "info sharedlib" shows $OUT/symbols/apex/com.android.runtime.debug/bin/linker64

Test: gdbclient.py -r /data/nativetest64/bionic-unit-tests/bionic-unit-tests
  "info sharedlib" shows $OUT/symbols/system/bin/bootstrap/linker64

Test: m asan_test
  gdbclient.py -r /data/nativetest64/asan_test/asan_test
  "info sharedlib" shows /tmp/gdbclient-linker-HunVs9/linker_asan64

Bug: http://b/134183407
Change-Id: I7f79943dcd9ec762d1aaf21178bb6ab3eff40617
2019-06-11 16:07:37 -07:00
Andreas Gampe
a43fb8ea6a Merge "Stack: Fix argument-less invocation" am: f54ccd7f3f
am: df910e694a

Change-Id: I344237fc13e450dd9d2b94c17eebe3e5826bedb0
2019-04-30 12:27:57 -07:00
Andreas Gampe
dcf9800c7e Stack: Fix argument-less invocation
Add nargs='?' to allow a missing positional argument.

Bug: 131662960
Test: manual
Change-Id: I47d98c7d903b0028bd9969580ff0217aaf0cfb78
2019-04-30 10:07:24 -07:00
Andreas Gampe
5c4b741476 Merge changes Ibe0c93c6,Ib7b1de46 am: 458206d64e
am: 8805a8dbcf

Change-Id: I8951e4176a1b44198a9bcf7d311ba82b9057d7bf
2019-04-09 16:16:21 -07:00
Andreas Gampe
d8c0293a33 Stack: Add ability to override symbols dir
Add --syms option to set the symbols directory used for lookup.

Test: m
Test: manual
Change-Id: Ibe0c93c68cafe017341e54e8f14ea9d775ae13bd
2019-04-08 12:32:27 -07:00
Andreas Gampe
3c9db52fd7 Stack: Replace getopt with argparse
Modernize and make it easier to add new options.

Test: m
Test: manual
Change-Id: Ib7b1de4626e6b2cd27dca1dd911c594db93cb292
2019-04-08 12:32:01 -07:00
Haibo Huang
8f4d101358 Merge "Fix gdbserver path in gdbclient.py" am: d328a9c301 am: 80db2e200a
am: 21e3836824

Change-Id: I3ec5dcdcf4abf17721ab8d610e7eecf6bc343a96
2019-03-26 17:38:08 -07:00
Haibo Huang
931cd0b237 Fix gdbserver path in gdbclient.py
gdbserver is moved in aosp/932459

Test: run gdbclient.py
Change-Id: Ia8cedfc994556bc1019649d15c91a505bdbf6dff
2019-03-26 20:58:21 +00:00
Christopher Ferris
85944576b8 Merge "Really fix support for soname in apk." am: 2f5dc0a066 am: 0a3cbe01a4
am: 279978161d

Change-Id: Ib14dcbb88c3e03642c4edc32a125fef02d6e6d17
2019-03-15 14:26:27 -07:00
Christopher Ferris
ac90d1da7e Really fix support for soname in apk.
Bug: 29218999

Test: Run a stack through vendor/google/tools/stack --auto with this change.
Change-Id: I0d650f30d37bb0dfa9db011d7624c0c74a98f2df
2019-03-15 12:21:57 -07:00
Christopher Ferris
4a3491ed0b Merge "Add support for soname display in apk." am: 3a5a1cf901 am: 246d49ded9
am: 48181e4baa

Change-Id: Ib86c157d2a388a810ee8cd204e530408934a4269
2019-03-14 09:13:46 -07:00
Christopher Ferris
55a9699db3 Add support for soname display in apk.
Bug: 29218999

Test: Verified unwind through an apk works with both formats.
Change-Id: I20dba918e94024902968ab320dc03e1e343d8a31
2019-03-13 17:08:40 -07:00
Peter Collingbourne
acb3916bea Merge "gdbclient.py: Add --env flag." am: f91fb912d3 am: 466966c66a
am: c413ff1ef7

Change-Id: I08dbb74ef537642b5b2e529852e2828e1de3ab2b
2019-02-25 18:53:10 -08:00
Treehugger Robot
f91fb912d3 Merge "gdbclient.py: Add --env flag." 2019-02-23 02:12:39 +00:00
Alex Light
d0ad924c94 Merge "gdbclient.py alternative frontend support" am: 24dc4630c7 am: c34956f0cc
am: 99742da343

Change-Id: Ie3c85a62d0603874d84012659b876b7c788b273c
2019-01-18 17:39:17 -08:00