Rename rust_defaults that contain tests.
This patch ensures that rust_defaults for tests have _tests in the
name. This can make the Android.bp file a bit more readable.
Test: Run on a crate and build it.
Change-Id: I5d034c456052b892bd01c3c041b2572bc9364692
diff --git a/scripts/cargo2android.py b/scripts/cargo2android.py
index 4f828e2..780a09b 100755
--- a/scripts/cargo2android.py
+++ b/scripts/cargo2android.py
@@ -554,11 +554,12 @@
def build_default_name(self):
"""Return a short and readable name for the rust_defaults module."""
- # Choices: (1) root_pkg + '_defaults',
- # (2) root_pkg + '_defaults_' + crate_name
- # (3) root_pkg + '_defaults_' + main_src_basename_path
- # (4) root_pkg + '_defaults_' + a_positive_sequence_number
- name1 = altered_defaults(self.root_pkg) + '_defaults'
+ # Choices: (1) root_pkg + '_test'? + '_defaults',
+ # (2) root_pkg + '_test'? + '_defaults_' + crate_name
+ # (3) root_pkg + '_test'? + '_defaults_' + main_src_basename_path
+ # (4) root_pkg + '_test'? + '_defaults_' + a_positive_sequence_number
+ test = "_test" if self.crate_types == ['test'] else ""
+ name1 = altered_defaults(self.root_pkg) + test + '_defaults'
if self.runner.try_claim_module_name(name1, self):
return name1
name2 = name1 + '_' + self.crate_name