Support versioned=%d at the section level.

Test: nose2
Bug: https://github.com/android-ndk/ndk/issues/265
Change-Id: I4c22cb8069f41861613ecf01f7e1adbe1d3118a9
This commit is contained in:
Dan Albert 2017-01-03 14:27:41 -08:00
parent 3340d6091c
commit ae452ccb7f
2 changed files with 19 additions and 3 deletions

View File

@ -289,6 +289,7 @@ class Generator(object):
if should_omit_version(name, tags, self.arch, self.api):
return
section_versioned = symbol_versioned_in_api(tags, self.api)
version_empty = True
pruned_symbols = []
for symbol in version.symbols:
@ -302,11 +303,12 @@ class Generator(object):
pruned_symbols.append(symbol)
if len(pruned_symbols) > 0:
if not version_empty:
if not version_empty and section_versioned:
self.version_script.write(version.name + ' {\n')
self.version_script.write(' global:\n')
for symbol in pruned_symbols:
if symbol_versioned_in_api(symbol.tags, self.api):
emit_version = symbol_versioned_in_api(symbol.tags, self.api)
if section_versioned and emit_version:
self.version_script.write(' ' + symbol.name + ';\n')
if 'var' in symbol.tags:
@ -314,7 +316,7 @@ class Generator(object):
else:
self.src_file.write('void {}() {{}}\n'.format(symbol.name))
if not version_empty:
if not version_empty and section_versioned:
base = '' if version.base is None else ' ' + version.base
self.version_script.write('}' + base + ';\n')

View File

@ -407,6 +407,14 @@ class IntegrationTest(unittest.TestCase):
woodly;
doodly; # var
} VERSION_2;
VERSION_4 { # versioned=9
wibble;
} VERSION_2;
VERSION_5 { # versioned=14
wobble;
} VERSION_4;
"""))
parser = gsl.SymbolFileParser(input_file)
versions = parser.parse()
@ -420,6 +428,8 @@ class IntegrationTest(unittest.TestCase):
int foo = 0;
void baz() {}
void qux() {}
void wibble() {}
void wobble() {}
""")
self.assertEqual(expected_src, src_file.getvalue())
@ -432,6 +442,10 @@ class IntegrationTest(unittest.TestCase):
global:
baz;
} VERSION_1;
VERSION_4 {
global:
wibble;
} VERSION_2;
""")
self.assertEqual(expected_version, version_file.getvalue())