Commit Graph

173 Commits

Author SHA1 Message Date
Jussi Pakkanen 5365d9a842 Refactor option classes to their own file. 2024-05-23 21:26:45 +03:00
Xavier Claessens 5654f03450 interpreter: Dependency variables can be empty string
There is no reason to forbid empty variables, PkgConfigCLI.variable()
even has code specifically for handling that case.
2024-02-26 10:03:51 -05:00
Dylan Baker e991c4d454 Use SPDX-License-Identifier consistently
This replaces all of the Apache blurbs at the start of each file with an
`# SPDX-License-Identifier: Apache-2.0` string. It also fixes existing
uses to be consistent in capitalization, and to be placed above any
copyright notices.

This removes nearly 3000 lines of boilerplate from the project (only
python files), which no developer cares to look at.

SPDX is in common use, particularly in the Linux kernel, and is the
recommended format for Meson's own `project(license: )` field
2023-12-13 15:19:21 -05:00
Chris Lamb 2ed94ccb47 Make the Requires.private line in generated .pkgconfig files reproducible
Whilst working on the Reproducible Builds effort, we noticed that
meson was generates .pkgconfig files that are not reproducible.

For example, here is neatvnc's pkgconfig file when built with HEAD^1:

   Name: neatvnc
   Description: A Neat VNC server library
   Version: 0.7.0
  -Requires.private: pixman-1, aml < 0.4.0, aml >= 0.3.0, zlib, libdrm, libturbojpeg, gnutls, nettle, hogweed, gmp, gbm, libavcodec, libavfilter, libavutil
  +Requires.private: pixman-1, aml >= 0.3.0, aml < 0.4.0, zlib, libdrm, libturbojpeg, gnutls, nettle, hogweed, gmp, gbm, libavcodec, libavfilter, libavutil
   Libs: -L${libdir} -lneatvnc
   Libs.private: -lm
   Cflags: -I${includedir}

This is, ultimately, due to iterating over the contents of a set within a
DefaultDict and can thus be fixed by sorting the output immediately prior to
generating the Requires.private string.

An alternative solution would be to place the sorted(…) call a few lines
down:

    return ', '.join(sorted(result))

However, this changes the expected ordering of the entire line, and many users
may be unhappy with that (alternative) change as a result. By contrast, this
commit will only enforce an ordering when there are multiple version
requirements (eg. a lower and a higher version requirement, ie. a version
range). It will, additionally, order them with the lower part of the range
first.

This was originally filed (with a slightly different patch) by myself in
the the Debian bug tracker <https://bugs.debian.org/1056117>.

Signed-off-by: Chris Lamb <lamby@debian.org>
2023-11-22 22:08:35 +02:00
Dylan Baker 74771d2119 compilers/d: use DFeatures for get_features_args 2023-10-16 13:28:32 -07:00
Xavier Claessens f1c35b561f pkgconfig: Set PKG_CONFIG in env for devenv and g-ir-scanner 2023-09-18 13:51:27 -04:00
Xavier Claessens 183e4b8e90 PkgConfigDependency: Move CLI handling into its own abstraction
This makes the code cleaner and will allow to have other implementations
in the future.
2023-08-03 16:27:52 -04:00
Dylan Baker 020610cfbe modules/pkgconfig: Don't insert None into devenv list
When the pkgconfig module is imported, but not used, it will insert None
on the end of the devenv list. This list is not expected to contain
None, and causes Meson to crash. This can happen in complex build setups
(reported from mesa), where pkgconfig is only used in some
configurations

Fixes: #12032
2023-07-25 00:13:16 -04:00
Eli Schwartz 7afc69254d
fix implicit_reexport issues and enforce them going forward
This detects cases where module A imports a function from B, and C
imports that same function from A instead of B. It's not part of the API
contract of A, and causes innocent refactoring to break things.
2023-07-19 18:31:37 -04:00
Eli Schwartz 3171fc5338
add better comments for mypy suppressions 2023-07-19 18:31:36 -04:00
Eli Schwartz e715400d1b
tree-wide: reduce unneeded imports on specific Dependency impls
We can check something's subtype using properties, without importing the
module up front and doing isinstance checks on specific subclasses of
the interface -- or worse, solving cyclic imports by doing the import
inside the function. ;)
2023-06-26 13:10:32 -04:00
Eli Schwartz 418063cc47
pkgconfig: move uninstalled devenv handling from setup to the module hook
msetup.py doesn't need to know the gory details of PkgConfigDependency,
or directly import it at program startup. It's also slightly wasteful to
generate a devenv for the -uninstalled directory when a project doesn't
even, in the end, use the pkgconfig module anyway.
2023-06-26 13:10:25 -04:00
Xavier Claessens 1781a481ee pkgconfig: Add include directories from internal deps in -uninstalled.pc
Fixes: #8651
2023-06-01 18:57:40 -04:00
Eli Schwartz 7bdb4a6926
pkgconfig module: fix traceback on invalid missing description
If the optional first "mainlib" argument is there, then we infer several
values. Otherwise, some of those values fall back to a generic default,
and two of them -- name and description -- fall back to being mandatory.

