Add support for weak symbols in the NDK stubs.
Test: nose2 Bug: None Change-Id: I202f718103f4a645b1eb83c0a9f5313bcdb4d485
This commit is contained in:
@@ -347,10 +347,16 @@ class Generator(object):
|
|||||||
if section_versioned and emit_version:
|
if section_versioned and emit_version:
|
||||||
self.version_script.write(' ' + symbol.name + ';\n')
|
self.version_script.write(' ' + symbol.name + ';\n')
|
||||||
|
|
||||||
|
weak = ''
|
||||||
|
if 'weak' in symbol.tags:
|
||||||
|
weak = '__attribute__((weak)) '
|
||||||
|
|
||||||
if 'var' in symbol.tags:
|
if 'var' in symbol.tags:
|
||||||
self.src_file.write('int {} = 0;\n'.format(symbol.name))
|
self.src_file.write('{}int {} = 0;\n'.format(
|
||||||
|
weak, symbol.name))
|
||||||
else:
|
else:
|
||||||
self.src_file.write('void {}() {{}}\n'.format(symbol.name))
|
self.src_file.write('{}void {}() {{}}\n'.format(
|
||||||
|
weak, symbol.name))
|
||||||
|
|
||||||
if not version_empty and section_versioned:
|
if not version_empty and section_versioned:
|
||||||
base = '' if version.base is None else ' ' + version.base
|
base = '' if version.base is None else ' ' + version.base
|
||||||
|
@@ -430,6 +430,8 @@ class GeneratorTest(unittest.TestCase):
|
|||||||
gsl.Version('VERSION_1', None, [], [
|
gsl.Version('VERSION_1', None, [], [
|
||||||
gsl.Symbol('foo', []),
|
gsl.Symbol('foo', []),
|
||||||
gsl.Symbol('bar', ['var']),
|
gsl.Symbol('bar', ['var']),
|
||||||
|
gsl.Symbol('woodly', ['weak']),
|
||||||
|
gsl.Symbol('doodly', ['weak', 'var']),
|
||||||
]),
|
]),
|
||||||
gsl.Version('VERSION_2', 'VERSION_1', [], [
|
gsl.Version('VERSION_2', 'VERSION_1', [], [
|
||||||
gsl.Symbol('baz', []),
|
gsl.Symbol('baz', []),
|
||||||
@@ -443,6 +445,8 @@ class GeneratorTest(unittest.TestCase):
|
|||||||
expected_src = textwrap.dedent("""\
|
expected_src = textwrap.dedent("""\
|
||||||
void foo() {}
|
void foo() {}
|
||||||
int bar = 0;
|
int bar = 0;
|
||||||
|
__attribute__((weak)) void woodly() {}
|
||||||
|
__attribute__((weak)) int doodly = 0;
|
||||||
void baz() {}
|
void baz() {}
|
||||||
void qux() {}
|
void qux() {}
|
||||||
""")
|
""")
|
||||||
@@ -453,6 +457,8 @@ class GeneratorTest(unittest.TestCase):
|
|||||||
global:
|
global:
|
||||||
foo;
|
foo;
|
||||||
bar;
|
bar;
|
||||||
|
woodly;
|
||||||
|
doodly;
|
||||||
};
|
};
|
||||||
VERSION_2 {
|
VERSION_2 {
|
||||||
global:
|
global:
|
||||||
|
Reference in New Issue
Block a user