Commit Graph

478 Commits

Author SHA1 Message Date
Xavier Claessens 48c17b7ae6 UserArrayOption: Remove user_input argument
The only place it can be set to False is from optinterpreter. Better
check value there and deprecate string usage.
2023-08-06 09:39:55 -04:00
Eli Schwartz d4615369ff fix lint errors revealed by pycodestyle 2.11
When performing isinstance checks, an identity comparison is
automatically done, but we don't use isinstance here because we need
strict identity equality *without allowing subtypes*.

Comparing type() == type() is a value comparison, but could produce
effectively the same results as an identity comparison, usually, despite
being semantically off. pycodestyle learned to detect this and warn you
to do strict identity comparison.
2023-07-31 11:00:22 -07:00
Jussi Pakkanen 0dba7340ec
Merge pull request #11976 from tristan957/cleanups
Some various type related cleanups
2023-07-17 00:29:37 +03:00
Jussi Pakkanen b60ea0851b Bump version number for new development. 2023-07-17 00:28:14 +03:00
Jussi Pakkanen abe01ae3d6 Bump version number for release. 2023-07-17 00:21:45 +03:00
Tristan Partin ffa5483564 Add typing to portions of machine file parsing 2023-07-12 18:56:06 -05:00
Tristan Partin b0f1f374e7 Add type annotations where they previously didn't exist 2023-07-12 18:56:06 -05:00
Tristan Partin d732e27e46 Use more specific types
Added type arguments where needed.
2023-07-12 18:56:06 -05:00
Tristan Partin 33c8362a1c Match the method signatures of parent classes
Names and types of some methods did not match their parent methods.
2023-07-12 18:56:06 -05:00
Tristan Partin d4bcf05c39 Annotate naked fundamental Python types
Although mypy wasn't complaining, pyright was.
2023-07-12 18:56:06 -05:00
Tristan Partin 921c2370a7 Replace some type comments with annotations 2023-07-12 18:56:06 -05:00
Tristan Partin 1624354f33 Use CompileCheckMode enum
There were a ton of naked strings with TODOs telling us to use the enum.
2023-07-12 18:56:06 -05:00
Jussi Pakkanen de44455b4b Bump version number for rc3. 2023-07-11 21:58:14 +03:00
Jussi Pakkanen dd3c39242b Bump version number for rc2. 2023-07-05 23:56:33 +03:00
Eli Schwartz 098ac5e0a6
genvslite: fix badly overflowing line lengths
Function comments that overflow the screen width by coming after code,
instead of on their own line, are hard to read. Same applies to message
strings that are all on one line. Fix by reflowing them.

Post-facto application of issues that were caught during post-merge
review, after the genvslite PR was merged without a full review.
2023-07-02 18:03:21 -04:00
Eli Schwartz 0520667973
genvslite: improve readability of the mconf help text
The option description has a lot of data packed into it, which is
squeezed into a small, hard to read column. Give a bit less information,
focusing on essentials, to make it fit better.

