Commit Graph

12926 Commits

Author SHA1 Message Date
Liam Beguin 3f86f19f95 completions: bash: define sub-commands as an array
Define subcommands as an array so that they can be reused for the
top-level sub-command completion.

Signed-off-by: Liam Beguin <liambeguin@gmail.com>
2022-09-18 15:22:48 -04:00
Liam Beguin 24e97e1945 completions: bash: update meson sub-command list
Add all meson sub-commands to the autocompletion script.

Signed-off-by: Liam Beguin <liambeguin@gmail.com>
2022-09-18 15:22:48 -04:00
Liam Beguin f08c788f61 completions: bash: add missing functions
Add empty functions for all commands defined in the autocompletion script.
When these functions are not defined, bash raises the following error:

       $ meson init <TAB>-bash: _meson-init: command not found

Signed-off-by: Liam Beguin <liambeguin@gmail.com>
2022-09-18 15:22:48 -04:00
Liam Beguin ebe14848e0 completions: bash: order function definitions like in help
Move _meson-introspect() to follow the command list defined at the top
of the script which follows the help message order.

Signed-off-by: Liam Beguin <liambeguin@gmail.com>
2022-09-18 15:22:48 -04:00
Xavier Claessens 7e4188a53f devenv: Resolve executable in devenv's PATH
Fixes: #10815
2022-09-15 10:04:59 -04:00
Eli Schwartz d924586bee
docs: note the automatic creation of gitignore in build directories 2022-09-14 18:53:53 -04:00
Yang Bo 83d18d137d Use os.path.realpath for default include paths testing in -isystem.
This ensures correct removal of default include paths in -isystem
options when symbolic links are involved.

A test for this is also added.
2022-09-13 02:24:38 -04:00
Eli Schwartz 719dd0d2a0
dependencies: log the real reason for a dependency lookup failing
In the debug logs, always log if a dependency lookup raises a
DependencyException. In the `required: false` case, this information
would otherwise disappear forever, and we would just not even log that
we tried it -- it doesn't appear in "(tried x, y and z)".

In the `required: true` case, we would re-raise the first exception if
it failed to be detected. Update the raise message with the same
information we print to the debug logs, indicating which dependency and
which method was used in the failing attempt.
2022-09-12 19:16:59 -04:00
Eli Schwartz b821a03511
dependencies: use better internal representation of factory methods
functools.partial preserves information about how the method was
created, lambdas do not. Also, we just want to freeze the first argument
and forward the rest anyway.

This also lets us get rid of a mypy error that was being ignored.
2022-09-12 19:16:59 -04:00
Eli Schwartz 7972c49bda
dependencies: simplify log_tried into a staticmethod
It doesn't really need class instantiation to just know what type it is,
and this way we can get the information early if a dependency fails to
init.
2022-09-12 19:16:59 -04:00
Eli Schwartz 36e7748d02
dependencies: simplify logging methods
A bunch of SystemDependency subclasses overrode log_tried() even though
they used the same function anyway. Delete them -- they still print
the same thing either way.
2022-09-12 19:16:59 -04:00
Dylan Baker 9a645c1c5a rust: Generate a rust-project.json file when rust targets are present
When at least one Rust target is present, we now generate a
rust-project.json file, which can be consumed by rust-analyzer. This is
placed in the build directory, and the editor must be configured to look
for this (as it is not a default search path).
2022-09-12 18:51:27 -04:00
Dylan Baker 0ef3c2b436 mesonlib: Add a function to find the first element in an iterable which matches a predicate 2022-09-12 18:51:27 -04:00
Dylan Baker b5a66ce2a3 arglist: use typing.MutableSequence instead of collections
In the long run collections is the right thing to use, but until we can
require 3.9.x as the minimum we cannot annotate the collections.abc
version, only the typing version. This allows correct type annotations
in users of `CompilerArgs`, as mypy (and friends) can determine that
`CompilerArgs` is ~= `T.Sequence[str]`
2022-09-12 18:51:27 -04:00
Eli Schwartz c555724b49
docs: fix broken porting advice for intl dependency in release notes
See https://github.com/theimpossibleastronaut/rmw/pull/345#discussion_r967876201

The check for `.found()` implies the dependency lookup should be
optional, but the example didn't make it optional.
2022-09-12 15:16:38 -04:00
Xavier Claessens 0042095d12 mcompile: Remove useless sleep
There is no reason to wait 2s before starting the compilation command.

Fixes: #10698.
2022-09-12 13:50:11 -04:00
David Ward ee5a729190 modules: Fix paths to (sub)project source/build directories
The subproject directory name (i.e. 'subprojects') was being added
to the path even for the main project.
2022-09-12 00:27:21 -04:00
David Ward 68add86f7b i18n: Fix source root in Gettext targets for subprojects
Gettext should search for input files relative to the (sub)project
source root, not the global source root.

This change exposes a root_subdir member in ModuleState.
2022-09-12 00:27:21 -04:00
Eli Schwartz 7eb5709bd9
backends: limit maximum path of generated filenames
When calculating the output filename for a compiled object, we sanitize
the whole input path, more or less. In cases where the input path is
very long, this can overflow the max length of an individual filename
component.

