From a9fb65d155b11b689bd98f4057f0a2a2da284ce8 Mon Sep 17 00:00:00 2001 From: Matthew Maurer Date: Thu, 16 Jun 2022 13:07:12 -0700 Subject: [PATCH] c2a: Automatically make crates APEX available The bulk of Rust packages in external/ are OS agnostic and do not care about individual platform features. This change is intended to reduce the churn of repeatedly adding new `apex_available` attributes to crates by defaulting to availability. When landing a new crate which is either platform revision specific or has an unstable file format, prefer to set `apex_available: ["//apex_available:platform"]` until you have thought things through. Bug: 174862583 Test: Regenerate with no apex_available, see universal availability Test: Regenerate with apex_available: [], see [] Test: Regenerate with apex_available: [foo], see [foo] Change-Id: I958597789bfc966caec043d051996284dab7a927 --- scripts/cargo2android.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/scripts/cargo2android.py b/scripts/cargo2android.py index c571dabe2..a9d57ebeb 100755 --- a/scripts/cargo2android.py +++ b/scripts/cargo2android.py @@ -709,10 +709,16 @@ class Crate(object): for header_dir in self.runner.args.exported_c_header_dir: self.write(' "%s",' % header_dir) self.write(' ],') - if self.runner.args.apex_available and crate_type in LIBRARY_CRATE_TYPES: + if crate_type in LIBRARY_CRATE_TYPES: self.write(' apex_available: [') - for apex in self.runner.args.apex_available: - self.write(' "%s",' % apex) + if self.runner.args.apex_available is None: + # If apex_available is not explicitly set, make it available to all + # apexes. + self.write(' "//apex_available:platform",') + self.write(' "//apex_available:anyapex",') + else: + for apex in self.runner.args.apex_available: + self.write(' "%s",' % apex) self.write(' ],') if crate_type != 'test': if self.runner.args.native_bridge_supported: