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
* 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
* 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
* 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
* 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
* 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
* 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
* 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
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
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
* 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
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
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
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