Add options to work in a subdirectory.
* Problem to solve:
When cargo2android.py is run under external/crosvm,
it does not generate .bp file in some subdirectories like kvm.
* Use --add_workspace flag to append [workspace] in Cargo.toml
temporarily to generate correct relative source file paths.
Otherwise, the path will be based on parent/root package
such as external/crosvm.
* Use --global_defaults=default_name flag to insert a global
default module name like "crosvm_defaults" in every module.
* Use --no-subdir flag to generate .bp file in one directory,
and skip all changes to subdirectories.
* Sort the option names so they show up in order with --help.
* Use relative path for local dependent packages.
* Example: run in external/crosvm with flags;
--run --tests --dependencies --no-subdir
fix-up external/crosvm/Android.bp file,
and then run in each subdirectory with flags:
--run --tests --dependencies --add_workspace
--global_defaults=crosvm_defaults
* Add rename mapping:
libminijail ==> libminijail_rust
Bug: 161716839
Test: regen .bp files in external/crosvm subdirectories
Test: make && atest -m -c --include-subdirs external/crosvm
Change-Id: I0c08d358cc2f88f66e99b59032613d2a5b4ea5eb
1 file changed