Ejemplo n.º 1
0
    def test_flags_rpath(self):
        p1 = Path('path1')
        p2 = Path('path2')

        self.assertEqual(
            self.linker.flags(opts.option_list(opts.rpath_dir(p1))),
            ['-Wl,-rpath,' + p1])

        self.assertEqual(
            self.linker.flags(
                opts.option_list(opts.rpath_dir(p1), opts.rpath_dir(p2))),
            ['-Wl,-rpath,' + p1 + ':' + p2])
Ejemplo n.º 2
0
    def test_link_options_elf_uninst(self):
        linker = AttrDict(flavor='gcc', builder=AttrDict(object_format='elf'))
        with mock.patch('bfg9000.shell.execute', mock_execute_uninst):
            pkg = PkgConfigPackage('foo', 'elf', SpecifierSet(''),
                                   PackageKind.shared, self.tool)

            self.assertEqual(
                pkg.link_options(linker),
                opts.option_list(
                    '-L/path/to/build/foo', opts.lib_literal('-lfoo'),
                    opts.rpath_dir(Path('/path/to/build/foo'), 'uninstalled'),
                    opts.rpath_dir(Path('/usr/lib'), 'installed')))
Ejemplo n.º 3
0
    def test_link_options_elf_uninst(self):
        linker = AttrDict(flavor='gcc', builder=AttrDict(object_format='elf'))
        with mock.patch('bfg9000.shell.execute', mock_execute_uninst):
            pkg = PkgConfigPackage(self.tool, 'foo', format='elf')

            self.assertEqual(
                pkg.link_options(linker),
                opts.option_list(
                    '-pthread',
                    opts.lib_dir(Directory(Path('/path/to/build/foo'))),
                    opts.lib_literal('-lfoo'),
                    opts.rpath_dir(Path('/path/to/build/foo'), 'uninstalled'),
                    opts.rpath_dir(Path('/usr/lib'), 'installed')))
Ejemplo n.º 4
0
    def test_post_installed_linux(self):
        output = self._get_output_file()
        shared = SharedLibrary(self.Path('libfoo.so'), 'native')
        shared_abs = SharedLibrary(self.Path('/path/to/libfoo.so'), 'native')
        static = StaticLibrary(self.Path('libfoo.a'), 'native')

        install_outputs = MockInstallOutputs(self.env)
        with mock.patch('bfg9000.shell.which', return_value=['command']):
            # Local shared lib
            fn = self.linker.post_install(opts.option_list(opts.lib(shared)),
                                          output, None)
            self.assertEqual(fn(install_outputs), [
                self.env.tool('patchelf'), '--set-rpath',
                self.Path('', InstallRoot.libdir),
                installify(output).path
            ])

            # Absolute shared lib
            fn = self.linker.post_install(
                opts.option_list(opts.lib(shared_abs)), output, None)
            self.assertEqual(fn(install_outputs), None)

            # Local static lib
            fn = self.linker.post_install(opts.option_list(opts.lib(static)),
                                          output, None)
            self.assertEqual(fn(install_outputs), None)

            # Explicit rpath dir
            fn = self.linker.post_install(
                opts.option_list(opts.rpath_dir(self.Path('/path'))), output,
                None)
            self.assertEqual(fn(install_outputs), None)

            # Mixed
            fn = self.linker.post_install(
                opts.option_list(opts.lib(shared), opts.lib(shared_abs),
                                 opts.lib(static),
                                 opts.rpath_dir(self.Path('/path')),
                                 opts.rpath_dir(self.Path('/path/to'))),
                output, None)
            self.assertEqual(fn(install_outputs), [
                self.env.tool('patchelf'), '--set-rpath',
                (self.Path('', InstallRoot.libdir) + ':' +
                 self.Path('/path/to') + ':' + self.Path('/path')),
                installify(output).path
            ])
Ejemplo n.º 5
0
    def test_installed_rpaths(self):
        output = Executable(self.Path('program'), 'native')

        # Local shared lib
        rpaths = self.linker._installed_rpaths(
            opts.option_list(
                opts.lib(SharedLibrary(self.Path('libfoo.so'), 'native'))),
            output)
        self.assertEqual(rpaths, [self.Path('', InstallRoot.libdir)])

        # Absolute shared lib
        rpaths = self.linker._installed_rpaths(
            opts.option_list(
                opts.lib(
                    SharedLibrary(self.Path('/path/to/libfoo.so'), 'native'))),
            output)
        self.assertEqual(rpaths, [])

        # Local static lib
        rpaths = self.linker._installed_rpaths(
            opts.option_list(
                opts.lib(StaticLibrary(self.Path('libfoo.a'), 'native'))),
            output)
        self.assertEqual(rpaths, [])

        # Explicit rpath dir
        rpaths = self.linker._installed_rpaths(
            opts.option_list(opts.rpath_dir(self.Path('/path'))), output)
        self.assertEqual(rpaths, [])

        # Mixed
        rpaths = self.linker._installed_rpaths(
            opts.option_list(
                opts.lib(SharedLibrary(self.Path('libfoo.so'), 'native')),
                opts.lib(
                    SharedLibrary(self.Path('/path/to/libfoo.so'), 'native')),
                opts.lib(StaticLibrary(self.Path('libfoo.a'), 'native')),
                opts.rpath_dir(self.Path('/path')),
                opts.rpath_dir(self.Path('/path/to'))), output)
        self.assertEqual(rpaths, [
            self.Path('', InstallRoot.libdir),
            self.Path('/path/to'),
            self.Path('/path')
        ])
Ejemplo n.º 6
0
 def check_package(self, pkg):
     self.assertEqual(pkg.name, 'foo')
     self.assertEqual(pkg.compile_options(self.compiler), option_list(
         '/DMACRO', opts.include_dir(HeaderDirectory(Path('/path')))
     ))
     self.assertEqual(pkg.link_options(self.linker), option_list(
         '/DEBUG', opts.lib_dir(Directory(Path('/path'))),
         opts.lib_literal('foo.lib'),
         (opts.rpath_dir(Path('/path')) if self.platform_name == 'linux'
          else None)
     ))