Commit Graph

209 Commits

Author SHA1 Message Date
Jussi Pakkanen d37d649b08 Make all Meson level options overridable per subproject. 2025-02-13 23:57:48 +02:00
Dylan Baker 9fd5281bef options: Replace uses of `UserOption[T.Any]` with a Union of UserOption types
The fact that UserOption is generic is really an implementation detail,
not something to be used publicly. So by having an `AnyOptionType`
alias, we can get better type checking, as can be seen by the patch as a
whole. One of the big fixes it replace open-coded equivlalents of
`MutableKeydOptionDictType` with that type alias.
2025-02-05 17:45:38 +02:00
Dylan Baker 177148686c options: split UserIntegerOption and UserUmaskOption
They are very similar, but they are not exactly the same. By splitting
them we can get full type safety, and run mypy over the options.py file!
2025-02-05 17:45:38 +02:00
Dylan Baker ba3460eb11 options: Add an EnumeratedUserOption class
This will allow us to take choices out of the UserOption class, which
doesn't actually use this attribute.
2025-02-05 17:45:38 +02:00
Dylan Baker b32e4e87b1 options: Add a printable_choices method to UserOption
This provides a method to get choices for options in a printable form.
The goal is to make refactoring options simpler.
2025-02-05 17:45:38 +02:00
Paolo Bonzini 15c2c98114 introspect: add machine to target_sources
Even though the "targets" introspection info already includes the
command line arguments used to invoke the compiler, this is not
enough to correlated with the "compilers" introspection info and
get extra information from there.

Together with the existing "language" key, adding a "machine" key
is enough to identify completely an entry in the compilers info.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2024-12-19 09:25:20 -08:00
Daniele Nicolodi ec7a81ad86 mintro: Add license and license_files to project introspection data 2024-10-13 19:35:58 +03:00
Daniele Nicolodi d299add709 intro: add install_rpath to intro-install_plan.json 2024-09-03 11:13:11 -07:00
Jussi Pakkanen 0d7bb776e2 Move OptionKey in the option source file. 2024-07-11 11:53:39 +03:00
Jussi Pakkanen c2552527fb Move compiler option check into OptionStore. 2024-07-11 11:53:39 +03:00
Jussi Pakkanen 5c6e9d2d8f Move builtin option check into OptionStore. 2024-07-11 11:53:39 +03:00
Jussi Pakkanen 472d8852e9 Move backend option check into OptionStore. 2024-07-11 11:53:39 +03:00
Jussi Pakkanen 0c36ace4b7 Move base option check into OptionStore. 2024-07-11 11:53:39 +03:00
Jussi Pakkanen 8e3f609e73 Move project option detection into OptionStore. 2024-07-11 11:53:39 +03:00
Jussi Pakkanen 181c3499fd Fix mypy. 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
Filipe Laíns e5aed6ac8f mintro: write humman-readable JSON
Signed-off-by: Filipe Laíns <lains@riseup.net>
2024-06-01 13:34:01 +03:00
Jussi Pakkanen 5365d9a842 Refactor option classes to their own file. 2024-05-23 21:26:45 +03:00
Charles Brunet bd4fd90730 parser: revert to single StringNode type
this will allow transforming string types in the formater
2024-04-08 10:43:57 -07: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
Tristan Partin e107b40225
Remove unused parameter in IntroCommand::get_meson_introspection_types() 2023-10-04 15:28:23 -04:00
Charles Brunet 306562b466 parser: use IdNode for function name and assignment name 2023-09-11 07:51:18 -04:00
Charles Brunet 35936283d2 parser: preserve escape chars in strings
use separate Node for multiline strings
2023-09-11 07:51:18 -04:00
Xavier Claessens 4eb9c84cf9 include_directories: Always add both source and build dirs
Compiler checks were not adding build dir side, which prevents using
headers generated with configure_file().
2023-08-28 20:18:26 -04:00
Eli Schwartz 90ce084144
treewide: automatic rewriting of all comment-style type annotations
Performed using https://github.com/ilevkivskyi/com2ann

This has no actual effect on the codebase as type checkers (still)
support both and negligible effect on runtime performance since
__future__ annotations ameliorates that. Technically, the bytecode would
be bigger for non function-local annotations, of which we have many
either way.

So if it doesn't really matter, why do a large-scale refactor? Simple:
because people keep wanting to, but it's getting nickle-and-dimed. If
we're going to do this we might as well do it consistently in one shot,
using tooling that guarantees repeatability and correctness.

Repeat with:

```
com2ann mesonbuild/
```
2023-08-11 13:41:03 -04:00
Eli Schwartz de1cc0b02b
rewrite a couple comment-style type annotations for oddly indented dicts
Make them into real type annotations. These are the only ones that if
automatically rewritten, would cause flake8 to error out with the
message: "E128 continuation line under-indented for visual indent".
2023-08-11 13:39:07 -04:00
Eli Schwartz a7a3563c0d
fix a few miscellaneous implicit-optional typing issues 2023-07-24 14:25:33 -04:00
Eli Schwartz 0bb1647fd1
move various bits of type-checking only code to TYPE_CHECKING blocks
Mostly detected with flake8-type-checking. Also quote T.cast() first
arguments, since those are not affected by future annotations.
2023-07-19 18:31:37 -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
Daniele Nicolodi c900e6b0b3 mintro: record subproject in install_plan 2023-06-26 23:06:29 -04:00
Charles Brunet 8d30577a2d intro: add more details to generated files(part 2)
- add `extra_paths` to intro-tests.json to know paths needed to run a
  test on Windows;
- add `depends` to alias targets in intro-targets.json to know what
  targets does an alias point to;
- add `depends` to intro-dependencies.json to know libraries linked with
  an internal dependency;
- renamed `deps` to `dependencies` in `intro-dependencies.json` for more
  uniformity.
2023-05-22 22:12:29 +03:00
Charles Brunet 5eb55075ba intro: add more details to generated json files
This will help with the writing of tools to generate
VisualStudio project and solution files, and possibly
for other IDEs as well.

- Used compilers a about `host`, `build` and `target` machines
  arere listed in `intro-compilers.json`
- Informations lister in `intro-machines.json`
- `intro-dependencies.json` now includes internal dependencies,
  and relations between dependencies.
- `intro-targets.json` now includes dependencies, `vs_module_defs`,
  `win_subsystem`, and linker parameters.
2023-04-20 18:31:39 +03:00
Dylan Baker 4a014d1724 Add support for meson.options as a replacement for meson_options.txt
We will still try to load `meson_options.txt` if `meson.options` doesn't
exist. Because there are some advantages to using `meson.options` even
with older versions of meson (such as better text editor handling)
we will not warn about the existence of a `meson.options` file if a
`meson_options.txt` file or symlink also exists.

The name `meson.options` was picked instead of alternative proposals,
such as `meson_options.build` for a couple of reasons:

  1. meson.options is shorter
  2. While the syntax is the same, only the `option()` function may be
     called in meson.options, while, it may not be called in meson.build
  3. While the two files share a syntax and elementary types (strings,
     arrays, etc), they have different purposes: `meson.build` declares
     build targets, `meson.options` declares options. This is similar to
     the difference between C's `.c` and `.h` extensions.

As an implementation detail `Interpreter.option_file` has been removed,
as it is used exactly once, in the `project()` call to read the options,
and we can just calculate it there and not store it.

Fixes: #11176
2023-03-28 15:01:10 +03:00
Charles Brunet a0d0fb5492 mintro: redirect stdout to stderr 2023-03-02 10:10:03 -05:00
Daniele Nicolodi f39ccde513 mintro: Add exclude_{files, dirs} to install_subdir install_plan
These are necessary for projects outside Meson itself that want to
extend the 'meson install' functionality as meson-python does to
assemble Python package wheels from Meson projects.

Fixes #11426.
2023-02-27 07:03:30 -05:00
Dylan Baker f5283dd63f pylint: enable global-statement
This does force a number of uses of `# pylint: disable` comments, but it
also finds a couple of useless global uses and one place (in the
previous commit) that an easy refactor removes the use of global. Global
is a code smell, so forcing adding a comment to disable helps force
developers to really consider if what they're doing is a good idea.
2022-09-22 18:17:43 -04:00
Dylan Baker 4da14918cd pylint: enable consider-using-in 2022-09-19 20:57:52 -04:00
Dylan Baker b11cf2f371 pylint: enable consider-using-dict-items
Which found a couple of places where we could write better code.
2022-09-19 20:57:52 -04:00
Thomas Li a4d5442207 Fix install_subdirs not showing up in intro-install_plan.json 2022-09-06 02:09:38 -04:00
Eli Schwartz 3e73d4d77d
introspection: untangle install_plan implemetation, fix a bunch of wrong ones
Generally plumb through the values of get_option() passed to
install_dir, and use this to establish the install plan name. Fixes
several odd cases, such as:

- {datadir} being prepended to "share" or "include"

- dissociating custom install directories and writing them out as
  {prefix}/share/foo or {prefix}/lib/python3.10/site-packages

This is the second half of #9478
Fixes #10601
2022-08-22 14:15:22 -04:00
Eli Schwartz 0703ee0aef
move various unused typing-only imports into type-checking blocks 2022-07-03 14:11:31 -04:00
Eli Schwartz 075ccc68be
sort imports for neatness 2022-07-03 14:11:30 -04:00
Dylan Baker 2a0082b13a ast: rename module constant to match PEP8 style 2022-06-01 22:49:10 -04:00
Xavier Claessens 06d12064d0 OptionOverrideProxy: Make it immutable to avoid copies
It is always used as an immutable view so there is no point in doing
copies. However, mypy insist it must implement the same APIs as
Dict[OptionKey, UserOption[Any]] so keep faking it.
2022-03-22 17:20:48 -04:00
Jussi Pakkanen ade6e3a19e
Merge pull request #10043 from dcbaker/submit/type-checking-for-subproject
Add typing for subproject()
2022-03-07 16:43:44 +02:00
Xavier Claessens 01e92dc543 Fix default install tag for shared lib symlinks
Versioned shared libraries should have .so file in devel, .so.1 and
.so.1.2.3 in runtime.

Fixes: #9811
2022-03-07 09:27:02 -05: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
Paolo Bonzini 5e96730d7d introspect: include choices for array options
There was even a test covering this, but it did not fail due to a typo.
2021-10-14 09:04:25 -04:00
Eli Schwartz c94d6acc49
remove printf debugging
Why did this dumb thing of mine ever get committed???
2021-10-04 18:37:03 -04:00