Exemplo n.º 1
0
    def test_non_ascii_output(self):
        with pkg_config_script("""print("-L'zażółć gęślą jaźń'")""") as command:
            flags = pkgconfig.cflags(['test-1.0'], command=command)
            self.assertEqual(flags, ["-Lzażółć gęślą jaźń"])

        with pkg_config_script("""print('-Lé')""") as command:
            flags = pkgconfig.cflags(['test-1.0'], command=command)
            self.assertEqual(flags, ['-Lé'])
Exemplo n.º 2
0
 def test_non_zero_exit_code(self):
     """Checks that non-zero exit code from pkg-config results in exception."""
     s = """
     import sys
     sys.exit(1)
     """
     with self.assertRaises(pkgconfig.PkgConfigError):
         with pkg_config_script(s) as command:
             pkgconfig.cflags(['foo'], command=command, ignore_errors=False)
Exemplo n.º 3
0
    def test_shell_word_splitting_rules(self):
        # Regression test for issue #171.
        with pkg_config_script("""print('-L"/usr/lib64" -lgit2')""") as command:
            flags = pkgconfig.cflags(['foo-2.0'], command=command)
            self.assertEqual(flags, ['-L/usr/lib64', '-lgit2'])

        # Macro define for a C string literal.
        with pkg_config_script('''print("""-DLOG='"HELLO"'""")''') as command:
            flags = pkgconfig.cflags(['bar-3.0'], command=command)
            self.assertEqual(flags, ['-DLOG="HELLO"'])
Exemplo n.º 4
0
 def test_cflags(self):
     """Checks arguments passed to pkg-config when asking for --cflags."""
     s = """
     import sys
     args = sys.argv[1:]
     assert len(args) == 4
     assert args[0] == '--cflags'
     assert args[1] == 'foo-1.0'
     assert args[2] == 'bar-2.0'
     assert args[3] == 'baz'
     """
     with pkg_config_script(s) as command:
         pkgconfig.cflags(['foo-1.0', 'bar-2.0', 'baz'], command=command)
Exemplo n.º 5
0
def process_packages(options, packages):
    flags = pkgconfig.cflags(packages)
    # Some pkg-config files on Windows have options we don't understand,
    # so we explicitly filter to only the ones we need.
    options_whitelist = ['-I', '-D', '-U', '-l', '-L']
    filtered_output = list(process_options(flags, options_whitelist))
    parser = _get_option_parser()
    pkg_options, unused = parser.parse_args(filtered_output)
    options.cpp_includes.extend([os.path.realpath(f) for f in pkg_options.cpp_includes])
    options.cpp_defines.extend(pkg_options.cpp_defines)
    options.cpp_undefines.extend(pkg_options.cpp_undefines)