Handle command arguments which contain multiple substitutions correctly
in Backend.eval_custom_target_command()
In particular, gnome.gtkdoc() makes arguments of the form '--cflags
-I@SOURCE_ROOT@ -I@BUILD_ROOT' (where these arguments are then passed
down to a compiler invocation)
Normally, these are subsequently made right by
NinjaBackend.replace_paths(), but if Backend.as_meson_exe_cmdline()
decides that the command needs to be pickled, that doesn't happen.
(Although having two places where this substitution might happen smells
really bad)
Since we parse buildoptions.json to pass options, we end up passing
-Dbuildtype and also -Doptimization and -Ddebug which triggers the
warning:
WARNING: Recommend using either -Dbuildtype or -Doptimization + -Ddebug [...]
Filter out buildtype. It is redundant.
Otherwise we can end up finding dependencies from the build machine for
the host machine, which is incorrect. This alters cmake, pkg-config, and
all config-tool based dependencies.
Fixes: #7276
it really doesn't make sense to put this in the ExternalDependency
class. It doesn't rely on any of the state of that class, and it's
generically useful inside meson.
The documentation of gnome.generate_gir() has duplicated entry for
dependencies parameter. As a fix, this patch removes the entry added
recently.
Fixes: 893d101fff ("gnome: Add header kwarg to generate_gir()")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Should be "sources" not "source"
```
../meson.build:162: WARNING: Passed invalid keyword argument "source".
WARNING: This will become a hard error in the future.
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/mesonbuild/mesonmain.py", line 131, in run
return options.run_func(options)
File "/usr/local/lib/python3.7/site-packages/mesonbuild/msetup.py", line 245, in run
app.generate()
File "/usr/local/lib/python3.7/site-packages/mesonbuild/msetup.py", line 159, in generate
self._generate(env)
File "/usr/local/lib/python3.7/site-packages/mesonbuild/msetup.py", line 192, in _generate
intr.run()
File "/usr/local/lib/python3.7/site-packages/mesonbuild/interpreter.py", line 4359, in run
super().run()
File "/usr/local/lib/python3.7/site-packages/mesonbuild/interpreterbase.py", line 465, in run
self.evaluate_codeblock(self.ast, start=1)
File "/usr/local/lib/python3.7/site-packages/mesonbuild/interpreterbase.py", line 490, in evaluate_codeblock
raise e
File "/usr/local/lib/python3.7/site-packages/mesonbuild/interpreterbase.py", line 483, in evaluate_codeblock
self.evaluate_statement(cur)
File "/usr/local/lib/python3.7/site-packages/mesonbuild/interpreterbase.py", line 498, in evaluate_statement
self.assignment(cur)
File "/usr/local/lib/python3.7/site-packages/mesonbuild/interpreterbase.py", line 1151, in assignment
value = self.evaluate_statement(node.value)
File "/usr/local/lib/python3.7/site-packages/mesonbuild/interpreterbase.py", line 500, in evaluate_statement
return self.method_call(cur)
File "/usr/local/lib/python3.7/site-packages/mesonbuild/interpreterbase.py", line 895, in method_call
return obj.method_call(method_name, args, self.kwargs_string_keys(kwargs))
File "/usr/local/lib/python3.7/site-packages/mesonbuild/interpreterbase.py", line 39, in method_call
return method(args, kwargs)
File "/usr/local/lib/python3.7/site-packages/mesonbuild/interpreterbase.py", line 285, in wrapped
return f(*wrapped_args, **wrapped_kwargs)
File "/usr/local/lib/python3.7/site-packages/mesonbuild/interpreterbase.py", line 151, in wrapped
return f(*wrapped_args, **wrapped_kwargs)
File "/usr/local/lib/python3.7/site-packages/mesonbuild/interpreterbase.py", line 213, in wrapped
return f(*wrapped_args, **wrapped_kwargs)
File "/usr/local/lib/python3.7/site-packages/mesonbuild/interpreter.py", line 484, in partial_dependency_method
pdep = self.held_object.get_partial_dependency(**kwargs)
TypeError: get_partial_dependency() got an unexpected keyword argument 'source'
FAILED: build.ninja
```
Causes spammy warnings from the linker:
ld: warning: -headerpad_max_install_names is ignored when used with -bitcode_bundle (Xcode setting ENABLE_BITCODE=YES)
so: when building compile args, meson is deduplicating flags. When a
compiler argument is appended, a later appearance of a dedup'ed is going
to remove a earlier one. If the argument is prepended, the element
*before* the new one is going to be removed. And that is where the
problem reported in https://github.com/mesonbuild/meson/pull/7119 is
coming in. In the revision linked there, the order of replacement in the
prepend case was revesered.
With this patch, we restore this behaviour again.
When meson is currently being run with a python that seems to have been
installed from the Windows Store, replace the general WindowsApps
directory in search paths with dirname(sys.executable), and also handle
failures with pathlib.resolve on WindowsApps exe files.
Use the IDE's OpenMP flag instead of adding /openmp to additional
arguments. The IDE appears to override /openmp in additional arguments
with the IDE setting, which defaults to false, leading to binaries built
without OpenMP.
The linker that comes with MSVC does not understand the /openmp flag.
This results in a string of
LINK : warning LNK4044: unrecognized option '/openmp'; ignored
warnings, one for each static_library linked with an executable.
Avoid this by only setting the linker openmp flag when the compiler is
not MSVC.
It's assumed that where we use DEPFILE in command or rspfile_content, it
can be quoted by quoting the ninja variable (e.g. $DEPFILE ->
'$DEPFILE')
This is nearly always true, but not for gcc response files, where
backslash is always an escape, even inside single quotes.
So this fails if the value of DEPFILE contains backslashes (e.g. a
Windows path)
Do some special casing, adding DEPFILE_UNQUOTED, so that the value of
depfile is not shell quoted (so ninja can use it to locate the depfile
to read), but the value of DEPFILE used in command or rspfile_content is
shell/response file quoted)
(It would seem this also exists as a more general problem with built-in
ninja variables: '$out' appearing in command is fine, unless one of the
output filenames contains a single quote. Although forbidding shell
metacharacters in filenames seems a reasonable way to solve that.)
(How does this even work, currently? Backslashes in the value of all
ninja variables, including DEPFILE were escaped, which protected them
against being treated as escapes in the gcc response file. And
fortunately, the empty path elements indicated by a double backslash in
the value of depfile are ignored when ninja opens that file to read it.)
Now that all command-line escaping for ninja is dealt with in the ninja
backend, escape_extra_args() shouldn't need to do anything.
But tests of existing behaviour rely on all backslashes in defines being
C escaped: This means that Windows-style paths including backslashes can
be safely used, but makes it impossible to have a define containing a C
escape.
We avoided having to get this right previously, as we'd always use a
response file if possible.
But this is so insane, I can't imagine it's right.
See also: subprocess.list2cmdline() internal method