aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordimitry <dimitry@google.com>2017-11-21 17:47:33 +0100
committerdimitry <dimitry@google.com>2017-11-21 20:31:48 +0100
commit2be7fa991c0b2a176ff5eb489f408f7e21ae849e (patch)
tree6c64b698ed85b45f3815a023cc7ca775b0299779
parentcf31fcfc71918c2b9c2d5d78dde819a719712806 (diff)
downloadandroid_build_soong-2be7fa991c0b2a176ff5eb489f408f7e21ae849e.tar.gz
android_build_soong-2be7fa991c0b2a176ff5eb489f408f7e21ae849e.tar.bz2
android_build_soong-2be7fa991c0b2a176ff5eb489f408f7e21ae849e.zip
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: https://android.googlesource.com/platform/frameworks/native/+/3a11413a2584cf9a51e4315bef27546f602578fb/libs/nativewindow/include/private/android/AHardwareBufferHelpers.h Bug: http://b/69603741 Test: make Change-Id: I2f9e6678c0a6cd90113543e890786876d4c3e992
-rwxr-xr-xcc/gen_stub_libs.py22
1 files changed, 14 insertions, 8 deletions
diff --git a/cc/gen_stub_libs.py b/cc/gen_stub_libs.py
index abb39c2a..8c99bbf3 100755
--- a/cc/gen_stub_libs.py
+++ b/cc/gen_stub_libs.py
@@ -244,6 +244,7 @@ class SymbolFileParser(object):
tags = decode_api_level_tags(tags, self.api_map)
symbols = []
global_scope = True
+ cpp_symbols = False
while self.next_line() != '':
if '}' in self.current_line:
# Line is something like '} BASE; # tags'. Both base and tags
@@ -252,12 +253,17 @@ class SymbolFileParser(object):
base = base.partition('#')[0].strip()
if not base.endswith(';'):
raise ParseError(
- 'Unterminated version block (expected ;).')
- base = base.rstrip(';').rstrip()
- if base == '':
- base = None
- return Version(name, base, tags, symbols)
- elif ':' in self.current_line:
+ 'Unterminated version/export "C++" block (expected ;).')
+ if cpp_symbols:
+ cpp_symbols = False
+ else:
+ base = base.rstrip(';').rstrip()
+ 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()
if visibility == 'local':
global_scope = False
@@ -265,10 +271,10 @@ class SymbolFileParser(object):
global_scope = True
else:
raise ParseError('Unknown visiblity label: ' + visibility)
- elif global_scope:
+ elif global_scope and not cpp_symbols:
symbols.append(self.parse_symbol())
else:
- # We're in a hidden scope. Ignore everything.
+ # We're in a hidden scope or in 'extern "C++"' block. Ignore everything.
pass
raise ParseError('Unexpected EOF in version block.')