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
This commit is contained in:
@@ -76,7 +76,23 @@ def version_is_private(version):
|
|||||||
return version.endswith('_PRIVATE') or version.endswith('_PLATFORM')
|
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."""
|
"""Enters a new version block scope."""
|
||||||
if scope.top != Scope.Top:
|
if scope.top != Scope.Top:
|
||||||
raise RuntimeError('Encountered nested version block.')
|
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.
|
# with "_PRIVATE" or "_PLATFORM" are not included in the NDK.
|
||||||
version_name = line.split('{')[0].strip()
|
version_name = line.split('{')[0].strip()
|
||||||
tags = get_tags(line)
|
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)
|
scope.push(Scope.Private)
|
||||||
else:
|
else:
|
||||||
scope.push(Scope.Global) # By default symbols are visible.
|
scope.push(Scope.Global) # By default symbols are visible.
|
||||||
@@ -123,10 +139,10 @@ def leave_visibility(scope):
|
|||||||
assert scope.top == Scope.Top
|
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."""
|
"""Processes a line in the top level scope."""
|
||||||
if '{' in line:
|
if '{' in line:
|
||||||
enter_version(scope, line, version_file)
|
enter_version(scope, line, version_file, arch, api)
|
||||||
else:
|
else:
|
||||||
raise RuntimeError('Unexpected contents at top level: ' + line)
|
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('#'):
|
if line.strip() == '' or line.strip().startswith('#'):
|
||||||
version_file.write(line)
|
version_file.write(line)
|
||||||
elif scope.top == Scope.Top:
|
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:
|
elif scope.top == Scope.Private:
|
||||||
handle_private_scope(scope, line, version_file)
|
handle_private_scope(scope, line, version_file)
|
||||||
elif scope.top == Scope.Local:
|
elif scope.top == Scope.Local:
|
||||||
|
Reference in New Issue
Block a user