Commit Graph

134 Commits

Author SHA1 Message Date
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
Xavier Claessens 7902d2032d Refactor handling of machine file options
It is much easier to not try to parse options into complicated
structures until we actually collected all options: machine files,
command line, project()'s default_options, environment.
2020-10-16 17:42:24 -04:00
Daniel Mensinger 23818fc5a3
typing: more fixes 2020-09-08 20:15:58 +02:00
Dylan Baker af763e093a mconf/mintro: use authoritative list of options from coredata
This splits the directory options and non-directory options into two
dicts, and then merges them later to maintain API.
2020-08-01 22:00:06 -07:00
Xavier Claessens e191cbf6e9 mconf: Fix regression when printing all options
This is a regression introduced by #5489
2020-06-18 17:39:43 +03:00
John Ericson 278c294aa4 Compiler options per lang
A current rather untyped storage of options is one of the things that
contributes to the options code being so complex. This takes a small
step in synching down by storing the compiler options in dicts per
language.

Future work might be replacing the langauge strings with an enum, and
defaultdict with a custom struct, just like `PerMachine` and
`MachineChoice`.
2020-04-20 23:23:15 +03:00
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 c6b512e64d mconf: Fix printing options when there is no compiler/project options
Closes: #6087
2019-10-22 22:32:34 +03:00
Xavier Claessens 88e77e69bc mconf: Group all options per subproject and align all groups
Also hide value of yielding subproject options to make it clear the
value must be set on the main project.
2019-10-18 00:49:27 +03:00
Daniel Mensinger 47bdea5040 mconf: Fix meson configure crash (fixes #5909) 2019-09-13 15:44:02 +03:00
Jussi Pakkanen 8a4aceef43 Do not print build and host settings when compiling natively. 2019-08-06 21:34:15 +03:00