Commit Graph

55 Commits

Author SHA1 Message Date
Aleksey Filippov d6b5d7fe9f Add library with generated_pc and PkgConfigDependency support to pkgconfig.generate() 2018-02-24 23:41:08 +00:00
Aleksey Filippov be6cedb491 Use listify(unholder=True) instead of manual unwrapping 2018-02-24 21:22:04 +00:00
Aleksey Filippov 02bd4be0e6 Fix misprint in pkgconfig comment 2018-02-23 00:24:16 +00:00
Xavier Claessens 6e2e94c645 pkgconfig: Also ignore not found deps passed directly to pc generator
Currently only not found deps implicitly pulled from a Library object
are ignored. We should also ignore not found deps passed directly to
generate() method.

This makes the unit testing more complicated because libfoo pkgconfig
dependency cannot be found when generated from the within the same
meson.build.
2018-01-19 13:45:14 -05:00
Jussi Pakkanen 5e4538fe63 Add external dependencies to pc files only if found. Closes #2911. 2018-01-19 15:49:49 +02:00
Xavier Claessens 68eedc8b71 pkgconfig: Rename DepsHolder to DependenciesHelper 2017-12-21 16:45:36 -05:00
Xavier Claessens 49977686b5 pkgconfig: Use the pc file we generated for libraries 2017-12-20 19:09:08 -05:00
Xavier Claessens 9e541a0fff pkgconfig: Avoid duplicated -L flags 2017-12-20 19:09:08 -05:00
Xavier Claessens 1c0570906c pkgconfig: Allow passing Dependency objects to library(_private)
Special case ThreadDependency by taking compiler's flags and
PkgConfigDependency by adding them in requires(.private) instead. For
other Dependency objects just take their link_args and compile_args.

Closes #2725
2017-12-20 19:09:08 -05:00
Iñigo Martínez 638077181a pkgconfig: Handle prefix in library path
The install_dir parameter of the libraries can also contain the
prefix path, which creates wrong library paths in the .pc file.

This patch detects if prefix is contained in the library path
and creates a relative path.

Fixes #2469
2017-11-19 18:20:21 +02:00
Nirbheek Chauhan 4fb978e1f7 pkgconfig module: Escape all paths while generating
Without this, we produce unusable pkg-config files when
prefix/libdir/etc contain spaces, which is very common on Windows.
2017-11-11 23:06:49 +05:30
getzze 6ce42e2ec5 Error for Libs in package_config function
Without specifying a custom install directory string, get_custom_install_dir() returns True. So for the `Libs` entry I was getting this:

  Libs: -L${prefix}/True -lfoo

Now it behaves as expected:

  Libs: -L${libdir} -lfoo
2017-10-19 20:22:32 +03:00
Luke Shumaker 4dbbb4884c flake8: Clean up complained-about unused imports
This also adds a "# noqa: F401" comment on an unused "import lzma",
which we are using it in a try/except block that is being used to
check if the lzma module is importable; of course it is unused.

v2: This turned out to be a little tricky.

    mesonbuild/modules/__init__.py had the "unused" import:

        from ..interpreterbase import permittedKwargs, noKwargs

    However, that meant that the various modules could do things like:

        from . import noKwargs # "." is "mesonbuild.modules"

    Which breaks when you remove __init__.py's "unused" import.  I
    could have tagged that import with "# noqa: F401", but instead I
    chose to have each of the module import directly from
    "..interpreterbase" instead of ".".
