Handle the case when a symbol is annotated with "# apex vndk"
This change fixes a bug that a symbol is omitted for apex (or vndk) when
it is annotated with "# vndk apex" (or "# apex vndk).
Bug: 123349183
Test: python3 test_gen_stub_libs.py
Change-Id: I344d6e70732bae8877cb16bbe881edb79fe90670
diff --git a/cc/gen_stub_libs.py b/cc/gen_stub_libs.py
index 4906ea2..81bc398 100755
--- a/cc/gen_stub_libs.py
+++ b/cc/gen_stub_libs.py
@@ -119,9 +119,12 @@
return True
if 'platform-only' in version.tags:
return True
- if 'vndk' in version.tags and not vndk:
- return True
- if 'apex' in version.tags and not apex:
+
+ no_vndk_no_apex = 'vndk' not in version.tags and 'apex' not in version.tags
+ keep = no_vndk_no_apex or \
+ ('vndk' in version.tags and vndk) or \
+ ('apex' in version.tags and apex)
+ if not keep:
return True
if not symbol_in_arch(version.tags, arch):
return True
@@ -132,9 +135,11 @@
def should_omit_symbol(symbol, arch, api, vndk, apex):
"""Returns True if the symbol should be omitted."""
- if not vndk and 'vndk' in symbol.tags:
- return True
- if not apex and 'apex' in symbol.tags:
+ no_vndk_no_apex = 'vndk' not in symbol.tags and 'apex' not in symbol.tags
+ keep = no_vndk_no_apex or \
+ ('vndk' in symbol.tags and vndk) or \
+ ('apex' in symbol.tags and apex)
+ if not keep:
return True
if not symbol_in_arch(symbol.tags, arch):
return True
diff --git a/cc/test_gen_stub_libs.py b/cc/test_gen_stub_libs.py
index 594c1bc..2ee9886 100755
--- a/cc/test_gen_stub_libs.py
+++ b/cc/test_gen_stub_libs.py
@@ -751,6 +751,8 @@
wibble;
wizzes; # vndk
waggle; # apex
+ bubble; # apex vndk
+ duddle; # vndk apex
} VERSION_2;
VERSION_5 { # versioned=14
@@ -771,6 +773,8 @@
void qux() {}
void wibble() {}
void waggle() {}
+ void bubble() {}
+ void duddle() {}
void wobble() {}
""")
self.assertEqual(expected_src, src_file.getvalue())
@@ -788,6 +792,8 @@
global:
wibble;
waggle;
+ bubble;
+ duddle;
} VERSION_2;
""")
self.assertEqual(expected_version, version_file.getvalue())