Add --no-ndk to ndkstubgen

By default, ndkstubgen does not omit NDK symbols as long as they
satisfy the API version and the CPU architecture requirements. This
change adds a new flag --no-ndk to ndkstubgen which is used to
override the default behavior. If the flag is set, NDK symbols are
omitted leaving only the annotated symbols (e.g. #apex, #systemapi,
etc.).

This will be used for stub libraries that are not part of NDK. So far,
symbols in such libraries haven't needed to be annotated as #apex, and
that has caused a confusion that those symbols belong to NDK. The
follow-up change will ensure that those symbols are always annoated as
either #apex or #systemapi so that their roles are clearly visible.

Bug: 184712170
Test: atest test_ndkstubgen
Test: atest test_symbolfile
Change-Id: Ic8d2c7d0b32bdef79f7563621035e60f406e4131
diff --git a/cc/ndkstubgen/test_ndkstubgen.py b/cc/ndkstubgen/test_ndkstubgen.py
index 450719b..1e0bdf3 100755
--- a/cc/ndkstubgen/test_ndkstubgen.py
+++ b/cc/ndkstubgen/test_ndkstubgen.py
@@ -424,6 +424,45 @@
         """)
         self.assertEqual(expected_version, version_file.getvalue())
 
+    def test_integration_with_nondk(self) -> None:
+        input_file = io.StringIO(textwrap.dedent("""\
+            VERSION_1 {
+                global:
+                    foo;
+                    bar; # apex
+                local:
+                    *;
+            };
+        """))
+        f = copy(self.filter)
+        f.apex = True
+        f.ndk = False   # ndk symbols should be excluded
+        parser = symbolfile.SymbolFileParser(input_file, {}, f)
+        versions = parser.parse()
+
+        src_file = io.StringIO()
+        version_file = io.StringIO()
+        symbol_list_file = io.StringIO()
+        f = copy(self.filter)
+        f.apex = True
+        f.ndk = False   # ndk symbols should be excluded
+        generator = ndkstubgen.Generator(src_file,
+                                         version_file, symbol_list_file, f)
+        generator.write(versions)
+
+        expected_src = textwrap.dedent("""\
+            void bar() {}
+        """)
+        self.assertEqual(expected_src, src_file.getvalue())
+
+        expected_version = textwrap.dedent("""\
+            VERSION_1 {
+                global:
+                    bar;
+            };
+        """)
+        self.assertEqual(expected_version, version_file.getvalue())
+
     def test_empty_stub(self) -> None:
         """Tests that empty stubs can be generated.