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
This commit is contained in:
Matthew Maurer
2022-06-16 13:07:12 -07:00
parent e1d07ba872
commit a9fb65d155

View File

@@ -709,10 +709,16 @@ class Crate(object):
for header_dir in self.runner.args.exported_c_header_dir: for header_dir in self.runner.args.exported_c_header_dir:
self.write(' "%s",' % header_dir) self.write(' "%s",' % header_dir)
self.write(' ],') 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: [') self.write(' apex_available: [')
for apex in self.runner.args.apex_available: if self.runner.args.apex_available is None:
self.write(' "%s",' % apex) # 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(' ],') self.write(' ],')
if crate_type != 'test': if crate_type != 'test':
if self.runner.args.native_bridge_supported: if self.runner.args.native_bridge_supported: