コード例 #1
0
 def test_identity(self):
     self.env.library_mode = LibraryMode(True, True)
     expected = file_types.DualUseLibrary(
         file_types.SharedLibrary(Path('shared', Root.srcdir), None),
         file_types.StaticLibrary(Path('static', Root.srcdir), None)
     )
     self.assertIs(self.context['library'](expected), expected)
コード例 #2
0
 def test_convert_to_static(self):
     self.env.library_mode = LibraryMode(False, True)
     lib = file_types.DualUseLibrary(
         file_types.SharedLibrary(Path('shared', Root.srcdir), None),
         file_types.StaticLibrary(Path('static', Root.srcdir), None)
     )
     self.assertEqual(self.context['library'](lib), lib.static)
コード例 #3
0
 def test_convert_to_shared(self):
     self.env.library_mode = LibraryMode(True, False)
     lib = file_types.DualUseLibrary(
         file_types.SharedLibrary(Path('shared', Root.srcdir), None),
         file_types.StaticLibrary(Path('static', Root.srcdir), None))
     result = self.builtin_dict['library'](lib)
     self.assertEqual(result, lib.shared)
コード例 #4
0
    def test_libs(self):
        self.env.library_mode = LibraryMode(True, False)

        result = self.builtin_dict['object_file'](file='main.java', libs='lib')
        self.assertEqual(
            result.creator.libs,
            [file_types.StaticLibrary(Path('lib', Root.srcdir), 'java')])
コード例 #5
0
    def test_upgrade_from_v4(self):
        env = Environment.load(os.path.join(test_data_dir, 'environment',
                                            'v4'))

        self.assertEqual(env.bfgdir, Path('/path/to'))
        self.assertEqual(env.backend, 'make')

        self.assertEqual(env.srcdir, Path('/root/srcdir'))
        self.assertEqual(env.builddir, Path('/root/builddir'))
        self.assertDictsEqual(
            env.install_dirs, {
                InstallRoot.prefix: Path('/root/prefix'),
                InstallRoot.exec_prefix: Path('', InstallRoot.prefix),
                InstallRoot.bindir: Path('bin', InstallRoot.exec_prefix),
                InstallRoot.libdir: Path('lib', InstallRoot.exec_prefix),
                InstallRoot.includedir: Path('include', InstallRoot.prefix),
            })

        self.assertEqual(env.library_mode, LibraryMode(True, False))
        self.assertEqual(env.extra_args, [])

        variables = {u'HOME': u'/home/user'}
        self.assertEqual(env.variables, variables)

        self.assertEqual(env.host_platform.name, 'linux')
        self.assertEqual(env.target_platform.name, 'linux')
コード例 #6
0
    def test_upgrade_from_v4(self):
        env = Environment.load(os.path.join(test_data_dir, 'environment',
                                            'v4'))

        self.assertEqual(env.bfgdir, Path('/path/to', Root.absolute))
        self.assertEqual(env.backend, 'make')

        self.assertEqual(env.srcdir, Path('/root/srcdir', Root.absolute))
        self.assertEqual(env.builddir, Path('/root/builddir', Root.absolute))
        self.assertDictsEqual(
            env.install_dirs, {
                InstallRoot.prefix: Path('/root/prefix', Root.absolute),
                InstallRoot.exec_prefix: Path('', InstallRoot.prefix),
                InstallRoot.bindir: Path('bin', InstallRoot.exec_prefix),
                InstallRoot.libdir: Path('lib', InstallRoot.exec_prefix),
                InstallRoot.includedir: Path('include', InstallRoot.prefix),
            })

        self.assertEqual(env.library_mode, LibraryMode(True, False))
        self.assertEqual(env.extra_args, [])

        variables = {u'HOME': u'/home/user'}
        if platform_info().family == 'windows' and sys.version_info[0] == 2:
            variables = {str(k): str(v) for k, v in iteritems(variables)}
        self.assertEqual(env.variables, variables)

        self.assertEqual(env.host_platform.name, 'linux')
        self.assertEqual(env.target_platform.name, 'linux')
コード例 #7
0
 def test_convert_invalid_args(self):
     self.env.library_mode = LibraryMode(False, True)
     lib = file_types.DualUseLibrary(
         file_types.SharedLibrary(Path('shared', Root.srcdir), None),
         file_types.StaticLibrary(Path('static', Root.srcdir), None)
     )
     self.assertRaises(TypeError, self.context['library'], lib,
                       files=['foo.cpp'])
コード例 #8
0
    def test_src_file(self):
        self.env.library_mode = LibraryMode(True, True)
        expected = file_types.StaticLibrary(
            Path('library', Root.srcdir),
            self.env.target_platform.object_format, 'c')
        self.assertSameFile(self.context['library']('library'), expected)
        self.assertEqual(list(self.build.sources()), [self.bfgfile, expected])

        self.context['project'](lang='c++')
        expected.lang = 'c++'
        self.assertSameFile(self.context['library']('library'), expected)
コード例 #9
0
    def test_finalize(self):
        env = self.make_env()
        env.finalize({}, (True, False))
        self.assertEqual(env.library_mode, LibraryMode(True, False))
        self.assertEqual(env.install_dirs[InstallRoot.prefix], Path('/prefix'))
        self.assertEqual(env.install_dirs[InstallRoot.exec_prefix],
                         Path('/exec-prefix'))

        env = self.make_env()
        env.finalize(
            {
                InstallRoot.prefix: Path('/foo'),
                InstallRoot.exec_prefix: None,
            }, (True, False))
        self.assertEqual(env.install_dirs[InstallRoot.prefix], Path('/foo'))
        self.assertEqual(env.install_dirs[InstallRoot.exec_prefix],
                         Path('/exec-prefix'))
コード例 #10
0
 def test_no_library(self):
     self.env.library_mode = LibraryMode(False, False)
     self.assertRaises(ValueError, self.context['library'], 'library',
                       files=['foo.cpp'])
コード例 #11
0
 def test_src_file(self):
     self.env.library_mode = LibraryMode(True, True)
     expected = file_types.StaticLibrary(
         Path('library', Root.srcdir),
         self.env.target_platform.object_format, 'c')
     self.assertSameFile(self.builtin_dict['library']('library'), expected)
コード例 #12
0
 def test_no_library(self):
     self.env.library_mode = LibraryMode(False, False)
     self.assertRaises(ValueError, self.builtin_dict['library'], 'library')
コード例 #13
0
 def test_src_file(self):
     self.env.library_mode = LibraryMode(True, True)
     result = self.builtin_dict['library']('library')
     self.assertEqual(
         result, file_types.StaticLibrary(Path('library', Root.srcdir),
                                          None))