In commit e84f293f67, we removed
validation for description as part of refactoring that never actually
validated anything.
2023-04-18 19:42:29 -04:00
X512 b1384b9c9f Haiku pkgconfig directory layout support 2023-01-20 14:57:33 -05:00
Paolo Bonzini 863f2a6d74 forbid using declare_dependency(objects: ...) with pkg-config module
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2023-01-04 09:44:32 -08:00
Dylan Baker 20d76b8353
pylint: enable unnecessary-comprehension 2022-10-03 00:14:43 -04:00
Dylan Baker a572734330 modules/pkgconfig: make it a NewExtensionModule
Since we no longer need Interpreter.extract_variables, we can remove the
interpreter from the module!
2022-08-18 21:57:36 -04:00
Dylan Baker 7c12066e73 modules/pkgconfig: mypy clean! 2022-08-18 21:57:36 -04:00
Dylan Baker 9bd3c1957d modules/pkgconfig: Fix code to handle CustomTarget and CustomTargetIndex 2022-08-18 21:57:36 -04:00
Dylan Baker 2fb0c0e4d8 modules/pkgconfig: remove type checking abstraction
Which confuses the heck out of mypy
2022-08-18 21:57:36 -04:00
Dylan Baker e15f15d904 modules/pkgconfig: get rid of modifications to the BuildTarget objects
This would tack on extra attributes for meta data tracking. Do that with
our own datastructures instead
2022-08-18 21:57:36 -04:00
Dylan Baker 3f63827527 modules/pkgconfig: ensure "name" is not None
The name can be None if a library is not passed as a positional
argument, and the name keyword argument is not provided. We shouldn't
allow that to happen.
2022-08-18 21:57:36 -04:00
Dylan Baker 26f02f50b8 modules/pkgconfig: Get most type annotations added
There are still a lot of errors here due to a mixture of really bad
design (adding extra attributes to objects), and legitimate type errors
(passing a str where a List[str] is expected). I suspect a lot of these
cases aren't hit for some reason.
2022-08-18 21:57:36 -04:00
Dylan Baker e84f293f67 modules/pkgconfig: Use typed_kwargs 2022-08-18 21:57:36 -04:00
Dylan Baker ddb95b0ed8 modules/pkgconfig: use typed_pos_args 2022-08-18 21:57:36 -04:00
Dylan Baker 6e75456a75 modules/pkgconfig: fix typo in blocked variable
require_private -> requires_private.
2022-08-18 21:57:36 -04:00
Dylan Baker 48222c45b2 modules/pkgconfig: Fix some low hanging typing issues 2022-08-18 21:57:36 -04:00
Dylan Baker 6843f56f6b modules: use module level information about new and deprecation
Instead of using FeatureNew/FeatureDeprecated in the module.

