Commit Graph

232 Commits

Author SHA1 Message Date
Marvin Scholz 2cdddbab56 Add new debug() function
Adds a new debug() function that can be used in the meson.build to
log messages to the meson-log.txt that will not be printed to stdout
when configuring the project.
2022-03-30 06:57:30 -04:00
Xavier Claessens e33ec88ac7 Pass environment down to base Target class 2022-03-29 16:10:28 -04:00
Xavier Claessens f2d21bf8a9 Make compilers list per subproject
Previously subprojects inherited languages already added by main
project, or any previous subproject. This change to have a list of
compilers per interpreters, which means that if a subproject does not
add 'c' language  it won't be able to compile .c files any more, even if
main project added the 'c' language.

This delays processing list of compilers until the interpreter adds the
BuildTarget into its list of targets. That way the interpreter can add
missing languages instead of duplicating that logic into BuildTarget for
the cython case.
2022-03-24 12:27:06 -04:00
Xavier Claessens 8867fb7999 interpreter: Make compiler options per-subproject 2022-03-22 17:20:48 -04:00
Dylan Baker f9445300b3 structured_sources: fix subdir handling
We currently don't handle subdirectories correctly in
structured_sources, which is problematic. To make this easier to handle
correctly, I've simply changed `structured_sources` to only use Files
and not strings as an implementation detail.
2022-03-18 19:46:24 -07:00
Eli Schwartz e54e9f58e5 give subproject interpreters a view of user defined options
We need this for the python module, as implemented in commit
e8375d20a9, but that then crashed in
subprojects because those options were never forwarded to the subproject
interpreter.
2022-03-13 06:50:31 -04:00
Jussi Pakkanen 69ade4f4cf
Merge pull request #9339 from dcbaker/submit/structured_sources
Structured Sources
2022-03-13 01:01:55 +02:00
Eli Schwartz 5cb9f2b066 fix regression in vcs_tag when the VCS program is not installed
We are supposed to fallback on the fallback when running the vcstagger,
but instead we errored out during configure.

Fixes regression in commit b402817fb6.
Before this, we used shutil.which || relative paths, and in the latter
case if it could not be found we still wrote out that path but it failed
to run in vcstagger. Now, we use find_program under the hood, so it
needs to be run in non-fatal mode, and if it is not found, we simply
keep the original command string. It's a VCS command, so if we magically
end up finding it at runtime because it was installed after running
configure, that is *fine*.
2022-03-12 00:31:12 +02:00
Eli Schwartz 7df6c6a728
add early sanity check for test programs existing
It used to be possible to do this:

```
bomb = find_program('nonexisting', required: false)
test('traceback during meson test', bomb)
```

and it would in fact bomb out, with:

```
[0/1] Running all tests.
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/mesonbuild/mesonmain.py", line 149, in run
    return options.run_func(options)
  File "/usr/lib/python3.10/site-packages/mesonbuild/mtest.py", line 2017, in run
    return th.doit()
  File "/usr/lib/python3.10/site-packages/mesonbuild/mtest.py", line 1685, in doit
    runners.extend(self.get_test_runner(test) for test in tests)
  File "/usr/lib/python3.10/site-packages/mesonbuild/mtest.py", line 1685, in <genexpr>
    runners.extend(self.get_test_runner(test) for test in tests)
  File "/usr/lib/python3.10/site-packages/mesonbuild/mtest.py", line 1586, in get_test_runner
    return SingleTestRunner(test, env, name, options)
  File "/usr/lib/python3.10/site-packages/mesonbuild/mtest.py", line 1308, in __init__
    self.cmd = self._get_cmd()
  File "/usr/lib/python3.10/site-packages/mesonbuild/mtest.py", line 1374, in _get_cmd
    test_cmd = self._get_test_cmd()
  File "/usr/lib/python3.10/site-packages/mesonbuild/mtest.py", line 1352, in _get_test_cmd
    if self.options.no_rebuild and not os.path.isfile(testentry):
  File "/usr/lib/python3.10/genericpath.py", line 30, in isfile
    st = os.stat(path)
TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType

ERROR: Unhandled python exception

    This is a Meson bug and should be reported!
```

This is something we explicitly check for elsewhere, for example when
using a not-found program as a command in a custom target or generator.

Check for it when making a test too, and error out with a similar error.

