Exemplo n.º 1
0
    def test_omit_api(self) -> None:
        self.assertFalse(
            symbolfile.should_omit_version(
                symbolfile.Version('foo', None, [], []), Arch('arm'), 9, False,
                False))
        self.assertFalse(
            symbolfile.should_omit_version(
                symbolfile.Version('foo', None, [Tag('introduced=9')], []),
                Arch('arm'), 9, False, False))

        self.assertTrue(
            symbolfile.should_omit_version(
                symbolfile.Version('foo', None, [Tag('introduced=14')], []),
                Arch('arm'), 9, False, False))
Exemplo n.º 2
0
    def test_omit_arch(self) -> None:
        self.assertFalse(
            symbolfile.should_omit_version(
                symbolfile.Version('foo', None, [], []), Arch('arm'), 9, False,
                False))
        self.assertFalse(
            symbolfile.should_omit_version(
                symbolfile.Version('foo', None, [Tag('arm')], []), Arch('arm'),
                9, False, False))

        self.assertTrue(
            symbolfile.should_omit_version(
                symbolfile.Version('foo', None, [Tag('x86')], []), Arch('arm'),
                9, False, False))
    def test_omit_arch(self) -> None:
        self.assertFalse(
            symbolfile.should_omit_version(
                symbolfile.Version('foo', None, Tags(), []), Arch('arm'), 9,
                False, False))
        self.assertFalse(
            symbolfile.should_omit_version(
                symbolfile.Version('foo', None, Tags.from_strs(['arm']), []),
                Arch('arm'), 9, False, False))

        self.assertTrue(
            symbolfile.should_omit_version(
                symbolfile.Version('foo', None, Tags.from_strs(['x86']), []),
                Arch('arm'), 9, False, False))
Exemplo n.º 4
0
    def test_omit_private(self) -> None:
        self.assertFalse(
            symbolfile.should_omit_version(
                symbolfile.Version('foo', None, [], []), Arch('arm'), 9, False,
                False))

        self.assertTrue(
            symbolfile.should_omit_version(
                symbolfile.Version('foo_PRIVATE', None, [], []), Arch('arm'),
                9, False, False))
        self.assertTrue(
            symbolfile.should_omit_version(
                symbolfile.Version('foo_PLATFORM', None, [], []), Arch('arm'),
                9, False, False))

        self.assertTrue(
            symbolfile.should_omit_version(
                symbolfile.Version('foo', None, [Tag('platform-only')], []),
                Arch('arm'), 9, False, False))
Exemplo n.º 5
0
    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')