Commit Graph

7791 Commits

Author SHA1 Message Date
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
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
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
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
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 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
Eli Schwartz ff7d86d05f flake8: fix unnecessary f-strings without any format placeholders
These can just be ordinary strings.
2022-08-29 23:32:43 +03:00
Eli Schwartz 520bb7abbc flake8: fix lingering whitespace errors 2022-08-29 23:32:43 +03:00
Eli Schwartz af28826c24 flake8: fix missing import
This sort of worked, because it was a typing-only import and this file
isn't actually tested by mypy yet.
2022-08-29 23:32:43 +03:00
Alf Henrik Sauge 28dff2ca6d Fix indentation issues reported by flake8, requiring code restructuring
Strictly speaking code restructuring isn't needed, but making this PEP8
compliant results in indentation of the code that reduces the
readability. By moving the offending code on the outside of the method
call, the readability is maintained.
2022-08-26 17:12:40 -04:00
Alf Henrik Sauge 9ad5d0df4a Remove redundant backslash and fix white space issue 2022-08-26 17:12:40 -04:00
Alf Henrik Sauge 06bf9a5cda Fix purely white space issues reported by flake8 2022-08-26 17:12:40 -04:00
Eli Schwartz 47a0ed5924
Revert "Windows: Improve Python 3.8+ module check on Windows"
This reverts commit 99ad11bd9c.

This breaks working setups in conda. It is either wrong or incomplete
and thus cannot be used.

Fixes #10737
2022-08-25 17:41:38 -04:00
Fabian Orccon 83c6fc5b02 wrap: Support netrc files 2022-08-25 10:18:04 -04:00
Eli Schwartz 27748f9cd1
fix linker regression for compilers that don't accept LDFLAGS directly
e.g. ldc -- the compiler needs to process args before consuming them.

Fixes #10693
2022-08-24 23:49:14 -04:00
Eli Schwartz 9e2d4994c4
fix incorrect type annotations for coredata compile/link args
These make no sense as single strings.
2022-08-24 23:49:13 -04:00
Dylan Baker c94c492089 build: don't add targets to link_whole_targets if we took their objects
What happens is this:
 - liba is a convenience static library
 - libb is an installed static library
 - libb links in liba with --link-whole
 - libc links to libb
 - we generate a link line with libb *and* liba, even though libb is a
   strict superset of liba

This is a bug that has existed since the we stopped using link-whole to
combine convenience libraries, and to instead propagate their
dependencies up. For most linkers this is harmless, if inefficient.
However, for apple's ld64 with the addition calling `ranlib -c`, this
ends up causing multiple copies of symbols to clash (I think that other
linkers recognize that these symbols are the same and combine them), and
linking to fail.

The fix is to stop adding libraries to a target's `link_whole_targets`
when we take its objects instead. This is an all around win since it
fixes this bug, shortens linker command lines, and avoids opening
archives that no new symbols will be found in anyway.
2022-08-24 22:50:35 -04:00
Dylan Baker c02d7fe119 backend/ninja: properly track objects extracted from fortran sources
We need this to ensure that .mod files are created before we start
compiling, and to ensure that the proper include directory arguments are
generated.
2022-08-24 22:50:35 -04:00
Dylan Baker a044f42308 build: add a `uses_fortran()` convenience method 2022-08-24 22:50:35 -04:00
Dylan Baker 741de25462 build: Don't attempt to link-whole with rust convenience libraries
There are two distinct cases here that need to be considered. The first
issue is https://github.com/mesonbuild/meson/issues/10723 and
https://github.com/mesonbuild/meson/issues/10724, which means that Meson
can't actually generate link-whole arguments with rust targets. The
second is that rlibs are never valid candidates for link-whole anyway.
The promotion happens to work because of another bug in the promotion
path (which is fixed in the next commit).
2022-08-24 22:50:35 -04:00
Eli Schwartz f8ebfdf7b1
install modes should not apply sticky bit to files
This is generally a bad idea, e.g. it causes OSError on freebsd.

It also gets ignored by solaris and thus causes unittest failures.

The proper solution is to simply reject any attempt to set this, and log a
warning.

The install_emptydir function does apply the mode as well, and since it
is a directory it actually does something. This is the only place where
we don't reset the mode.

Although install_subdir also installs directories, and in theory it
could set the mode as well, that would be a new feature. Also it doesn't
provide much granularity and has mixed semantics with files. Better to
let people use install_emptydir + install_subdir.

Fixes #5902
2022-08-23 21:07:00 -04:00
Xavier Claessens 75b8dc5c9e pkgconfig: Variables can be a single string
It used to be listified and libxml2 wrap relies on that.
2022-08-23 08:13:55 -04:00