Ignore 'extern "C++"' section in a version script
This allows creating extern "C++" {} sections in version script in order
to export some of private platform symbols from NDK libraries.
Example for context: 3a11413a25/libs/nativewindow/include/private/android/AHardwareBufferHelpers.h
Bug: http://b/69603741
Test: make
Change-Id: I2f9e6678c0a6cd90113543e890786876d4c3e992
This commit is contained in:
parent
cf31fcfc71
commit
2be7fa991c
1 changed files with 14 additions and 8 deletions
|
@ -244,6 +244,7 @@ class SymbolFileParser(object):
|
||||||
tags = decode_api_level_tags(tags, self.api_map)
|
tags = decode_api_level_tags(tags, self.api_map)
|
||||||
symbols = []
|
symbols = []
|
||||||
global_scope = True
|
global_scope = True
|
||||||
|
cpp_symbols = False
|
||||||
while self.next_line() != '':
|
while self.next_line() != '':
|
||||||
if '}' in self.current_line:
|
if '}' in self.current_line:
|
||||||
# Line is something like '} BASE; # tags'. Both base and tags
|
# Line is something like '} BASE; # tags'. Both base and tags
|
||||||
|
@ -252,12 +253,17 @@ class SymbolFileParser(object):
|
||||||
base = base.partition('#')[0].strip()
|
base = base.partition('#')[0].strip()
|
||||||
if not base.endswith(';'):
|
if not base.endswith(';'):
|
||||||
raise ParseError(
|
raise ParseError(
|
||||||
'Unterminated version block (expected ;).')
|
'Unterminated version/export "C++" block (expected ;).')
|
||||||
base = base.rstrip(';').rstrip()
|
if cpp_symbols:
|
||||||
if base == '':
|
cpp_symbols = False
|
||||||
base = None
|
else:
|
||||||
return Version(name, base, tags, symbols)
|
base = base.rstrip(';').rstrip()
|
||||||
elif ':' in self.current_line:
|
if base == '':
|
||||||
|
base = None
|
||||||
|
return Version(name, base, tags, symbols)
|
||||||
|
elif 'extern "C++" {' in self.current_line:
|
||||||
|
cpp_symbols = True
|
||||||
|
elif not cpp_symbols and ':' in self.current_line:
|
||||||
visibility = self.current_line.split(':')[0].strip()
|
visibility = self.current_line.split(':')[0].strip()
|
||||||
if visibility == 'local':
|
if visibility == 'local':
|
||||||
global_scope = False
|
global_scope = False
|
||||||
|
@ -265,10 +271,10 @@ class SymbolFileParser(object):
|
||||||
global_scope = True
|
global_scope = True
|
||||||
else:
|
else:
|
||||||
raise ParseError('Unknown visiblity label: ' + visibility)
|
raise ParseError('Unknown visiblity label: ' + visibility)
|
||||||
elif global_scope:
|
elif global_scope and not cpp_symbols:
|
||||||
symbols.append(self.parse_symbol())
|
symbols.append(self.parse_symbol())
|
||||||
else:
|
else:
|
||||||
# We're in a hidden scope. Ignore everything.
|
# We're in a hidden scope or in 'extern "C++"' block. Ignore everything.
|
||||||
pass
|
pass
|
||||||
raise ParseError('Unexpected EOF in version block.')
|
raise ParseError('Unexpected EOF in version block.')
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue