Support versioned=%d at the section level. am: ae452ccb7f am: 236e832237

am: 7f4d23d90a

Change-Id: Ifd126ee9c83dab12c1e50d965a7b937615dc0094
This commit is contained in:
Dan Albert 2017-01-04 19:11:16 +00:00 committed by android-build-merger
commit e60a1d355c
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())