Fixes #10091
2022-03-08 23:49:26 -05:00
Eli Schwartz c231c4bd2a
move a bunch of imports into TYPE_CHECKING blocks
These are only used for type checking, so don't bother importing them at
runtime.

Generally add future annotations at the same time, to make sure that
existing uses of these imports don't need to be quoted.
2022-03-07 19:09:50 -05:00
Dylan Baker 7d1431a060 build: plumb structured sources into BuildTargets 2022-03-07 12:33:33 -08:00
Dylan Baker cbc62e892a interpreter: add an implementation for structured_sources 2022-03-07 12:33:33 -08:00
Dylan Baker fd55ff6a72 interpreter: Add a holder for StructuredSources
And teach the interpreter how to use it
2022-03-07 12:33:33 -08:00
Dylan Baker bcf1583bb0 interpreter: teach source_strings_to_files about StructuredSources 2022-03-07 12:33:33 -08:00
Eli Schwartz 6ddba5c542
remove unused code after subproject conversion to typed_kwargs
This should have been removed in commit
4a2058cb83 but was forgotten.
2022-03-07 15:31:39 -05:00
Dylan Baker bcf924dc7b interpreter: annotate the find_program chain 2022-03-03 10:30:31 -08:00
Dylan Baker 5e89953dbb interpreter: fix some low hanging type annotations issues 2022-03-03 10:30:31 -08:00
Dylan Baker 643b3f227e interpreter: fix mismatched type expectations 2022-03-03 10:30:31 -08:00
Dylan Baker a760ef5b60 interpreter: Fix type violation in do_subproject_cmake 2022-03-03 10:29:14 -08:00
Dylan Baker 3e90f27703 interpreter: replace build_def_files with OrderedSet
We do a bunch of backbending to make sure we don't have duplicates,
let's just use the right datastructure to begin with.
2022-03-03 10:29:14 -08:00
Dylan Baker 82f43ba8c5 interpreter: fix Interpreter type annotations
default_options should be `T.Dict[OptionKey, str]`, not `T.Dict[str,
str]`.
2022-03-03 10:29:14 -08:00
Dylan Baker 4a2058cb83 interpreter: use typed_kwargs for subproject() 2022-03-03 10:29:14 -08:00
Dylan Baker 71c65392a8 interpreter: add some simple annotations to subproject methods 2022-03-03 10:29:14 -08:00
Dylan Baker 122b9db7b0 interpreter: Use a literal for the do_subproject helper
Since we only have two valid options and we don't want to allow any
others.
2022-03-03 10:29:14 -08:00
Dylan Baker ca64777315 interpreter: annotate subproject_stack 2022-03-03 10:29:14 -08:00
Remi Thebault 4fe6f0dd29 add D features to InternalDependency 2022-03-03 08:42:56 -08:00
Eli Schwartz 2bcc204a11
document and raise an error for disallowed combination of install_headers args
It makes no sense to specify both:
- install_dir, which overrides the -Dincludedir= builtin option
- subdir, which suffixes the -Dincludedir= builtin option

We've always silently ignored the subdir in this case, which is really
surprising if someone actually passed it and expected it to do
something. We also confusingly didn't say anything in the documentation
about it.

Document that the options are incompatible, and explicitly check to see
if they are both passed -- if so, raise an error message pointing out
that only install_dir should be used.

Fixes #10046
2022-03-02 17:17:45 -05:00
Dylan Baker 0f090147ef interpreter: delete now unnecessary code
Only func_configure_file could reach this code, but now it cannot due to
the use of typed_kwargs, so delete it.
2022-03-01 15:17:59 -05:00
Dylan Baker 23f666b497 interpreter: use typed_kwargs for configure_file 2022-03-01 15:17:59 -05:00
Dylan Baker 272308ff05 interpreter: use a shared KwargInfo for install_tag
The kind that takes a single argument, not the custom_target version
that takes an array
2022-03-01 15:17:59 -05:00
Dylan Baker f03c712d17 interpreter: fix notfound_program method
Which should take a File or str, but only handles str correctly. Which
mypy would have caught for us, if we just had annotations here.
2022-03-01 15:17:59 -05:00
Eli Schwartz 23e767176e allow dependency checks to bubble up feature warnings to the interpreter
It would be too difficult and probably a layering violation to give an
interpreter handle to the inner guts of every dependency. What we can do
instead is let every dependency track:

- the Feature checks it can produce,
- the version attribute for when it was implemented

