def test_omit_api(self) -> None: self.assertFalse( symbolfile.should_omit_symbol(symbolfile.Symbol('foo', []), Arch('arm'), 9, False, False)) self.assertFalse( symbolfile.should_omit_symbol( symbolfile.Symbol('foo', [Tag('introduced=9')]), Arch('arm'), 9, False, False)) self.assertTrue( symbolfile.should_omit_symbol( symbolfile.Symbol('foo', [Tag('introduced=14')]), Arch('arm'), 9, False, False))
def test_omit_arch(self) -> None: self.assertFalse( symbolfile.should_omit_symbol(symbolfile.Symbol('foo', []), Arch('arm'), 9, False, False)) self.assertFalse( symbolfile.should_omit_symbol( symbolfile.Symbol('foo', [Tag('arm')]), Arch('arm'), 9, False, False)) self.assertTrue( symbolfile.should_omit_symbol( symbolfile.Symbol('foo', [Tag('x86')]), Arch('arm'), 9, False, False))
def test_omit_api(self) -> None: self.assertFalse( symbolfile.should_omit_symbol(symbolfile.Symbol('foo', Tags()), Arch('arm'), 9, False, False)) self.assertFalse( symbolfile.should_omit_symbol( symbolfile.Symbol('foo', Tags.from_strs(['introduced=9'])), Arch('arm'), 9, False, False)) self.assertTrue( symbolfile.should_omit_symbol( symbolfile.Symbol('foo', Tags.from_strs(['introduced=14'])), Arch('arm'), 9, False, False))
def test_omit_arch(self) -> None: self.assertFalse( symbolfile.should_omit_symbol(symbolfile.Symbol('foo', Tags()), Arch('arm'), 9, False, False)) self.assertFalse( symbolfile.should_omit_symbol( symbolfile.Symbol('foo', Tags.from_strs(['arm'])), Arch('arm'), 9, False, False)) self.assertTrue( symbolfile.should_omit_symbol( symbolfile.Symbol('foo', Tags.from_strs(['x86'])), Arch('arm'), 9, False, False))
def write_version(self, version: Version) -> None: """Writes a single version block's data to the output files.""" if symbolfile.should_omit_version(version, self.arch, self.api, self.llndk, self.apex): return section_versioned = symbolfile.symbol_versioned_in_api( version.tags, self.api) version_empty = True pruned_symbols = [] for symbol in version.symbols: if symbolfile.should_omit_symbol(symbol, self.arch, self.api, self.llndk, self.apex): continue if symbolfile.symbol_versioned_in_api(symbol.tags, self.api): version_empty = False pruned_symbols.append(symbol) if len(pruned_symbols) > 0: 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: emit_version = symbolfile.symbol_versioned_in_api( symbol.tags, self.api) if section_versioned and emit_version: self.version_script.write(' ' + symbol.name + ';\n') weak = '' if 'weak' in symbol.tags: weak = '__attribute__((weak)) ' if 'var' in symbol.tags: self.src_file.write(f'{weak}int {symbol.name} = 0;\n') else: self.src_file.write(f'{weak}void {symbol.name}() {{}}\n') self.symbol_list.write(f'{symbol.name}\n') if not version_empty and section_versioned: base = '' if version.base is None else ' ' + version.base self.version_script.write('}' + base + ';\n')