Commit Graph

144 Commits

Author SHA1 Message Date
Jussi Pakkanen 181c3499fd Fix mypy. 2024-06-14 17:19:53 +03:00
Jussi Pakkanen 9a6fcd4d9a Replace direct indexing with named methods. 2024-06-14 17:19:53 +03:00
Jussi Pakkanen c0d86024f5 Rename option variable to optstore to make it unique. 2024-06-14 17:19:53 +03:00
Jussi Pakkanen 5365d9a842 Refactor option classes to their own file. 2024-05-23 21:26:45 +03:00
Dylan Baker 2d7b7c3aaf mconf: Reload the options files if they have changed
This fixes issues where a new option is added, an option is removed, the
constraints of an option are changed, an option file is added where one
didn't previously exist, an option file is deleted, or it is renamed
between meson_options.txt and meson.options

There is one case that is known to not work, but it's probably a less
common case, which is setting options for an unconfigured subproject.
We could probably make that work in some cases, but I don't think it
makes sense to download a wrap during meson configure.
2024-03-18 16:06:37 -07:00
Dylan Baker 5d1c3ae787 mconf|msetup: use Protocol for argparse options
These are much easier to handle as one commit since msetup calls mconf
internally. This has found one case where things are being carefully
crafted to work in mconf even though msetup has slightly different
options
2024-02-23 08:47:01 -08: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
Luke Elliott ce691f8c98 Add comments suggesting to keep shell completion scripts up-to-date near cmd line argument code 2023-11-01 00:06:19 +02:00
Xavier Claessens e3a71a7b58 msetup: Update options when builddir is already configured
`meson setup -Dfoo=bar builddir` command was returning success ignoring
new option values.

This now also update options. It is useful because it means
`meson setup -Dfoo=bar builddir && ninja -C builddir` works regardless
whether builddir already exists or not, and when done in a script,
changing options in the script will automatically trigger a reconfigure
if needed. This was already possible by always passing --reconfigure
argument, but that triggers a reconfigure even when options did not
change.
2023-08-25 09:43:24 -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 a53c6687b6
fully type mconf.py 2023-06-25 10:08:15 -04:00
Xavier Claessens 543610468d coredata: Also clear compiler and run caches 2023-06-23 13:53:35 -04:00
Xavier Claessens 1d600b48cb mconf: Allow changing options and clearing cache at the same time
Setting options or clearing cache is also an error without a valid build
directory.
2023-06-23 13:53:35 -04:00
Dylan Baker ada2a976f0
mlog: use a hidden class for state
This is a pretty common pattern in python (the standard library uses it
a ton): A class is created, with a single private instance in the
module, and then it's methods are exposed as public API. This removes
the need for the global statement, and is generally a little easier to
reason about thanks to encapsulation.
2023-05-31 17:20:44 -04:00
Xavier Claessens 72cd2a395a coredata: Do not pickle it twice
Exclude coredata from build.dat because it gets pickled separately
already.
2023-03-16 21:02:23 -04:00
Daan De Meyer adb619db61 Stop using replace_if_different() for coredata pickle file
This was added in f774609 to only change the access time of the
coredata file if the coredata struct actually changed. However,
this doesn't work as pickle serializations aren't guaranteed to
be stable. Instead, let's manually check if options have changed
values and skip the save if they haven't changed.

We also extend the associated unit test to cover all the option
types and to ensure that configure does get executed if one of the
options changes value.
2023-03-16 17:18:30 -04:00
Xavier Claessens 4fa5b2ee42 mconf: Use auto_features value for auto options
When project is configured with -Dauto_features=disabled, meson
configure should not print "auto" value but "disabled" instead.
2023-02-07 03:24:48 -05:00
Eli Schwartz 680b5ff819
treewide: add future annotations import 2023-02-01 17:01:30 -05:00
Xavier Claessens 195aae6a84 mconf: Do not print None for empty choices 2022-09-27 11:15:51 -04:00
Xavier Claessens 4fce954f97 mconf: Use pager only when printing configuration
Fixes: #10845
2022-09-27 11:15:51 -04:00
Xavier Claessens d202697182 mconf: Add --no-pager option 2022-09-22 11:29:03 -04:00
Xavier Claessens b3dc99e6da mconf: Print options with colors 2022-09-22 11:29:03 -04:00
Xavier Claessens 5a98c915c5 mconf: Substract the 3 space separators between columns 2022-09-22 11:29:03 -04:00
Xavier Claessens 5d6368e562 mconf: Do not wrap choices manually
We already use textwrap.wrap() for that and it will correctly split on
spaces.
2022-09-22 11:29:03 -04:00
Xavier Claessens c8b57f1b57 mconf: There is always 4 columns 2022-09-22 11:29:03 -04:00
Xavier Claessens 59d561d4c1 mlog: Add support for pager
It is useful to redirect some outputs, such as "meson configure" to a
pager (e.h. less). This is similar to most git commands.
2022-09-22 11:29:03 -04:00
Xavier Claessens 3111ce6aae mconf: Use mlog.log() instead of print()
This will allow using colors and redirect print into a pager.
2022-09-22 11:29:03 -04:00
Daan De Meyer f774609b09 Only reconfigure if configure options actually changed
Currently, if we run "meson configure -Doption=value", meson will
do a reconfigure when running "ninja build" afterwards, even if
the new value is the same one that was already configured previously.

