Commit Graph

49 Commits

Author SHA1 Message Date
Eli Schwartz 1c52ac4e15
move various imports into TYPE_CHECKING blocks for neatness 2022-05-23 16:44:08 -04:00
Dylan Baker 3e90f27703 interpreter: replace build_def_files with OrderedSet
We do a bunch of backbending to make sure we don't have duplicates,
let's just use the right datastructure to begin with.
2022-03-03 10:29:14 -08:00
Dylan Baker 5787f81615 interpreter: add cm_interpreter to SubprojectHolder
This is used in the cmake module, as an extra attribute we just tack on.
Instead, let's actually define and type it.
2022-03-03 10:29:14 -08:00
Dylan Baker 4a2058cb83 interpreter: use typed_kwargs for subproject() 2022-03-03 10:29:14 -08:00
Dylan Baker f4ae32c2ad modules/cmake: add type annotations for subproject method
This will be used to handle the interpreter subproject as well
2022-03-03 10:29:14 -08:00
Andrea Pappacoda fcca265035 cmake: configure_package_config_file can now take a dict 2022-02-27 11:45:26 -05:00
Andrea Pappacoda c42a3fd2fb cmake: typed_kwargs for configure_package_config_file 2022-02-27 11:45:26 -05:00
Andrea Pappacoda 316cf3a717 cmake: add arch_independent kwarg
CMake's write_basic_package_version_file has supported since version 3.14
an ARCH_INDEPENDENT option that makes it skip its architecture check in
the Version file.

With this patch Meson now supports it as well, and the change is also
compatible with older CMake versions, as they will simply ignore the
option.

This also slightly changes the contents of the generated Version file
when arch_independent is not set: previously, the if() needed to skip
the arch check was always filled with an empty string, while CMake puts
"FALSE" (or "TRUE") in it. Now, that if() will always be filled with
either "False" or "True", better matching CMake's behaviour.
2022-02-01 23:48:17 -05:00
Andrea Pappacoda a755750cae cmake: typed_kwargs for write_basic_package_version_file 2022-02-01 23:48:17 -05:00
Dylan Baker 5074e2d3b5 interpreter: replace ConfigurationDataObject with ConfigurationDataHolder
This is much cleaner, and more in line with the way we handle
interpreter objects in modern meson practice
2022-01-18 17:53:29 -05:00
Eli Schwartz 688b4bac76 add FeatureNew decorators for various modules that were lacking them
Going back to 0.38, though some of them are far older. The original
implementation of FeatureNew only added backdated feature checks that
far, anyway.
2021-12-31 12:03:57 +02:00
Eli Schwartz ee0baa97cd modules: use find_program implementation to find programs
Do not use ExternalProgram as that is too low-level and doesn't handle
e.g. machine file overrides.

Fixes #9733
2021-12-21 12:17:10 +01:00
Chris Lamb 958b1a7fb4 Make the generated reproducible .cmake files reproducible.
Whilst working on the Reproducible Builds effort [0], I noticed that meson did
not generate reproducible .cmake files: they include the full path name.

This commit not only makes the build reproducible, but it also matches CMake's
own behaviour. Specifically, CMakePackageConfigHelpers.cmake does the
equivalent transformation using:

    get_filename_component(inputFileName "${_inputFile}" NAME)

I originally filed this in Debian as bug #1000327 [1].

 [0] https://reproducible-builds.org/
 [1] https://bugs.debian.org/1000327