2017-09-21 13:41:03 -04:00
Alexis Jeandet bf64cf569b Gnome, pkgconfig, Qt4, Qt5 and windows modules slightly refactored.
Signed-off-by: Alexis Jeandet <alexis.jeandet@member.fsf.org>
2017-09-18 22:21:22 +02:00
Matthias Klumpp 61db415d7f d: Make feature names less verbose 2017-09-17 21:36:13 +02:00
Matthias Klumpp 75fdf413e4 Drop feature_args call in favor of letting pkgconfig do this directly 2017-09-12 17:33:22 +02:00
Patrick Griffis 2acf737b4b pkgconfig: Document url keyword
Closes #2272
2017-09-03 13:23:37 +03:00
Emmanuele Bassi 381e8313ed Make error message more informative
It's easier to identify a malformed variable assignment if we print it
out.
2017-07-21 19:38:55 +03:00
Laurent Carlier 0283a2fb41 pkgconfig: avoid appending slash at Cflags
otherwise it can break some compilations, see https://bugs.archlinux.org/task/54763
2017-07-13 16:28:32 +02:00
Bruce Richardson f12ece4547 pkgconfig: add support for extra_cflags
Allow the user to pass in arbitrary cflags for putting into the generated
pkgconfig file.
2017-06-29 11:03:20 -04:00
Jussi Pakkanen 3262be23dc Fixed issues raised in review. 2017-06-26 23:29:42 +03:00
Jussi Pakkanen 80d665e8de Converted some modules. 2017-06-26 21:10:27 +03:00
Peter Hutterer 7ed19902be pkgconfig: add suppport for custom variables during generation
Usage:
    pkgconfig.generate(
      ...
      description : 'A library with custom variables.',
      variables : ['foo=bar', 'datadir=${prefix}/data']
      )

The variables 'prefix', 'libdir' and 'includedir' are reserved, meson will
fail with an error message.

Variables can reference each other with the pkgconfig notation, e.g.

   variables : ['datadir=${prefix}/data',
                'otherdatadir=${datadir}/other']

meson does not check this for correctness or that the referenced variable
exists, we merely keep the same order as specified.
2017-05-11 00:13:30 +03:00
Nirbheek Chauhan 57cb1f9aad Support multiple install dirs for built/custom targets
You can now pass a list of strings to the install_dir: kwarg to
build_target and custom_target.

