The documentation for subprocess.run at https://docs.python.org/3/library/subprocess.html#popen-constructor has a warning,
pointing to using shutil.which() instead of subprocess.run for detecting if exe files exists on the path.
shutil.which() is used in many places already.
Fix incorrect map access to custom_target_output_buildfile in CustomTargetIndex
case. Map keys are file names with the path appended, but the used keys were
just the file name. This led to crashes.
Revert "interpreter: when overriding a dependency make its name match"
This reverts commit b1340e9bb1.
Revert "dependency: define equality and hash operators for Dependency"
This reverts commit 6d713e40f8.
This caused some projects to fail to build, such as libplacebo and
libepoxy. Taking libplacebo as the example, the produced build.ninja
does not include libvulkan.so as a linker input for
src/libplacebo.so.338.
We are probably getting dependency hashing wrong somewhere. Unsure where
exactly and unsure how to create a test case. We are also deep into rc2.
Revert it for now and try to re-land these changes for 1.6.
Bug: https://bugs.gentoo.org/935443Fixes: #13352
This reverts commit 9f02d0a3e5.
It turns out that this does introduce a behavioral change in existing
users of ConfigurationData, which it wasn't supposed to (it was supposed
to preserve behavior there, and add a new *warning* for
EnvironmentVariables).
This breaks projects such as pulseaudio, libvirt, and probably more.
Roll back the change and try again after 1.5.0 is released.
Fixes: #13372
Don't require the string to be enclosed in parentheses.
https://github.com/llvm/llvm-project/pull/97323 changed the LLD
version printout to no longer be enclosed in parentheses, which
made Meson fail to detect the linker style used here.
The LLD change is being reverted in
https://github.com/llvm/llvm-project/pull/97698 in order to fix
building with existing Meson versions, but for the future, loosen
the check slightly, to not require the parentheses.
When building a limited API module on Windows the library
to link with should be python3.dll, not python3X.dll. This was
already the case for non-GCC, but should have been the case
unconditionally.
Fixes regression from commit 78e9009ff9.
The above commit relied on rpath_dirs_to_remove being present and
correctly filled, which was never the case for the AppleDynamicLinker.
The result was that all the build-dir-only RPATHs were being carried
over to the installed files.
This commit implements returning the list of RPATHs to remove in
AppleDynamicLinker, doing pretty much the same thing as what's in the
GnuLikeDynamicLinkerMixin. Thanks to that, depfixer now correctly
removes build-time Meson-created RPATHs, as it used to before 1.4.1.
XCode project file contains dictionary-like structures. Strings for the
mapped values have to be quoted if these include special characters.
Previously this quoting was happening in-place, before adding a new
value to the dictionary. This produce big amounts of boilerplate
error-prone code. For example if there are targets whose names contain special
characters (grpc++ in my case), produced file will be invalid.
This moves checking and quoting subroutine to the PbxDictItem class,
eliminating the need to do this on the caller side.
[Kin](https://github.com/Serchinastico/Kin) tool was used to validate
produced PBXProj files.
Fixes regression in commit 78e9009ff9.
new_rpath is only set when install_rpath appears in meson.build.
Before this commit, we treated new_rpath as a single string to pass to
-add_rpath. This worked as long as new_rpath had a single rpath in it,
though for ELF we explicitly supported multiple rpaths separated with
":" (as binutils ld is quite happy with that too).
install_name_tool does not support paths with colons in it:
```
21:12 <awilfox> Load command 19 cmd LC_RPATH cmdsize 40 path /bar:/baz:/eli:/ldap (offset 12)
21:12 <awilfox> Load command 20 cmd LC_RPATH cmdsize 24 path /foo (offset 12)
21:14 <awilfox> so the result is: do not use colons
```
After commit 78e9009ff9, we simply ended
up with one load command for LC_RPATH per char in new_rpath, which was
wrong in every possible case.
What we actually need to do is pass every distinct rpath as a separate
`-add_rpath` argument, so we split it on the colons instead. We do the
same splitting to ensure proper diff'ability for ELF anyways...
Fixes#13355
It was probably done this way originally since we didn't have the
`fatal` keyword argument to avoid triggering the fatal-meson-warnings.
While we're here, replace the use of a `if bool` with an `else` on the
for loop.
In commit 2cb7350d16 we added a special
case for environment() objects to allow skipping `meson --internal exe`
overhead when /usr/bin/env exists and can be used to set environment
variables instead of using a pickled wrapper.
This special case assumed that environment is used for setting
variables, but it is also possible, albeit less common, to
append/prepend to them, in which case `meson --internal exe` will
compute the final value as an offset from whatever the current environment
variables inherited from ninja are. It is not possible to precompute
this when generating command lines for ninja, so using arguments to
/usr/bin/env is not possible. All it can do is set (override) an
environment variable.
In this case, we have to use the python wrapper and cannot optimize it
away. Add a tracking bit to the env object and propagate it to the
backend.
_get_gnu_compiler_defines and _get_clang_compiler_defines were broken
by not defining the language they used.
Neither GCC nor Clang infer the language based on the driver name which means
`self.defines` isn't populated correctly in compilers/cpp.py.
e.g.
```
$ echo "" | g++ -E -dM - | grep -i cplus
$ echo "" | g++ -x c++ -E -dM - | grep -i cplus
#define __cplusplus 201703L
```
Fix that by passing '-cpp -x LANGUAGE' as a first pass. If it fails, try
again without '-cpp -x LANGUAGE' as before, as its portability isn't
certain. We do '-cpp' because during testing, I found Fortran needs this,
although per below, I had to drop Fortran in the end and leave it to the
fallback (existing) path.
Without this change, a63739d394 is only
partially effective. It works if the system has injected Clang options
via /etc/clang configuration files, but not by e.g. patching the driver
(or for GCC there too).
Unfortunately, we have to wimp out for Fortran and fallback to the
old method because you need the language standard (e.g. -x f95).
Make the debug & error message strings consistent between the GCC and Clang probes.
Copy-paste error. Here, we're scraping pre-processor tokens, not checking
for the compiler type.
"PEP 667: Consistent views of namespaces" caused locals() to be
inconsistent between uses since it is now created afresh every time you
invoke it and writes to it are dropped. `sys._getframe().f_locals` is
equivalent but preserves writes (it doesn't create a new dict) and
unfortunately doesn't help at all as it's documented to be a private
implementation detail of CPython that "should be used for internal and
specialized purposes only".
Work around this by saving locals to a variable reference and both
passing it into runctx and reusing it in lookups of the result. This
works okay for both new and older versions of python.
Per the documentation for locals():
> The contents of this dictionary should not be modified; changes may
> not affect the values of local and free variables used by the
> interpreter.
So... lesson learned? :) This was introduced in commit
c34ee374a77fb2dffff90364506ac0cbbb1f00de; before that, we still used
locals() but only to pass local variables *in*.
Bug: https://github.com/python/cpython/pull/115153
We passed a wrapper hack for shutil.chown because some functionality
wasn't available in the stdlib. It was added in python 3.13 beta1, so
the tests fail when we actually test symlink handling.
Fixes failure to run test_install_subdir_symlinks_with_default_umask_and_mode
on python 3.13.
There are two issues:
1. has_header() wants just the header name without surrounding <>
or similar; it fails otherwise.
2. has_header() returns a tuple of two bools, where the first element
determines whether or not the header has been found. So use
that element specifically, otherwise the tuple will always evaluate
to true because it is not empty.
Fixes: 675b47b069 ("compilers: cpp: improve libc++ vs libstdc++ detection (again)")
* Ensure private directory exists for custom targets
Some custom target commands will expect the `@PRIVATE_DIR@` to already exist, such as with `make -C @PRIVATE_DIR@ ...`
* Prefer `exist_ok` over catching exception
* Explicitly look for 'OpenAL' with method: 'cmake'
This test was added for testing cmake depenencies,
so no other method must be accepted here, and
the spelling must match FindOpenAL.cmake.
* Resolve frameworks in IMPORTED_LOCATION
The IMPORTED_LOCATION property of CMake targets may contain macOS
framework paths. These must be processed into flags. By putting the
values in the list of targets, they will be processed as if they
appeared in INTERFACE_LINK_LIBRARIES.
When trying to get the version of a program, meson was previously
hardcoded to run the binary with `--version`. This does work with the
vast majority of programs, but there are a few outliers (e.g. ffmpeg)
which have an unusual argument for printing out the version. Support
these programs by introducing a version_argument kwarg in find_program
which allows users to override `--version` with whatever the custom
argument for printing the version may be for the program.