The goal here is to be able to handle information about modules in a
single place, instead of having to handle it separately. Each module
simply defines some metadata, and then the interpreter handles the rest.
2022-08-17 16:25:36 -04:00
Marc-André Lureau 6096337904 pkgconfig: do not add valgrind as requirement
For the same reasons commit 7aa28456d ("Add dependency type for
Valgrind") removed linking with valgrind, pkgconfig shouldn't generate
"Requirements" for it, in general.

This solves dbus meson port question/issue from:
https://gitlab.freedesktop.org/dbus/dbus/-/merge_requests/303#note_1444819

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-07-06 10:36:44 -07:00
Michael Mera 9b21428006 fix parameter expansion in several error messages
At several points in the code base, f-strings are not correctly expanded
due to missing 'f' string prefix. This fixes all the occurrences I could
find.
2022-06-17 12:16:42 -04:00
Fredrik Salomonsson 2e31330fe6 pkgconfig: Add relocatable module option
If set to true it will generate the pkgconfig files as relocatable i.e
the prefix variable will be relative to the install_dir. By default
this is false.

Will generate a MesonException if the pkgconfig file is installed
outside of the package and pkgconfig.relocatable=true.
2022-04-19 17:35:08 -04:00
Tristan Partin 2c03b2bb7f Move dataonly pkgconfig file to datadir/pkgconfig
dataonly files are architecture independent (lib vs lib64 for example).

Fixes #9902
2022-03-09 17:50:41 -05:00
Eli Schwartz 6240920c21
pkgconfig module: allow custom variables to reference builtin directories
Automatically generate additional variables and write them into the
generated pkg-config file.

This means projects no longer need to manually define the ones they
use, which is annoying for dataonly usages (it used to forbid setting
the base library-relevant "reserved" ones, and now allows it only for
dataonly. But it's bloat to manualy list them anyway).

It also fixes a regression in commit
248e6cf473 which caused libdir to not be
set, and to be unsettable, if the pkg-config file has no libraries but
uses the ${libdir} expansion in a custom variable. This could be
considered likely a case for dataonly, but it's not guaranteed.
2022-02-15 16:50:41 -05:00
Andrea Pappacoda 248e6cf473 pkgconfig: set libdir only if used
This should address some concerns outlined in
https://github.com/yhirose/cpp-httplib/pull/1182
2022-02-01 12:23:06 -08:00
Xavier Claessens 95a4c6a62a pkgconfig: Fix linking to a custom target
When generating pkgconfig file for a library that links to an
uninstalled static library built by custom_target() Meson was crashing
when trying to access some attributes that does not exist on that class.

Also fix is_internal() implementation, it only really make sense on a
CustomTargetIndex or if CustomTarget has only a single output.
2021-12-22 08:04:08 +05:30
Eli Schwartz 038b31e72b
various manual conversion of percent-formatted strings to f-strings 2021-11-01 20:26:18 -04:00
Eli Schwartz 8947352889 fix various flake8 whitespace errors 2021-10-27 09:51:52 -04:00
Eli Schwartz da81586a5b pkgconfig module: correctly generate Libs search path with absolute install_dir
For example the OpenRC build files install libraries to install_dir: '/lib'
and this works, but causes the generated pkg-config to say:

prefix=/usr

Libs: -L${prefix}//lib

which is both ugly (double //) and resolves to /usr/lib which is exactly
what does not work.
2021-10-10 14:30:46 +03:00
Eli Schwartz d06cc042eb
f-strings 2021-10-04 16:29:32 -04:00
Dylan Baker c3c30d4b06 interpreter: Use typed_kwargs for func_custom_target
This does not convert the build side, or remove any of the checking it
does. We still need that for other callers of custom target. What we'll
do for those is add an internal interface that defaults things, then
we'll be able to have those callers do their own validation, and the
CustomTarget validation machinary can be removed.

Fixes #9096
2021-09-30 21:01:38 +02:00
Dylan Baker d661a0cd96 build: use an object rather than a dict for the dep_manifest
This really is more of a struct than a dict, as the types are disjoint
and they are internally handled, (ie, not from user input). This cleans
some things up, in addition I spotted a bug in the ModuleState where the
dict with the version and license is passed to a field that expects just
the version string.
2021-09-24 10:36:05 -07:00
Filipe Laíns af8b55d49b mintro: add installed_plan
Signed-off-by: Filipe Laíns <lains@riseup.net>
2021-09-06 18:10:55 +02:00
Xavier Claessens 8c5aa031b5 Add install tags
Fixes: #7007.
2021-08-17 15:19:18 -04:00
Dylan Baker 20399a3e04 modules/pkgconfig: remove handling of .pcdep
Nothing uses this anymore, so don't check for it.
2021-07-13 16:43:14 -07:00
Daniel Mensinger 8f7343831b refactor: Refactor BothLibraries logic
This commit introduces a new type of `HoldableObject`: The
`SecondLevelHolder`. The primary purpose of this class is
to handle cases where two (or more) `HoldableObject`s are
stored at the same time (with one default object). The
best (and currently only) example here is the `BothLibraries`
class.
2021-06-26 12:49:35 +02:00
Daniel Mensinger 34c28dc92c holders: remove unholder 2021-06-18 23:48:33 +02:00
Daniel Mensinger 84a3e459a8 holders: Introduce BothLibraries 2021-06-18 23:48:33 +02:00
Daniel Mensinger 95b70bcb97 deps: Split dependencies.base
Split the Factory and dependency classes out
of the base.py script to improve maintainability.
2021-06-03 10:23:27 -07:00
Xavier Claessens 2e02ef6592 modules: Add methods dict everywhere
This fix calling random internal methods from meson.build as long as
they were not prefixed by underscore.
2021-05-28 15:17:10 -04:00