At the same time, we do want unique names so people can recognize what
these outputs actually are. Compromise:

- for filepaths with >5 components (which are a lot more likely to cause
  problems, and simultanously less likely to have crucial information that
  far back in the filepath)
- if an sha1 hash of the full path, replacing all *but* those last 5
  components, produces a path that is *shorter* than the original path

... then use that modified path canonicalization via a hash. Due to the
use of hashes, it's unique enough to guarantee correct builds. Because
we keep the last 5 components intact, it's easy to tell what the output
file is compiled from.

Fixes building in ecosystems such as spack, where the build environment
is a very long path containing repetitions of
`__spack_path_placeholder__/` for... reasons of making the path long.
2022-09-11 14:51:03 -04:00
Dylan Baker 37663da83e tests: Add a test for a target with no sources
Since this was broken for a long time, we should have a test for it.
2022-09-09 19:13:46 -04:00
Andres Freund 91206aaeb0 vs: Fix CustomBuild contents.
%% survived into the output since 038b31e72b. That failed to fail, at
least in the common cases, because the whole command sequence is unnecessary /
redundant - it appears to come from cmake, which executes multiple commands
within a single CustomBuild element.
2022-09-09 18:37:30 -04:00
Xavier Claessens 1acccc862a doc: Recommend tags for libraries utilities
GLib installs a few executables that are not needed by applications that
use the glib libraries, but are used either by build systems or by user
scripts. Debian splits them into libglib2.0-dev-bin and libglib2.0-bin
packages. Another example is GStreamer tools (e.g. gst-launch-1.0) that
Debian packages separately in gstreamer1.0-tools.

It is common enough that Meson documentation should recommend a tag for
consistency across projects.
2022-09-09 18:24:18 -04:00
Eli Schwartz 2a76afcef1 compilers: drop some useless info from CompileResult
text_mode was never set, nor used, and pid was set but never used.
2022-09-09 14:12:14 -07:00
Eli Schwartz e3a4dc7218 compilers: fix regression in logging cached compile commands
In commit d326c87fe2 we added a special
holder object for cached compilation results, with some broken
attributes:

- "command", that was never set, but used to print the log

- "args", that was set to some, but not all, of the information a fresh
  compilation would log, but never used

Remove the useless args attribute, call it command, and use it properly.
2022-09-09 14:12:14 -07:00
Eli Schwartz 167356aeab
compilers: correct the MSVC version comparison for turning on __cplusplus
We compared a Visual Studio (the IDE) version, but we wanted a MSVC (the
compiler) version. This caused the option to be passed for a few too
many versions of MSVC, and emit a "D9002 : ignoring unknown option" on
those systems.

Compare the correct version using the version mapping from
https://walbourn.github.io/vs-2017-15-7-update/

Fixes #10787

Co-authored-by: CorrodedCoder <38778644+CorrodedCoder@users.noreply.github.com>
2022-09-07 17:27:55 -04:00
Eli Schwartz 7bdfe7ccb2 wrap: correctly override dependency names with capital letters
When we do wrap resolution, we do a case-insensitive lookup because
keys, i.e. `dep_name = variable_name`, are case insensitive. In order to
check whether we should process a subproject, we need to know if the
lowercased dependency name matches.

We do this by looking up the lowercase name, and assuming that the
stored name is also lowercase. But for dependency_names, this isn't "case
insensitive and stored in lowercase" so we need to manually force it to
be consistent.