Post-facto application of issues that were caught during post-merge
review, after the genvslite PR was merged without a full review.
2023-07-02 18:03:21 -04:00
Jussi Pakkanen 9a6a95483c Bump version number for rc1. 2023-06-28 17:50:49 +03:00
GertyP 36bf53bdfd
Experimental 'genvslite' WIP. (#11049)
* Capture all compile args from the first round of ninja backend generation for all languages used in building the targets so that these args, defines, and include paths can be applied to the .vcxproj's intellisense fields for all buildtypes/configurations.

Solution generation is now set up for mutiple build configurations (buildtypes) when using '--genvslite'.

All generated vcxprojs invoke the same high-level meson compile to build all targets;  there's no selective target building (could add this later).  Related to this, we skip pointlessly generating vcxprojs for targets that aren't buildable (BuildTarget-derived), which aren't of interest to the user anyway.

When using --genvslite, no longer inject '<ProjectReference ...>' dependencies on which a generated .vcxproj depends because that imposes a forced visual studio build dependency, which we don't want, since we're essentially bypassing VS's build in favour of running 'meson compile ...'.

When populating the vcxproj's shared intellisense defines, include paths, and compiler options fields, we choose the most frequent src file language, since this means more project src files can simply reference the project shared fields and fewer files of non-primary language types need to populate their full set of intellisense fields.  This makes for smaller .vcxproj files.

Paths for generated source/header/etc files, left alone, would be added to solution projects relative to the '..._vs' build directory, where they're never generated;  they're generated under the respective '..._[debug/opt/release]' ninja build directories that correspond to the solution build configuration. Although VS doesn't allow conditional src/header listings in vcxprojs (at least not in a simple way that I'm aware of), we can ensure these generated sources get adjusted to at least reference locations under one of the concrete build directories (I've chosen '..._debug') under which they will be generated.

Testing with --genvslite has revealed that, in some cases, the presence of 'c:\windows\system32;c:\windows' on the 'Path' environment variable (via the make-style project's ExecutablePath element) is critical to getting the 'meson compile ...' build to succeed.  Not sure whether this is some 'find and guess' implicit defaults behaviour within meson or within the MSVC compiler that some projects may rely on. Feels weird but not sure of a better solution than forcibly adding these to the Path environment variable (the Executable Path property of the project).

Added a new windows-only test to windowstests.py ('test_genvslite') to exercise the --genvslite option along with checking that the 'msbuild' command invokes the 'meson compile ...' of the build-type-appropriate-suffixed temporary build dir and checks expected program output.

Check and report error if user specifies a non-ninja backend with a 'genvslite' setup, since that conflicts with the stated behaviour of genvslite.  Also added this test case to 'WindowsTests.test_genvslite'

I had problems tracking down some problematic environment variable behaviour, which appears to need a work-around. See further notes on VSINSTALLDIR, in windowstests.py, test_genvslite.
'meson setup --help' clearly states that positional arguments are ... [builddir] [sourcedir].  However, BasePlatformTests.init(...) was passing these in the order [sourcedir] [builddir].  This was producing failures, saying, "ERROR: Neither directory contains a build file meson.build." but when using the correct ordering, setup now succeeds.

Changed regen, run_tests, and run_install utility projects to be simpler makefile projects instead, with commands to invoke the appropriate '...meson.py --internal regencheck ...' (or install/test) on the '[builddir]_[buildtype]' as appropriate for the curent VS configuration.  Also, since the 'regen.vcxproj' utility didn't work correctly with '--genvslite' setup build dirs, and getting it to fully work would require more non-trivial intrusion into new parts of meson (i.e. '--internal regencheck', '--internal regenerate', and perhaps also 'setup --reconfigure'), for now, the REGEN project is replaced with a simpler, lighter-weight RECONFIGURE utility proj, which is unlinked from any solution build dependencies and which simply runs 'meson setup --reconfigure [builddir]_[buildtype] [srcdir]' on each of the ninja-backend build dirs for each buildtype.
Yes, although this will enable the building/compiling to be correctly configured, it can leave the solution/vcxprojs stale and out-of-date, it's simple for the user to 'meson setup --genvslite ...' to fully regenerate an updated, correct solution again. However, I've noted this down as a 'fixme' to consider implementing the full regen behaviour for the genvslite case.

* Review feedback changes -
- Avoid use of 'captured_compile_args_per_buildtype_and_target' as an 'out' param.
- Factored a little msetup.py, 'run(...)' macro/looping setup steps, for genvslite, out into a 'run_genvslite_setup' func.

* Review feedback:  Fixed missing spaces between multi-line strings.

* 'backend_name' assignment gets immediately overwritten in 'genvslite' case so moved it into else/non-genvslite block.

* Had to bump up 'test cases/unit/113 genvslites/...' up to 114; it collided with a newly added test dir again.

* Changed validation of 'capture' and 'captured_compile_args_...' to use MesonBugException instead of MesonException.

* Changed some function param and closing brace indentation.
2023-06-28 15:29:57 +03:00
Eli Schwartz e715400d1b
tree-wide: reduce unneeded imports on specific Dependency impls
We can check something's subtype using properties, without importing the
module up front and doing isinstance checks on specific subclasses of
the interface -- or worse, solving cyclic imports by doing the import
inside the function. ;)
2023-06-26 13:10:32 -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 c16dd8d711 coredata: Malformed machine file is not a Meson bug
Fixes: #11899
2023-06-23 06:03:20 -04:00
Xavier Claessens c503c757f1 coredata: Fix wrong stable_version value 2023-06-13 21:14:34 -04:00
Xavier Claessens d8cb62bf2b Allow targetting Meson 1.2.0 when version is 1.1.99
When a project targets a dev version of Meson (e.g. 1.1.99) for
experimenting, this allows to use:

  project(..., meson_version: '>=1.2.0')

It avoids getting warnings when using FeatureNew for features introduced
in 1.2.0.
2023-06-13 10:32:48 -04:00
Eli Schwartz 95b03f7930 avoid clearing the dependency cache unnecessarily based on wrap-mode
We actually do not and should not care about wrap-mode at all for this.
We want to cache dependency lookups whenever humanly possible, but only
use them in cases where we would anyways be using them -- which in
particular means if we said to force a subproject fallback for this dep,
we want to bypass the cache.

Currently, we handle this by always looking up the cache for all
dependencies, but clearing the cache at startup if a reconfigure means
we are changing our resolution strategy. This is bad -- we might have
many dependencies that are worth caching, and only one dependency that
should stop being cached and use a subproject instead.

The simple solution is to handle the forcefallback case when doing a
cache lookup, and not do a cache lookup at all. Now we don't have to
nuke the entire cache. In fact, if a future reconfigure changes the
forcefallback state back to not being forced, we can reuse the original
cached dependency, which is still there.

Closes #11828
2023-05-29 15:04:34 -04:00
Eli Schwartz d3804d0579
Remove pointless install_umask validation check for None
This option can never have a value of None. There are only two sources
of values at all:

- the class instance initializer when defining BUILTIN_CORE_OPTIONS
- user-provided command-line or machine file values etc. which can only
  be meson types

We know we don't construct the Option instance with None, and users
cannot pass a None anywhere since that's not a meson type. The only
reason this was ever checked for was as an artifact during the initial
implementation of the option in commit 8651d55c6a.

At the time, a review comment was made that `-Dinstall_umask=none` was a
bad UX and "preserve" should be used instead. Before that, this option
type accepted `None` (in the BUILTIN_CORE_OPTIONS initializer) and
`'none'` (provided by users) which is odd and should have consistently
been the latter. Then inside set_value, it checked for the magic
initializer value and converted it to the real value.

After review comments and a force-push, the patch ended up using `None`
in the initializer, and `'preserve'` everywhere else, and still handling
both in set_value and converting both to a proper string.

In the very next commit in the patch series, the initializer was
migrated to use an actual umask of 022, and now `None` was entirely
impossible to get anywhere at all. But the wart of checking for it was
never removed. Remove it at long last.
2023-05-24 19:05:06 -04:00
Volker Weißmann 2699fd4b8a During reconfigure, show that no compiler was found, if compiler fails sanity check. 2023-05-13 11:06:24 +03:00
Eli Schwartz 0e7fb07f91
python module: add an automatic byte-compilation step
For all source `*.py` files installed via either py.install_sources() or
an `install_dir: py.get_install_dir()`, produce `*.pyc` files at install
time. Controllable via a module option.
2023-05-02 19:28:35 -04:00
Josh Soref cf9fd56bc9 fix various spelling issues
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-11 19:21:05 -04:00
Jussi Pakkanen eb472a133f Bump version number for new development. 2023-04-10 20:01:06 +03:00
Jussi Pakkanen ae163a3f3e Bump version number for release. 2023-04-10 18:39:25 +03:00
Jussi Pakkanen 71487c876e Bump version number for rc2. 2023-04-02 22:52:22 +03:00
Xavier Claessens ad151d9f11 coredata: Fix changing prefix option
This is a regression from #11537.
2023-03-30 17:01:04 -04:00
Xavier Claessens b30cd5d2d5 Make --vsenv a readonly builtin option
We need to remember its value when reconfiguring, but the Build object
is not reused, only coredata is.

This also makes CLI more consistent by allowing `-Dvsenv=true` syntax.

Fixes: #11309
2023-03-29 09:33:41 -04:00
Jussi Pakkanen 697b42f022 Bump version number for rc1. 2023-03-28 17:21:47 +03:00
Xavier Claessens 567d1fec9b Make backend option read-only 2023-03-28 00:36:37 +03:00
Eli Schwartz a024d75e15
backends: add a new "none" backend
It can only be used for projects that don't have any rules at all, i.e.
they are purely using Meson to:

- configure files
- run (script?) tests
- install files that exist by the end of the setup stage

This can be useful e.g. for Meson itself, a pure python project.
2023-03-20 17:22:50 -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
Dylan Baker 7c2ac4f8fe utils: fix annotation of pickle_load
It's actually Generic, and we should use Generic annotations to get the
correct result. This means that we don't have to assert or cast the
return type, because mypy just knowns
2023-03-09 19:03:44 -05:00
Andres Freund 9a41ce58d6 Add Compiler.cached_run()
Caching Compiler.run() seems likely to cause problems, but some users, like
.sizeof(), we know enough about the program run to make it safe.

This commit just adds the Compiler.cached_run(), a subsequent commit makes use
of it.
2023-02-27 20:09:32 -05:00
Eli Schwartz 680b5ff819
treewide: add future annotations import 2023-02-01 17:01:30 -05:00
X512 3074731797 haiku: set default prefix and library paths 2023-01-20 14:57:33 -05:00
Dylan Baker c8b8e7e732 coredata: allow deprecation to be passed to Option initializer
Instead of requiring it to be set outside the initializer
2023-01-20 00:18:42 -05:00
Dylan Baker 432c46e67c coredata: get rid of UserArrayOption `**kwargs`
Let's just pass the two arguments explicitly.
2023-01-20 00:18:42 -05:00
Dylan Baker 93e370c7dd coredata: use DEFAULT_YIELDING as the default value for Options
Instead of setting it to `Optional[bool] = None`, and then in the
initializer replacing `None` with `DEFAULT_YIELDING`, just set to to
`bool = DEFAULT_YIELDING`
2023-01-20 00:18:42 -05:00
Dylan Baker 3f733437da coredata: use a frozenset instead of a dict where values are always None 2023-01-20 00:18:42 -05:00
Dylan Baker e0efc7603e coredata: Make a deepcopy of global state before mutating
When a compiler is initialized, it adds specific options that it
supports, but taking some global UserOption objects and adding them to
itself. When it does so, it mutates then if necessary. This means that
each compiler initialized mutates global state, this is bad. This is
worse because in our test suite we do in process testing, so these
mutations are preserved *between tests*, potentially leading to
incorrect results. The simple fix is to do the right thing, and copy the
UserOption before mutating. A deepcopy is required because the option
might be an ArrayOption, and a shallow copy is not sufficient in that
case.
2023-01-18 17:55:41 -05:00
Xavier Claessens e96929f1b2 coredata: Remove dead code 2023-01-11 14:13:18 -05:00
Dylan Baker f7cde8d3f6 Add fatal=False to many mlog.warnings()
There are lots of warnings that become fatal, that are simply unfixable
by the end user. Things like using old versions of software (because
they're using some kind of LTS release), warnings about compilers not
supporting certain kinds of checks, or standards being upgraded due to
skipped implementations (MSVC has c++98 and c++14, but not c++11). None
of these should be fatal, they're informative, and too important to
reduce to notices, but not important enough to stop meson if they're
printed.
2023-01-03 14:49:02 -05:00
Eli Schwartz 0544ffabf1
add builtin option to install licenses
Unless `meson.install_dependency_manifest()` is explicitly used, this
will cause a default implied one to be installed.
2022-12-27 20:29:46 -05:00