Commit Graph

60 Commits

Author SHA1 Message Date
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 51b361fdbe optinterpreter: organize the validation of arguments to be more readable 2020-11-20 14:48:35 -08:00
Dylan Baker 226945bbc7 optinterpreter: use PEP8 compliant names 2020-11-20 14:48:35 -08:00
Dylan Baker 49f8ff8410 optinterpreter: fix value being set in loop
This value shouldn't be set in the loop, it's probably been making
things slow, but also creates the potential that if choices is an empty
list that value would be unbound. While that's exteremly unlikly to
happen in practice, it is showing up as a warning from pylance.
2020-11-20 14:48:35 -08:00
Dylan Baker 93ecfa646b Add type annotations to optinterpreter 2020-11-20 14:48:35 -08:00
Dylan Baker f342efd080 pylint: turn on bad-indentation error
and fix all of the bad indentation
2020-09-22 17:57:03 -07:00
Daniel Mensinger 23818fc5a3
typing: more fixes 2020-09-08 20:15:58 +02:00
John Ericson 2447a1132a Capitalize some constants in coredata
I've been getting confused between them and similarly-named other
things, so I figured it was high time to clean this up.
2020-08-04 00:24:05 +03:00
Daniel Mensinger 534b340a56 opts: Add FeatureNew for '-' and 'not' introduced in 0.54.1 2020-05-26 13:48:26 -04:00
Daniel Mensinger 7e8f1de063 opts: Allow string concatenation (fixes #7199) 2020-05-26 13:48:26 -04:00
Dylan Baker c64715b99a optinterpreter: Enable and update FeatureNew to use_single
With the version information fixed we can use a FeatureNew inside the
optinterpreter, so let's do it.
2020-05-14 12:15:03 -07:00
Daniel Mensinger 03b86cdbed opts: Allow `-` and `not` in meson_options.txt (fixes #6948) 2020-04-11 18:58:26 -04:00
Daniel Mensinger c14aea2812
types: Annotate mparser.py
This also fixes that the keys in ArgumentNode.kwargs are
all of the type BaseNode now. Before this commit, it was
possible that both strings and Nodes where used as keys.
2020-03-02 10:34:55 +01:00
Jon Turney 346b5c4be7
Store filename in node location
Warnings have a location node object (with subdir and lineno
attributes), which is passed as a location: kwarg to mlog.warning() and
formatted in _log_error().

Re-purpose the subdir attribute (path relative to the source root dir,
with an implied filename of 'meson.build'), which is stored into the
node by parser(), to contain a pathname.

(Properly I should rename 'subdir' -> 'file' everywhere, but that's a
lot of churn just to see if this works)

Notes:
The warning location node may also have a colno attribute, which is
currently ignored by _log_error().

We can't currently issue warnings with locations in meson_options.txt
because the filename isn't part of the location (as it's assumed to be
'meson.build).
2020-02-28 11:54:04 +00:00
Jon Turney 534a974da7
Adjust all the other places MesonException file attribute is set
A MesonException has file, lineno and colno attributes, which get
formatted as a location in mlog.exception().

The file attribute got changed from a path relative to the root source
directory to a pathname (absolute or relative to cwd) in one place in
commit b8fbbf59.  Adjust all the other places the file attribute is set
to match.

Also:
Setting MesonException.file seems to be missing in the case where Parser
returned a non-CodeBlockNode object.  Fortunately, that looks like it's
unreachable, but add it just in case.
2020-02-28 11:54:04 +00:00
Jussi Pakkanen 6b5c1a4fc3 Refactor UserIntegerOption to work with BuiltinOption. 2020-02-12 22:31:08 +02:00
Daniel Mensinger 09b53c534f types: import typing as T (fixes #6333) 2020-01-08 15:28:17 +01:00
Jussi Pakkanen d7a682fded No need to reserve build_ because we use build. instead. 2019-07-15 14:13:55 -07:00
Jussi Pakkanen da1f663e8d Reserve build_ prefix in option names. 2019-05-20 22:53:06 +03:00
John Ericson 4030e7cb7a UserOption no longer has a name field.
This avoids the duplication where the option is stored in a dict at its
name, and also contains its own name. In general, the maxim in
programming is things shouldn't know their own name, so removed the name
field just leaving the option's position in the dictionary as its name.
2019-05-15 14:21:47 +03:00
Dylan Baker 068c3bf60a optinterpreter: Add a log argument to is_invalid_name
Since we're adding arguments that use the cross_ prefix but are valid
we don't want to print "warning invalid argument name!", as that will
confuse people by virtue of being wrong.
2019-04-05 09:26:42 -07:00
Dylan Baker 05ad69a1c7 optinterpreter: Add type annotations to is_invalid_name 2019-04-05 09:26:42 -07:00
Dylan Baker c6060d795c coredata: remove get_builtin_options
This returns a list out of th keys of a dict. In both cases of use
remaining though it's used for checking membership, checking for list
membership, lists are O(n) lookup, while dicts are O(1), so removing
the abstraction reduces typing and improves performance.
2019-04-04 15:02:20 -07:00
Jussi Pakkanen 3d0b110ec2 Reserve cross_ option prefix for Meson. 2019-03-19 06:28:21 +00:00
Xavier Claessens 5f9fda4acc UserFeatureOption: Default to 'auto' when no value specified
Closes #3938.
2018-07-25 09:55:16 -04:00
Nirbheek Chauhan a1d9adba09 FeatureNew: Make all checks subproject-specific
We now pass the current subproject to every FeatureNew and
FeatureDeprecated call. This requires a bunch of rework to:

1. Ensure that we have access to the subproject in the list of
   arguments when used as a decorator (see _get_callee_args).
2. Pass the subproject to .use() when it's called manually.
3. We also can't do feature checks for new features in
   meson_options.txt because that's parsed before we know the
   meson_version from project()
2018-07-02 19:52:53 +05:30
Xavier Claessens e565945253 Add UserFeatureOption type
This is a special type of option to be passed to most 'required' keyword
arguments. It adds a 3rd state to the traditional boolean value to cause
those methods to always return not-found even if the dependency could be
found.

Since integrators doesn't want enabled features to be a surprise there
is a global option "auto_features" to enable or disable all
automatic features.
2018-06-18 04:57:32 +00:00
Xavier Claessens 7c4736d27f Convert args.projectoptions into a dict
This simplifies a lot of code, and centralize "key=value" parsing in a
single place.

Unknown command line options becomes an hard error instead of
merely printing warning message. It has been warning it would become an
hard error for a while now. This has exceptions though, any
unknown option starting with "<lang>_" or "b_" are ignored because they
depend on which languages gets added and which compiler gets selected.
Also any option for unknown subproject are ignored because they depend
on which subproject actually gets built.

Also write more command line parsing tests. "19 bad command line
options" is removed because bad cmd line option became hard error and
it's covered with new tests in "30 command line".
2018-06-06 20:02:37 +00:00
Xavier Claessens 218ed2de89 optinterpreter: Remove duplicated list of languages
It is important to keep the list of languages up to date in
optinterpreter, otherwise we could have conflicting options when adding
new languages.
2018-06-06 20:02:37 +00:00
Salamandar 364b8a37b9 Add 0.45.0 features 2018-06-01 14:23:24 +02:00
Salamandar c90885de6d Add 0.44.0 features 2018-06-01 14:23:24 +02:00
Thibault Saunier 62165aef43 options: s/yiel/yield/ typo
Making the option unusable with Invalid kwargs for option use_orc: "yield"
2018-03-20 07:05:24 +00:00
Hemmo Nieminen ff1146bc8c Fix subproject prefix handling when checking subproject option validity. 2018-02-16 00:09:47 +02:00
Jussi Pakkanen 54d7817087 User options can "yield to" a user option of the same name in superproject. Closes ##2853. 2018-02-08 00:33:44 +02:00
Jussi Pakkanen 0204895143 Expose integer options to build option files. 2018-02-07 22:10:04 +02:00
Dylan Baker e245e57865 Warn on unknown command line arguments
I have a tendency to typo things. Humans in general are bad at spotting
spelling mistakes, computers are not. This patches prints the bad
options and provides the generic meson "This will be a hard error
someday" message.
2017-12-19 10:10:40 -08:00
Jussi Pakkanen 4ae0cadb7f Renamed UserStringArrayOption to UserArrayOption for short. 2017-12-07 00:00:34 +02:00
Jussi Pakkanen f8a419b27d String arguments can permit arbitrary string values
by leaving out the choices keyword.
2017-12-03 22:27:55 +02:00
Dylan Baker c9351ce30c Add new array type option
This exposes the already existing UserStringArrayOption class through
the meson_options.txt. The intention is to provide a way for projects to
take list/array type arguments and validate that all of the elements in
that array are valid without using complex looping constructrs.
2017-11-29 14:14:41 -08:00
Xavier Claessens b8187961b9 coredata: Remove parse_string() method
set_value() already does a better job at parsing strings, such as
accepting "True" for a boolean.

This fixes issue #2544
2017-11-06 20:55:05 +02:00
Dylan Baker 7dfad54f06 options: Add a permitted_kwargs function
I've typo'd "value" for the last time, options needs a kwargs validator.
This validator is slightly different than the one used by the main
parser, since it operates on a much simpler representation than the
other one does, and they are not interchangeable.

This also changes the optinterpreter to use pop on 'type' and
'description' so that they're not passed to the validator as kwargs.
2017-10-04 09:53:06 -07:00
Jussi Pakkanen a800c96f99 Add option to limit maximum number of concurrent link processes. 2017-08-05 00:24:59 +03:00
Nirbheek Chauhan 8ee9365717 Allow option values to contain ':'
Instead, check that option keys don't contain ':'. Also change the
failing option test to look for this.

Closes https://github.com/mesonbuild/meson/issues/1454
2017-04-04 23:41:23 +05:30
Mike Sinkovsky 969be1f679 cleanup: Remove redundant parentheses 2017-01-18 21:22:47 +02:00
Jussi Pakkanen 55cdba635e Merge pull request #1260 from mesonbuild/subproj_defaults
Can set subproject option defaults from command line and master project
2017-01-03 16:03:18 -05:00
Igor Gnatenko 969dc7e995 style: fix E124 violations
E124: closing bracket does not match visual indentation

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2017-01-01 12:02:05 -05:00
Jussi Pakkanen b55235dfbd Fix space before :. 2016-12-31 16:28:15 +02:00
Jussi Pakkanen 73042c7912 Can set project options (but not global options) in subproject default options. 2016-12-29 19:30:58 +02:00
Elliott Sales de Andrade d517bbfb5c Raise clearer error if -Doption is invalid. 2016-12-21 16:58:11 +02:00
Igor Gnatenko 139e020ede tree-wide: use proper 'not in' notation
Let's be more pythonic and 'not is' seems really weird.

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-12-19 21:48:35 +01:00