2021-11-21 14:38:33 -05:00
Eli Schwartz 9ec3b99a4f do not repeat magic regexes for cmake define replacements
We already have this magic string in mesonlib, and this should always
have used the cmake@ format which is identical to the meson format other
than the regex.
2021-10-27 09:59:08 -04:00
Eli Schwartz d06cc042eb
f-strings 2021-10-04 16:29:32 -04:00
Eli Schwartz 7825a6f2ca cmake module: if cmake cannot be found, do not traceback
We ended up passing a NoneType as the program binary, which is a very
awkward way to communicate an error when failing to write a basic
package version file.
2021-10-03 12:34:01 +02: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
Dylan Baker 4d7031437c pylint: turn on superflous-parens
We have a lot of these. Some of them are harmless, if unidiomatic, such
as `if (condition)`, others are potentially dangerous `assert(...)`, as
`assert(condtion)` works as expected, but `assert(condition, message)`
will result in an assertion that never triggers, as what you're actually
asserting is `bool(tuple[2])`, which will always be true.
2021-08-31 16:28:54 -04:00
Daniel Mensinger 8e1c599c10 cmake: Improved error message for using dependency for executables
fixes #8893
2021-07-05 18:21:10 +03:00
Daniel Mensinger 3e396b3782
fix: Always explicitly set encoding for text files (fixes #8263) 2021-06-29 11:28:08 +02:00
Daniel Mensinger 34c28dc92c holders: remove unholder 2021-06-18 23:48:33 +02: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
Xavier Claessens a734bcfc83 modules: Stop using ModuleReturnValue where it's not needed
It is only needed in functions that need to add targets to the
interpreter.
2021-05-28 15:17:10 -04:00
Xavier Claessens 3340284805 modules: Stop using InterpreterObject
Custom objects returned by modules must be subclass of ModuleObject and
have the state argument in its methods.

Add MutableModuleObject base class for objects that needs to be deep
copied on assignation.
2021-05-28 15:17:10 -04:00
Xavier Claessens 723c5227a4 modules: Remove snippet methods
The only advantage they have is they have the interpreter in arguments,
but it's already available as self.interpreter. We should discourage
usage of the interpreter API and rely on ModuleState object instead in
the future.

This also lift the restriction that a module method cannot add build
targets, but that was not enforced for snippet methods anyway (and some
modules were doing it) and it's really loose restriction as it should
check for many other things if we wanted to make it consistent.
2021-05-28 15:17:10 -04:00
Xavier Claessens 558a7bc6ff interpreter: Move to its own folder and split it 2021-04-01 14:26:33 -04:00
Dylan Baker 40e3577a65 split program related classes and functions out of dependencies
Dependencies is already a large and complicated package without adding
programs to the list. This also allows us to untangle a bit of spaghetti
that we have.
2021-03-19 08:47:10 -04:00
Eli Schwartz 6a0fabc647
mass rewrite of string formatting to use f-strings everywhere
performed by running "pyupgrade --py36-plus" and committing the results
2021-03-04 17:16:11 -05:00
Eli Schwartz 4340bf34fa
various python neatness cleanups
All changes were created by running

"pyupgrade --py3-only --keep-percent-format"

and committing the results. I have not touched string formatting for
now.

- use set literals
- simplify .format() parameter naming
- remove __future__
- remove default "r" mode for open()
- use OSError rather than compatibility aliases
- remove stray parentheses in function(generator) scopes
2021-03-04 17:11:26 -05:00
Xavier Claessens 2fabd4c7dc minstall: Add --skip-subprojects option
By default all subprojects are installed. If --skip-subprojects is given
with no value only the main project is installed. If --skip-subprojects
is given with a value, it should be a coma separated list of subprojects
to skip and all others will be installed.

Fixes: #2550.
2021-02-22 23:03:55 +02:00
Dylan Baker 022632c91b build/interperter: Add annotations and move input validation to interpreter
This moves the user input validation to the interpreter, instead of
being in the build module, and adds type annotations.
2021-01-13 13:32:48 -08:00
Dylan Baker e81acbd606 Use a single coredata dictionary for options
This patches takes the options work to it's logical conclusion: A single
flat dictionary of OptionKey: UserOptions. This allows us to simplify a
large number of cases, as we don't need to check if an option is in this
dict or that one (or any of 5 or 6, actually).
2021-01-04 12:20:58 -08:00
Daniel Mensinger e36f713a7f include_type: Add CMake subporject dependency method (fixes #6879) 2020-10-13 23:51:25 +03:00
Daniel Mensinger 948741355f cmake: Make the CMake targte not found error more useful (see #7567) 2020-08-09 19:36:10 +03:00
Jussi Pakkanen 64f36613ef
Merge pull request #7231 from mensinda/cmOverride
cmake: Add more advanced subproject configuration options
2020-07-01 00:04:08 +03:00
Dylan Baker 49a974213c modules/cmake: Fix setting install_dir
Fixes: #7301
2020-06-12 15:51:21 +00:00
Daniel Mensinger a2f94ca18b
cmake: Add more advanced subproject configuration options
This is done with the new cmake subprojects options object
that is similar to the already exisiting configuration data
object. It is consumed by the new `options` kwarg of the
cmake.subproject function.
2020-06-05 11:45:05 +02:00
Dylan Baker 73ddc01477 modules/cmake: Add a found() method to the cmake subproject
Just like the native meson subproject has.
2020-02-19 07:07:35 +05:30
Dylan Baker 52d36aaec1 modules/cmake: Use the noPosargs helper 2020-02-19 07:07:35 +05:30
Wolfgang Stöggl f037e7ef45 Fix typos found by codespell
- Typos were found by codespell v1.16.0
2019-11-06 09:55:30 -05:00
Xavier Claessens 71bfec7ec1 cmake: subproject() supports the 'required' kwarg 2019-10-01 13:30:15 -04:00
Daniel Mensinger fbddeeb4ac cmake: define set_and_check in CMake package config (fixes #5889) 2019-09-26 20:29:42 +03:00
Thibault Saunier 6813ef1e24 cmake: Handle disabling subprojects 2019-07-13 05:17:01 +00:00
John Ericson 07777e15d4 Purge `is_cross` and friends without changing user interfaces
In most cases instead pass `for_machine`, the name of the relevant
machines (what compilers target, what targets run on, etc). This allows
us to use the cross code path in the native case, deduplicating the
code.

As one can see, environment got bigger as more information is kept
structured there, while ninjabackend got a smaller. Overall a few amount
of lines were added, but the hope is what's added is a lot simpler than
what's removed.
2019-06-09 13:13:25 -04:00
Daniel Mensinger e02c101575
cmake: moved subprojects into the CMake module 2019-06-06 18:27:05 +02:00
Jon Turney 58870fda16 Remove compilers from ModuleState object
It doesn't make much sense to have this and not also have
cross-compilers (so any use of this is already pretty suspect as
probably wrong when cross-compiling).

This information is accessible anyhow via environment.coredata.
2019-05-20 11:29:17 -07:00
Daniel Mensinger cb1ef0c449 cmake: Use CMAKE_ROOT instead of _INCLUDE_FILE (closes #5218) 2019-04-28 19:29:56 +03:00
Dylan Baker 5678468c2c Don't use len() to test for container emptiness
I ran the numbers once before (it's in the meson history) but it's
*much* faster to *not* use len for testing if a container is empty or
not.
2019-04-25 12:28:51 -07:00
David Fort ceaebf6bac add support for generating cmake files
This new cmake module allows to generate cmake package files. This may ease the
porting for cmake projects that are exporting cmake package informations for other
depending projects. The module uses as much as possible the templates provided by
the cmake installation (and so cmake needs to be installed).
2019-01-17 20:48:28 +02:00