To avoid this unnecessary reconfigure, let's use replace_if_different()
instead of unconditionally replacing the conf file in coredata's save()
function.
2022-07-31 20:43:27 +03:00
fxxf 650cea3d08 fix: handle the case where the last item of `four_column` results in being < 1 (COLUMNS <= 60) by falling back to `_col`, relevant issue #10211 2022-06-24 00:17:56 -04:00
Eli Schwartz 1eaf49c880 flake8: remove no longer used imports 2022-06-10 09:15:48 -04:00
Xavier Claessens 3180c579f6 mconf: Fix printing <inherited from main project> for yielding options
In print_options() k was a string instead of OptionKey, but
self.yielding_options expects OptionKey. Not sure how this has not been
catched by mypy.

Fix by keeping k as OptionKey which makes self.yielding_options useless.

Fixes: #9503
2022-04-13 21:10:32 +03:00
Eli Schwartz 8947352889 fix various flake8 whitespace errors 2021-10-27 09:51:52 -04:00
Xavier Claessens 2628ce576c Add support for module options 2021-10-08 17:47:35 -04:00
Eli Schwartz 1bb2523e58
remove f from f-string that has no formatting 2021-10-04 16:29:31 -04:00
Xavier Claessens d5917c1b87 coredata: Invalidate deps cache when changing wrap_mode option
Fixes: #8858
2021-06-11 09:40:21 -04:00
Dylan Baker d3003ebb41 mconf: line wrap columns nicely
I've picked 160 characters as a default because anything less than that
looks terrible and has awful wrapping going on. However, this respects
the $COLUNNS environment variable if set, and otherwise will query the
terminal to determine the size.

This is all achieved through an application of shtuil.get_terminal_size,
textwrap, print formatters, and iteration.

Fixes #6965
2021-04-20 20:14:33 -07:00
Dylan Baker cd8c334788 mconf: cleanup up and sort imports 2021-04-20 13:38:13 -07:00
Dylan Baker 10c19e1206 mconf: print core options for subprojects
Looking in the right dictionary is pretty useful, actually.
2021-04-20 13:25:08 -07: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
Dylan Baker d5238baa45 mconf: only print correct options in the correct sections
A predicate in two comprehensions was dropped, in what looks like a
rebase error on my part. With the predicate added things work correctly.

Fixes: #8344
2021-02-17 14:46:48 +02:00
Jussi Pakkanen 8133a7b9a4 Keep buildtype the same even if user changes debug and/or optimization. 2021-01-19 20:25:55 +00: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
Dylan Baker 71db6b04a3 use OptionKey for builtin and base options
I would have prefered to do these seperatately, but they are combined in
some cases, so it was much easier to convert them together.

this eliminates the builtins_per_machine dict, as it's duplicated with
the OptionKey's machine parameter.
2021-01-04 12:20:40 -08:00
Dylan Baker f9b19e73a5 move OptionKey to mesonlib
There's starting to be a lot of things including coredata that coredata
needs to itself include. putting it in mesonlib makes more sense
2021-01-04 12:20:40 -08:00
Dylan Baker fe973d9fc4 use OptionKey for compiler_options 2021-01-04 12:20:39 -08:00
Dylan Baker 7142c92285 use OptionKey for backend_options 2021-01-04 12:15:41 -08:00
Dylan Baker e2ef6930ff use OptionKey for coredata.user_options 2021-01-04 12:15:41 -08:00
Dylan Baker b37f0cce2c movve insert_build_prefix to mconf
that's the only place it's used anyway.
2021-01-04 12:15:41 -08:00
Dylan Baker b25a423a64 use the OptionKey type for command line and machine files 2021-01-04 12:15:41 -08:00