Custom Targets:
===============
Allows you to specify the installation directory for each
corresponding output. For example:

    custom_target('different-install-dirs',
      output : ['first.file', 'second.file'],
      ...
      install : true,
      install_dir : ['somedir', 'otherdir])

This would install first.file to somedir and second.file to otherdir.

If only one install_dir is provided, all outputs are installed there
(same behaviour as before).

To only install some outputs, pass `false` for the outputs that you
don't want installed. For example:

    custom_target('only-install-second',
      output : ['first.file', 'second.file'],
      ...
      install : true,
      install_dir : [false, 'otherdir])

This would install second.file to otherdir and not install first.file.

Build Targets:
==============
With build_target() (which includes executable(), library(), etc),
usually there is only one primary output. However some types of
targets have multiple outputs.

For example, while generating Vala libraries, valac also generates
a header and a .vapi file both of which often need to be installed.
This allows you to specify installation directories for those too.

    # This will only install the library (same as before)
    shared_library('somevalalib', 'somesource.vala',
      ...
      install : true)

    # This will install the library, the header, and the vapi into the
    # respective directories
    shared_library('somevalalib', 'somesource.vala',
      ...
      install : true,
      install_dir : ['libdir', 'incdir', 'vapidir'])

    # This will install the library into the default libdir and
    # everything else into the specified directories
    shared_library('somevalalib', 'somesource.vala',
      ...
      install : true,
      install_dir : [true, 'incdir', 'vapidir'])

    # This will NOT install the library, and will install everything
    # else into the specified directories
    shared_library('somevalalib', 'somesource.vala',
      ...
      install : true,
      install_dir : [false, 'incdir', 'vapidir'])

true/false can also be used for secondary outputs in the same way.

Valac can also generate a GIR file for libraries when the `vala_gir:`
keyword argument is passed to library(). In that case, `install_dir:`
must be given a list with four elements, one for each output.

Includes tests for all these.

Closes https://github.com/mesonbuild/meson/issues/705
Closes https://github.com/mesonbuild/meson/issues/891
Closes https://github.com/mesonbuild/meson/issues/892
Closes https://github.com/mesonbuild/meson/issues/1178
Closes https://github.com/mesonbuild/meson/issues/1193
2017-04-04 14:59:13 +05:30
Mike Sinkovsky 84902cb93a style: [E301] expected 1 blank line, found 0 2017-01-11 12:33:27 -05:00
Jussi Pakkanen fbabe8ad85 There are two different kinds of extensions: modules that create new
objects directly and snippets that just call into interpreter methods.
2017-01-09 21:11:48 +02:00
Jussi Pakkanen de24fddbd1 Create a module return value object. 2017-01-04 21:01:06 +02:00
Igor Gnatenko 5693758e46 style: fix E231 violations
E231: missing whitespace after ','

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2017-01-01 12:02:05 -05:00
Igor Gnatenko ef608f217d style: fix E222 violations
E222: multiple spaces after operator

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2017-01-01 12:02:05 -05:00
Igor Gnatenko 8268eb4959 tree-wide: remove unused imports
./setup.py:17:1: F401 'os' imported but unused
import os
^
./setup.py:37:1: F401 'stat.ST_MODE' imported but unused
from stat import ST_MODE
^
./run_tests.py:17:1: F401 'os' imported but unused
import subprocess, sys, os
^
./run_tests.py:18:1: F401 'shutil' imported but unused
import shutil
^
./run_unittests.py:23:1: F401 'mesonbuild.dependencies.Qt5Dependency' imported but unused
from mesonbuild.dependencies import PkgConfigDependency, Qt5Dependency
^
./mesonbuild/build.py:15:1: F401 '.coredata' imported but unused
from . import coredata
^
./mesonbuild/interpreter.py:32:1: F401 'subprocess' imported but unused
import os, sys, subprocess, shutil, uuid, re
^
./mesonbuild/interpreter.py:32:1: F401 're' imported but unused
import os, sys, subprocess, shutil, uuid, re
^
./mesonbuild/dependencies.py:23:1: F401 'subprocess' imported but unused
import os, stat, glob, subprocess, shutil
^
./mesonbuild/mesonlib.py:17:1: F401 'sys' imported but unused
import platform, subprocess, operator, os, shutil, re, sys
^
./mesonbuild/modules/qt5.py:15:1: F401 'subprocess' imported but unused
import os, subprocess
^
./mesonbuild/modules/pkgconfig.py:15:1: F401 '..coredata' imported but unused
from .. import coredata, build
^
./mesonbuild/scripts/scanbuild.py:15:1: F401 'sys' imported but unused
import sys, os
^
./mesonbuild/scripts/meson_exe.py:20:1: F401 'subprocess' imported but unused
import subprocess
^
./mesonbuild/scripts/meson_exe.py:22:1: F401 '..mesonlib.MesonException' imported but unused
from ..mesonlib import MesonException, Popen_safe
^
./mesonbuild/scripts/symbolextractor.py:23:1: F401 'subprocess' imported but unused
import os, sys, subprocess
^
./mesonbuild/scripts/symbolextractor.py:25:1: F401 '..mesonlib.MesonException' imported but unused
from ..mesonlib import MesonException, Popen_safe
^
./mesonbuild/scripts/meson_install.py:19:1: F401 '..mesonlib.MesonException' imported but unused
from ..mesonlib import MesonException, Popen_safe
^
./mesonbuild/scripts/yelphelper.py:15:1: F401 'sys' imported but unused
import sys, os
^
./mesonbuild/scripts/yelphelper.py:20:1: F401 '..mesonlib.MesonException' imported but unused
from ..mesonlib import MesonException
^
./mesonbuild/backend/vs2010backend.py:17:1: F401 're' imported but unused
import re
^
./test cases/vala/8 generated sources/src/copy_file.py:3:1: F401 'os' imported but unused
import os
^
./test cases/common/107 postconf/postconf.py:3:1: F401 'sys' imported but unused
import sys, os
^
./test cases/common/129 object only target/obj_generator.py:5:1: F401 'shutil' imported but unused
import sys, shutil, subprocess
^
./test cases/common/57 custom target chain/usetarget/subcomp.py:3:1: F401 'os' imported but unused
import sys, os
^
./test cases/common/95 dep fallback/subprojects/boblib/genbob.py:3:1: F401 'os' imported but unused
import os
^
./test cases/common/98 gen extra/srcgen.py:4:1: F401 'os' imported but unused
import os
^
./test cases/common/113 generatorcustom/gen.py:3:1: F401 'os' imported but unused
import sys, os
^
./test cases/common/113 generatorcustom/catter.py:3:1: F401 'os' imported but unused
import sys, os
^
./test cases/common/59 object generator/obj_generator.py:5:1: F401 'shutil' imported but unused
import sys, shutil, subprocess
^

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-12-19 18:19:35 +01:00
Jussi Pakkanen 66ed54a94e Merge pull request #1144 from valum-framework/always-add-version-in-pkg-config
pkgconfig: 'Version' must be specified, even if it's empty
2016-12-06 20:26:30 +02:00
Guillaume Poirier-Morency ff55e848f6 pkgconfig: Raise an error if 'version' is not specified 2016-12-05 22:46:32 -05:00
Guillaume Poirier-Morency 6389e70c11 pkgconfig: 'Version' must be specified, even if it's empty 2016-12-05 11:23:04 -05:00
Guillaume Poirier-Morency bd22c9bdd2 pkgconfig: Add a newline after variable declarations 2016-12-02 22:56:47 +02:00
Jussi Pakkanen a01919976e Always specify installed data with a File object. Closes #858. 2016-11-18 17:37:35 -05:00
Nirbheek Chauhan a2262103fb Implement mlog.warning and use it everywhere for warnings
Prepends the string with 'WARNING:' in ANSI yellow.

Closes https://github.com/mesonbuild/meson/issues/961
2016-11-08 17:43:24 -05:00
Guillaume Poirier-Morency f7a60099f6 pkgconfig: Fix absolute 'libdir' and 'includedir' 2016-10-23 04:38:34 -07:00
Guillaume Poirier-Morency bda92b37ee pkgconfig: Accept string for 'libraries' and 'libraries_private' 2016-10-16 11:33:31 -04:00
Guillaume Poirier-Morency 9ebc140832 pkgconfig: Process private libraries like regular ones 2016-10-16 11:33:11 -04:00
Guillaume Poirier-Morency 9429183c1d pkgconfig: Fix typo in 'Libs.private'
It's no different from 'Libs', so we specify as well the directory.
2016-10-16 11:06:17 -04:00
Guillaume Poirier-Morency 3090419181 pkgconfig: Add missing 'URL' and 'Conflicts' entries 2016-10-16 11:06:17 -04:00
Guillaume Poirier-Morency a33c5c50f1 pkgconfig: Rename 'CFlags' for 'Cflags' 2016-10-16 11:04:40 -04:00
Guillaume Poirier-Morency e9f66b1930 pkgconfig: Prevent trailing space
Prepend instead of appending a space so that we never end with a
trailing space.
2016-10-16 11:04:40 -04:00
Nirbheek Chauhan 814f4909f9 pkgconfig: Handle library names starting with 'lib'
Sometimes people want the library to start with 'lib' everywhere, which
is achieved by setting name_prefix to '' and the target name to
'libfoo'. In that case, try to get the pkg-config '-lfoo' arg right.

Also, don't warn about anything on Windows

Fixes https://github.com/mesonbuild/meson/issues/889
2016-10-13 02:18:16 +05:30
Nirbheek Chauhan 674b520206 pkgconfig: Only warn for suffix if the filename doesn't start with lib 2016-10-12 21:22:54 +05:30
Nirbheek Chauhan d819914af0 pkgconfig: Warn if library has name_prefix/suffix set
GCC/Clang won't be able to find it via an -lfoo flag, so the pkg-config
file might be unusable.

Fixes https://github.com/mesonbuild/meson/issues/889
2016-10-12 13:40:08 +05:30
grindhold 167deda665 module pkgconfig: added install_dir attribute (#776)
the pkgconfig module automatically specified to install the
pkgconfig file to {libdir}/pkgconfig. Default settings in meson
already include multiarch-directories like x86_64-gnu-linux into
the libdir. pkgconfig usually does not check inside multiarch-dirs
for any pkgconfig-files.
to make this a bit more flexible, this commit introduces the
install_dir attribute for pkgconfig.generate. if it is set, the
default install path will be overridden by the users input
2016-09-11 00:20:49 +03:00
TingPing 0e79664155 Minor pkgconfig module cleanups (#748)
* pkgconfig: Remove unused function

Leftover copy from modtest

* Add self to authors.txt
2016-09-02 23:11:54 +03:00
Elliott Sales de Andrade 4c71695e41 Use context manager for file I/O.
There are a few cases where a context manager cannot be used, such as
the logger.
2016-08-27 18:29:55 -04:00
Elliott Sales de Andrade a2321b24f6 Flatten isinstance calls. (#715)
That is, isinstance(x, y) or isinstance(x, z) can be flattened with a
tuple to isinstance(x, (y, z)).
2016-08-27 15:47:29 +03:00