Likewise, when looking up the wrap name (which works like
dependency_names and doesn't need a provide section at all) the disk
filename of the wrap file is case sensitive, but needs to be manually
forced for consistency.
2022-09-07 16:19:09 -04:00
Volker Weißmann 5fec9f5db9 Fixed string escaping in AstPrinter 2022-09-07 08:56:51 -04:00
Rosen Penev 26acf2152d minstall: handle extra error for selinuxenabled
Microsoft's WSL2 uses a Plan 9 filesystem, which returns IOError when file is missing.
2022-09-07 08:46:50 -04:00
Mark Bolhuis a289e5416b modules/wayland: Change default value of include_core_only to true
The use of wayland-<client|server>.h is discouraged, therefore
change the default value of include_core_only to true.
2022-09-07 08:43:29 -04:00
Mark Bolhuis b6235a2e42 modules/wayland: Rename core_only to include_core_only
Rename the core_only option in scan_xml to include_core_only
to match the flag used by wayland-scanner.
2022-09-07 08:43:29 -04:00
Mark Bolhuis 25f838fd33 modules/wayland: Support --include-core-only
wayland-scanner can generate header files that only include
wayland-client-core.h using a flag.

Add a core_only option to scan_xml to support this use case.
2022-09-06 18:08:39 -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 e6122ba786 interpreter: name typing-only kwargs import with an underscore
To differentiate it from the function parameter itself. Annotating a
function as

```
def func_foo(kwargs: kwargs.FooKwargs):
```

is confusing, both visually and to static linters.
2022-09-05 09:47:35 -07:00
Eli Schwartz c1182b3f74 interpreter: add a few small func annotations 2022-09-05 09:47:35 -07:00
Andres Freund 628effb369 mtest: Run ninja build.ninja before loading tests
When the build definition has changed since the last ninja invocation meson
test operated on an outdated list of tests and their dependencies. That could
lead to some tests not being run / not all dependencies being built. This was
particularly confusing because the user would see the output of
reconfiguration and rebuilding, and the next mtest invocation would have the
updated configuration.

One issue with this is that that we will now output more useless ninja output
when nothing needs to be done (the "Entering directory" part is not repeated,
as we happen to be in the build directory already). It likely is worth
removing that output, perhaps by testing if anything needs to be done with
ninja -n, but that seems better addressed separately.

Fixes: #9852
2022-09-04 19:05:14 -04:00
Andres Freund f501e3b187 mtest: pull detection of ninja into TestHarness
A later commit will add a second invocation of ninja, no point in having the
detection code twice.

This changes the exit code in case ninja isn't found from 125 to 127, which
seems more appropriate given the justification for returning 125 (to make git
bisect run skip that commit). If we can't find ninja we'll not succeed in
other commits either.
2022-09-04 19:05:14 -04:00
Andres Freund 2096e394fc mtest: Move loading of test data into its own function
A subsequent commit will do a bit more during test data loading, making a
dedicated function seem advisable.

The diff looks a bit odd, using git show --diff-algorithm=patience
will make it clearer.
2022-09-04 19:05:14 -04:00
Jan Alexander Steffens (heftig) d682d3f837 Add missing cdata update in genmarshal tests
Otherwise the test is flaky, as it may try to include a header that's
not generated yet.
2022-09-04 00:07:34 -04:00
Nirbheek Chauhan f70895a441 tests/7 gnome: Fix incorrect unref of GResource
The returned GResource is transfer-none, since the generated function
basically calls g_static_resource_get_resource(). It should not be
unreffed. Causes an abort on Debian:

GLib-GIO:ERROR:../../../gio/gresource.c:1451:g_static_resource_fini: assertion failed: (g_atomic_int_get (&resource->ref_count) >= 2)
2022-09-03 20:12:35 +03:00
Nirbheek Chauhan cc1dd6c1dd ci: Fix macOS qt4 detection
Need to link the qt4 install so it's in PATH.
Also need to use a symlink to fix breakage in the Tap.
2022-09-03 19:44:03 +03:00
Konstantin Kharlamov 251113fa67 backend/ninja: omit --backend when regenerating build dir
Currently a cosmetic bug is present: once a build dir was regenerated,
meson would start showing:

  User defined options
    backend: ninja

This is not true as user have not defined the option, it is default.
Fix this by omitting the `--backend ninja` parameter from "regenerate"

In my tests this does not affect the situation when one specifies
`--backend ninja` explicitly, it still shows the backend as user-defined
after reconfiguration.

Fixes: https://github.com/mesonbuild/meson/issues/10632
2022-09-02 16:04:08 -04:00
Jehan a692395186 Fix 2 typos in a single string which can be shown in error messages. 2022-08-31 21:20:47 -04:00
Eli Schwartz 388cb0f805 env2mfile: reuse logical lists of interesting facts from meson itself
Meson internally knows about many languages and tools, and *FLAGS
variables, and which languages to use them for. Instead of duplicating
this logic, import it from mesonbuild.*

This logic was originally standalone, but now that it is merged into the
Meson tree we can have a single source of truth.
2022-09-01 01:05:48 +03:00
aleksander e121cd123c modules/cmake: Fix typo 2022-08-31 17:32:39 +03:00
Eli Schwartz 78bf1ec56e
fix obscure crash on unbound variable
This can be triggered if someone tries to call a non-ID. The example
reproducer was:

```
if (var = dependency(...)).found()
```

This produced a traceback ending in

```
    raise InvalidArguments(f'Variable "{object_name}" is not callable.')
UnboundLocalError: local variable 'object_name' referenced before assignment
```

After this commit, the error is reported as:

```
ERROR: AssignmentNode is not callable.
```
2022-08-30 15:30:55 -04:00
Samay Sharma 2c1ac8ac1d Add LLVM_CONFIG support 2022-08-30 15:06:51 -04:00
Eli Schwartz 8059908888 flake8: run in CI
We should have full coverage now, so make sure we don't regress in the
future.
2022-08-29 23:32:43 +03:00
Eli Schwartz c5db96e051 flake8: fix typing casts to not have actual objects
We use `__future__.annotations` to good effect everywhere we can, and
one of the effects of this is that annotations are automatically
stringized and don't need to be evaluated, using less memory and
computation. But this only affects actual annotations -- a cast is just
a function with an argument, so the compiler has no idea that it's an
annotation to be stringized.

Do this manually.
2022-08-29 23:32:43 +03:00
Eli Schwartz f4cc60bf20 flake8: move typing-only imports into T.TYPE_CHECKING 2022-08-29 23:32:43 +03:00
Eli Schwartz 14b2457627 flake8: fix warnings for unused imports
This is supposed to expose all primitives together, but to do that we
need to actually "use" each variable in `__all__`, which we... didn't.
Sorry about that.
2022-08-29 23:32:43 +03:00