while leaving the interpreter in charge of actually emitting them.
2022-03-01 12:13:24 -08:00
Xavier Claessens 6acfe48f32 Allow setting method/separator in environment() and meson.add_devenv() 2022-02-28 09:03:27 -05:00
Christian Wendt 3478e968d2 Add missing install_tag kwarg to install_emptydir() 2022-02-28 07:17:33 -05:00
Eli Schwartz 60c893f1c2
flake8: remove some redundant separators 2022-02-16 18:19:13 -05:00
Eli Schwartz baecebda0e
flake8: fix typoed whitespace surrounding tokens 2022-02-16 18:19:13 -05:00
Eli Schwartz 7a1e8eecaf
formatting improvement for include_directories sandbox violation warning
Print the location the warning was encountered, and quote the string
that triggered it. This makes it easier to read what actually happened.
2022-02-12 23:13:26 -05:00
Eli Schwartz f08aabfb77
validate the literal directory "subprojects" when checking sandbox violations
We do not want anyone touching this entire directory tree, but due to
the way it was implemented, we only checked if its direct parent was a
subproject violation. This generally worked, unless people tried to add
`subprojects/` as an include directory.

Patch this hole. It now provides the same warning any sandbox violation
does (but is not currently an error, just a "will become an error in the
future").
2022-02-12 23:13:26 -05:00
Jussi Pakkanen b497becc87 Guard against empty string in subdir(). 2022-02-05 08:09:24 -08:00
Paolo Bonzini fc661c35a2 interpreter: support for forcibly verbose logging of some tests
Add a new keyword argument to test() and benchmark(), completing the
implementation of the feature.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2022-02-01 09:05:26 +01:00
Dylan Baker 11f9638035 build: replace kwargs in CustomTarget initializer
Because we don't want to pass the Interpreter kwargs into the build
layer. This turned out to be a mega commit, as there's really on elegant
way to make this change in an incremental way. On the nice side, mypy
made this change super easy, as nearly all of the calls to
`CustomTarget` are fully type checked!

It also turns out that we're not handling install_tags in custom_target
correctly, since we're not converting the boolean values into Optional
values!
2022-01-28 15:53:20 -05:00
Dylan Baker b402817fb6 interpreter: use find_program_impl instead of shutil.which for vcs_tag
This is the right thing to do, using which is wrong.
2022-01-28 15:53:20 -05:00
Dylan Baker cc4160db04 interpreter: remove dead code from custom_target
This has been completely replaced by typed_kwargs now
2022-01-28 15:53:20 -05:00
Dylan Baker 08f06b237e interpreter: use typed_kwargs for vcs_tag 2022-01-28 15:53:20 -05:00
Eli Schwartz d9f55d774c
add location data to various Feature checks 2022-01-27 22:11:48 -05:00
Eli Schwartz 1913a4246c
pkgconfig module: fix incorrect Feature logging for uninstalled_variables
The utility function that processes this for both 'variables' and
'uninstalled_variables' accepts a kwarg for the name of the argument,
but then hardcodes 'variables' in the warning message. This is
misleading.
2022-01-27 22:11:47 -05:00
Eli Schwartz fa4f96427a remove incorrect deprecated feature for vcs_tag
In commit 06481666f4 this warning got
moved from build.py to the interpreter. Unfortunately it got added to
the wrong function... it is supposed to be part of custom_target and
even mentions this as the feature_name.

Since then, build_always became a KwargInfo and has the deprecated-since
attribute baked into it. But it didn't have the additional message which
it really should have.

Add that message at the same time we remove it from vcs_tag.
2022-01-27 13:01:48 -08:00
Eli Schwartz 7e0004d8cf move the version info for build_always* directly into the kwarginfo
Rather than pointlessly evolving it in the exactly one place which it is
used. It's not clear what the purpose for this was.
2022-01-27 13:01:48 -08:00
Eli Schwartz 3990dc6d64 flake8: fix indentation style 2022-01-27 10:48:01 -08:00
Eli Schwartz a0d28e850e properly error out when project version is an array other than files()
Due to the support for specifying version as files('VERSION'), we need
to internally accept an array, since that is what files() returns.
Before that, we didn't accept arrays, and after that, we don't intend to
accept generic arrays, only arrays as a side effect of files(). So
tighten the typechecking to ensure that that is what we actually get.
2022-01-24 19:46:51 +01:00