Merge changes I21f54c67,I41f6e493,I6f2ae636 am: 3a5af487f2

am: 9ac9847f0b

Change-Id: Iac7953e87766d1859492f0239c6baca1c53ff5bd
This commit is contained in:
Dan Albert
2016-08-01 23:13:22 +00:00
committed by android-build-merger
2 changed files with 35 additions and 8 deletions

View File

@@ -65,12 +65,34 @@ class Stack(object):
return self.stack[-1] return self.stack[-1]
def get_tags(line):
"""Returns a list of all tags on this line."""
_, _, all_tags = line.strip().partition('#')
return re.split(r'\s+', all_tags)
def version_is_private(version): def version_is_private(version):
"""Returns True if the version name should be treated as private.""" """Returns True if the version name should be treated as private."""
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.')
@@ -78,7 +100,8 @@ def enter_version(scope, line, version_file):
# Entering a new version block. By convention symbols with versions ending # Entering a new version block. By convention symbols with versions ending
# 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()
if version_is_private(version_name): tags = get_tags(line)
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.
@@ -116,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)
@@ -166,6 +189,11 @@ def symbol_in_version(tags, arch, version):
elif tag.startswith('introduced-' + arch + '='): elif tag.startswith('introduced-' + arch + '='):
introduced_tag = tag introduced_tag = tag
arch_specific = True arch_specific = True
elif tag == 'future':
# This symbol is not in any released API level.
# TODO(danalbert): These need to be emitted for version == current.
# That's not a construct we have yet, so just skip it for now.
return False
if introduced_tag is None: if introduced_tag is None:
# We found no "introduced" tags, so the symbol has always been # We found no "introduced" tags, so the symbol has always been
@@ -194,8 +222,7 @@ def handle_global_scope(scope, line, src_file, version_file, arch, api):
# Line is now in the format "<symbol-name>; # tags" # Line is now in the format "<symbol-name>; # tags"
# Tags are whitespace separated. # Tags are whitespace separated.
symbol_name, _, rest = line.strip().partition(';') symbol_name, _, rest = line.strip().partition(';')
_, _, all_tags = rest.partition('#') tags = get_tags(line)
tags = re.split(r'\s+', all_tags)
if not symbol_in_arch(tags, arch): if not symbol_in_arch(tags, arch):
return return
@@ -217,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:

View File

@@ -38,7 +38,7 @@ load-plugins=
# --enable=similarities". If you want to run only the classes checker, but have # --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use"--disable=all --enable=classes # no Warning level messages displayed, use"--disable=all --enable=classes
# --disable=W" # --disable=W"
disable=design disable=design,fixme
[REPORTS] [REPORTS]