예제 #1
0
    def test_post_installed_macos(self):
        output = self._get_output_file()
        installed = installify(output).path
        deplib = SharedLibrary(self.Path('libfoo.so'), 'native')

        install_outputs = MockInstallOutputs(self.env)
        with mock.patch('bfg9000.shell.which', return_value=['command']):
            install_name_tool = self.env.tool('install_name_tool')

            # No runtime deps
            fn = self.linker.post_install(opts.option_list(), output, None)
            self.assertEqual(fn(install_outputs), [
                install_name_tool, '-id', installed.cross(self.env), installed
            ] if self.shared else None)

            fn = self.linker.post_install(opts.option_list(
                opts.install_name_change('old.dylib', 'new.dylib')
            ), output, None)
            self.assertEqual(fn(install_outputs), (
                [install_name_tool] +
                (['-id', installed.cross(self.env)] if self.shared else []) +
                ['-change', 'old.dylib', 'new.dylib', installed]
            ))

            # Dependent on local shared lib
            output.runtime_deps = [deplib]
            fn = self.linker.post_install(
                opts.option_list(opts.lib(deplib)), output, None
            )
            self.assertEqual(fn(install_outputs), (
                [install_name_tool] +
                (['-id', installed.cross(self.env)] if self.shared else []) +
                ['-change', deplib.path.string(self.env.base_dirs),
                 installify(deplib, cross=self.env).path, installed]
            ))
예제 #2
0
    def test_link_options_macho_requires(self):
        linker = AttrDict(flavor='gcc',
                          builder=AttrDict(object_format='mach-o'))
        with mock.patch('bfg9000.shell.execute', mock_execute_requires):
            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.install_name_change('/path/to/build/foo/libfoo.dylib',
                                             '/usr/lib/libfoo.dylib'),
                    opts.install_name_change('/path/to/build/bar/libbar.dylib',
                                             '/usr/lib/libbar.dylib'),
                    opts.install_name_change('/path/to/build/baz/libbaz.dylib',
                                             '/usr/lib/libbaz.dylib'),
                ))
예제 #3
0
 def test_executable(self):
     self.assertEqual(
         post_install(
             self.env,
             opts.option_list(
                 opts.install_name_change('/lib/libfoo.dylib',
                                          '/lib/libbar.dylib')), self.exe,
             self.install_db),
         [
             self.tool, '-change', '/lib/libfoo.dylib', '/lib/libbar.dylib',
             Path('exe', InstallRoot.bindir, True)
         ])
예제 #4
0
    def test_link_options_macho_uninst(self):
        linker = AttrDict(flavor='gcc',
                          builder=AttrDict(object_format='mach-o'))
        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.install_name_change('/path/to/build/foo/libfoo.dylib',
                                             '/usr/lib/libfoo.dylib')))
예제 #5
0
 def test_flags_install_name_change(self):
     self.assertEqual(
         self.linker.flags(
             opts.option_list(
                 opts.install_name_change('foo.dylib', 'bar.dylib'))), [])