Commit Graph

102 Commits

Author SHA1 Message Date
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
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