aboutsummaryrefslogtreecommitdiffstats
path: root/cc/gen_stub_libs.py
diff options
context:
space:
mode:
authorDan Albert <danalbert@google.com>2016-07-28 18:09:47 -0700
committerDan Albert <danalbert@google.com>2016-08-01 16:04:37 -0700
commit08532b6779281c3a5f4d4166914a26b047cd3459 (patch)
tree463a83ba794f45d47648e3ad99737d910334a78d /cc/gen_stub_libs.py
parenta85042a040e10e912a3bcd282e5cc75030b26a0b (diff)
downloadbuild_soong-08532b6779281c3a5f4d4166914a26b047cd3459.tar.gz
build_soong-08532b6779281c3a5f4d4166914a26b047cd3459.tar.bz2
build_soong-08532b6779281c3a5f4d4166914a26b047cd3459.zip
Allow more symbol file tags at top level.
A version block might need to be omitted for reasons beyond just "future". Support all the same tags we do at symbol scope. Test: `make ndk` with libc/libm migration patches. Change-Id: I21f54c67079dae10fee1e5e08bcd01f8810e7a67
Diffstat (limited to 'cc/gen_stub_libs.py')
-rwxr-xr-xcc/gen_stub_libs.py26
1 files changed, 21 insertions, 5 deletions
diff --git a/cc/gen_stub_libs.py b/cc/gen_stub_libs.py
index 78544c39..4b7c244e 100755
--- a/cc/gen_stub_libs.py
+++ b/cc/gen_stub_libs.py
@@ -76,7 +76,23 @@ def version_is_private(version):
return version.endswith('_PRIVATE') or version.endswith('_PLATFORM')
-def enter_version(scope, line, version_file):
+def should_omit_version(name, tags, arch, api):
+ """Returns True if the version section should be ommitted.
+
+ We want to omit any sections that do not have any symbols we'll have in the
+ stub library. Sections that contain entirely future symbols or only symbols
+ for certain architectures.
+ """
+ if version_is_private(name):
+ return True
+ if not symbol_in_arch(tags, arch):
+ return True
+ if not symbol_in_version(tags, arch, api):
+ return True
+ return False
+
+
+def enter_version(scope, line, version_file, arch, api):
"""Enters a new version block scope."""
if scope.top != Scope.Top:
raise RuntimeError('Encountered nested version block.')
@@ -85,7 +101,7 @@ def enter_version(scope, line, version_file):
# with "_PRIVATE" or "_PLATFORM" are not included in the NDK.
version_name = line.split('{')[0].strip()
tags = get_tags(line)
- if version_is_private(version_name) or 'future' in tags:
+ if should_omit_version(version_name, tags, arch, api):
scope.push(Scope.Private)
else:
scope.push(Scope.Global) # By default symbols are visible.
@@ -123,10 +139,10 @@ def leave_visibility(scope):
assert scope.top == Scope.Top
-def handle_top_scope(scope, line, version_file):
+def handle_top_scope(scope, line, version_file, arch, api):
"""Processes a line in the top level scope."""
if '{' in line:
- enter_version(scope, line, version_file)
+ enter_version(scope, line, version_file, arch, api)
else:
raise RuntimeError('Unexpected contents at top level: ' + line)
@@ -228,7 +244,7 @@ def generate(symbol_file, src_file, version_file, arch, api):
if line.strip() == '' or line.strip().startswith('#'):
version_file.write(line)
elif scope.top == Scope.Top:
- handle_top_scope(scope, line, version_file)
+ handle_top_scope(scope, line, version_file, arch, api)
elif scope.top == Scope.Private:
handle_private_scope(scope, line, version_file)
elif scope.top == Scope.Local: