Commit Graph

7406 Commits

Author SHA1 Message Date
Tristan Partin 39f1d52e4a Add ability to add resources to jars
Previously Meson lacked the ability to add resources to jar files.

Fixes #9945
2022-03-22 13:21:26 +02:00
Jussi Pakkanen a559dbe70d Bump version number for new development. 2022-03-22 00:13:50 +02:00
Jussi Pakkanen fb67adf3e6 Prepare the 0.62.0 release. 2022-03-21 23:24:01 +02:00
Jussi Pakkanen 42af1f7092
Merge pull request #10147 from dcbaker/submit/structured-sources-subdir
structured_sources: fix subdir handling
2022-03-21 23:16:41 +02:00
Dylan Baker 9b83fc5ece ninja: fix handling of rust structured_sources in rare case
In the even that all of the inputs are generated, and they're all
generated into the same folder, and there are no subfolders, we would
fail to correctly handle all of the files after the main file. Let's fix
that.t
2022-03-21 11:26:52 -07:00
Dylan Baker adc509ed98 modules/rust: set bindgen include_dirs for both build and source dir
Which we pretty obviously need if any of our headers are generated
2022-03-20 11:00:53 -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 a0cade8f1d
gnome module: fix incorrect lookup of nonexistent dependencies in post_install
While gtk+-3.0 / gtk4 do exist, they have never provided the location of
the gtk-update-icon-cache program as a pkgconfig variable. Trying to
find one anyway, resulted in two things happening:
- a useless dep lookup
- a fatal-meson-warnings error and build failure because the
  get_pkgconfig_variable() in question never existed

The desktop-file-utils package is a package solely providing some
command line programs, and has never provided a pkg-config file in the
first place, so this always logged that the dependency was not found and
fell back to normal find_program_impl(), although without
fatal-meson-warnings build errors.

Fixes #10139
2022-03-18 12:52:06 -04:00
Paolo Bonzini ff844f3a1f fix detection of language standard library paths
The code in the C++ and Fortran compilers' language_stdlib_only_link_flags
method is broken and cannot possibly have ever worked.  Instead of
splitting by line, it splits by whitespace and therefore, instead of
the last line of the compiler output:

 programs: =/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
libraries: =/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0

it is only the last field that has its first 11 characters removed.
Instead of reinventing the wheel with a new and brittle pattern,
reuse get_compiler_dirs.

Fixes: 64c267c49 ("compilers: Add default search path stdlib_only_link_flags", 2021-09-25)
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2022-03-16 09:24:57 -07:00
Paolo Bonzini ca7b16f937 coredata: be even more robust on unpickling errors
When reverting from 0.62 to 0.59, one can see an error like this:

line 1003, in load
    obj = pickle.load(f)
  File "/Users/pm215/src/qemu-for-merges/meson/mesonbuild/mesonlib/universal.py",
line 2076, in __setstate__
    self.__init__(**state)  # type: ignore
TypeError: __init__() got an unexpected keyword argument 'module'
FAILED: build.ninja

Raise a MesonException for TypeError as well, so that reconfiguration
proceeds using cmd_line.txt.
2022-03-16 10:49:26 -04:00
Xavier Claessens 54213683e2 python: Remove warning about invalid install path
It was originally added because proper detection was not working on
Debian, but that has been fixed since. It was causing annoying warning
by default when prefix is /usr/local that can only be avoided by setting
options.
2022-03-16 07:03:43 -04:00
Jussi Pakkanen 1be444b464 Bump version number for rc2. 2022-03-15 11:30:58 +02:00
Eli Schwartz 68b8fbcf6d Revert "devenv: Set PYTHONPATH where we install python modules"
This reverts commit 79c6075b56.

# Conflicts:
#	docs/markdown/snippets/devenv.md
#	mesonbuild/modules/python.py
#	test cases/unit/91 devenv/test-devenv.py

PYTHONPATH cannot be reliably determined. The standard use case for
installing python modules with Meson is mixed pure sources (at least
`__init__.py`) and compiled extension_modules or configured files.
Unfortunately that doesn't actually work because python will not load
the same package hierarchy from two different directories, one a source
directory and one a (mandatory) out of tree build directory.

(It kind of can, but you need to do what this test case accidentally
stumbled upon, which is namespace packages. Namespace packages are a
very specific use case and you are NOT SUPPOSED to use them outside that
use case, so people are not going to use them just to circumvent Meson
devenv stuff as that would have negative install-time effects.)

Adding PYTHONPATH anyway will just lead to documentation commitments
which we cannot actually uphold, and confusing issues at time of use
because some imports *will* work... and some will *not*. The end result
will be a half-created tree of modules which just doesn't work together
at all, but because it partially works, users attempting to debug it
will spend time wondering why parts of it do import.

For any case where the automatic devenv would work correctly, it will
also work correctly to use `meson.add_devenv()` a single time, which is
very easy to manually get correct and doesn't provide any significant
value to automate.

In the long run, an uninstalled python package environment will require
"editable installs" support.
2022-03-15 11:22:59 +02:00
Paolo Bonzini 7c20890a05 sourceset: reorder fields in SourceSetRule
Keep conditions first, then "if true" fields, and the if_false sources last.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2022-03-14 10:27:38 -07:00
Paolo Bonzini 94be5b8b48 sourceset: document fields of SourceSetRule
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2022-03-14 10:27:38 -07:00
Paolo Bonzini 6dd04ce57c sourceset: improve typing of SourceSetRule
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2022-03-14 10:27:38 -07:00
Paolo Bonzini 9d42e58ea2 sourceset: reinstate extra_deps
Dependencies in the "if_true" keyword argument do not prevent the
sources from being used; in other words, they work just like dependencies
with "disabler: false".

However, this was broken in commit ab0ffc6a2 ("modules/sourceset: Fix
remaining typing issues", 2022-02-23) which changed logic instead of
just fixing typing issues.  This was likely an attempt to avoid using
"dependencies.Dependency" after the "dependencies" field was declared,
but it also broke QEMU.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2022-03-14 10:27:38 -07:00
Paolo Bonzini 076855c22f sourceset: rename "dependencies" fields to deps
The dependencies field clashes with the dependencies module, so that
mypy interprets "dependencies.Dependency" as a "Dependency" attribute
of the "dependencies" field.

Rename the field to something else, so that it does not clash.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2022-03-14 10:27:38 -07:00
Eli Schwartz a5bb654377
gnome module: fix crash due to misused function while generating gir command
In commit 68e684d51f the _get_link_args
function was modified from returning a list[str] of arguments, to a
tuple of both that and a modified copy of the entire target's
current/enhanced dependencies (why not just the new ones? I don't know).

However, the existing use of the function was not adapted to this
change, and tried to turn this entire tuple into a node of the command
line. Tuples cannot flatten to lists, and mesonlib.File or
HoldableObjects don't make good command line arguments.

As a result we errored out with:

ERROR: Argument (['-L/path/to/builddir/', '--extra-library=foo'], [<SharedLibrary 25a6634@@foo@sha: foo>, <SharedLibrary 25a6634@@foo@sha: foo>, <SharedLibrary 25a6634@@foo@sha: foo>]) in "command" is invalid

Split out the flags and the dependencies and update the former while
replacing the latter.
2022-03-13 21:23:36 -04:00
Eli Schwartz 4680c09aac mtest: fix logic bug that broke tests where the cmd is a Windows found program
In this case, the test fname might have an implicit extension and cannot
be found by `os.path.isfile()`.

We cannot use `shutil.which()` to handle platform differences, because
not all test fnames are executable -- for example Java jars.

The test representation does have an "is built" attribute which in
theory should work here, because all built targets definitely have their
full filename known to Meson, but it turns out to be misnamed. Rename it
correctly and add an actual "is built" attribute to check.

Tests which aren't built by Meson can be assumed to exist without
consulting their existence on the filesystem.

Fixes #10027
2022-03-14 01:48:16 +02: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 bfdbf7bf65 remove unused type ignore that mypy 0.940 no longer needs
And now that it doesn't need it, it errors out when you use it.
2022-03-12 00:31:12 +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
Ralf Gommers 44104e820a Remove a spurious debug print in Python module
This prints many lines of unwanted "done /absolute/path",
I noticed this when testing 0.62.0rc1 with SciPy.

[ci skip]
2022-03-10 15:30:31 -05:00
Jussi Pakkanen cec7d491f9 Bump version numbers for rc1 release. 2022-03-10 11:43:45 +02:00
Jussi Pakkanen 04ef7ec45d Add new env2mfile command. 2022-03-09 18:02:04 -05:00
Tristan Partin 2c03b2bb7f Move dataonly pkgconfig file to datadir/pkgconfig
dataonly files are architecture independent (lib vs lib64 for example).

Fixes #9902
2022-03-09 17:50:41 -05:00
Eli Schwartz 266e8acb58
fix python traceback when gtkdoc needs an exe_wrapper but doesn't have one
In commit c88bfdbefc we added support for
an exe_wrapper to gtkdoc, which checked twice whether the environment
says it is needed, and didn't check at all whether one was provided.

The result:

  File "/usr/lib/python3/dist-packages/mesonbuild/modules/gnome.py", line 1354, in gtkdoc
    t_args.append('--run=' + ' '.join(state.environment.get_exe_wrapper().get_command()))
AttributeError: 'NoneType' object has no attribute 'get_command'

Instead, check whether we have a valid exe_wrapper (if we don't need
one, then even when one is defined in the cross file, we get an
EmptyExternalProgram) and if we do, use it.

If we don't have one, but need one, then we revert back to the behavior
before commit c88bfdbefc, which probably
means "executing the doc target causes the command to error out with
"Exec format error".
2022-03-09 16:06:27 -05:00
Xavier Claessens eafb8a8e10 install: Add --strip option 2022-03-09 10:38:28 -05: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 7cc4ca2cbb
Revert "Add new env2cross command."
This reverts commit e257a870fe.

The PR adding this command had infinitely hanging CI, and now that it is
merged to master we cannot get any CI on any PR to succeed.
2022-03-08 21:34:39 -05:00
Jussi Pakkanen e257a870fe Add new env2cross command. 2022-03-08 23:40:03 +02:00
Eli Schwartz 2540ad6e9e
fix correctly detecting whether python is found if link args are empty
There are two cases where we can assume we found the python dependency
with its requisite libraries using sysconfig:

- we found the library with find_library and are prepared to link to it
- the library is not actually part of the dependency, so its presence or
  absence is irrelevant

In the latter case, we should consider it found if link_libpython is
False. Originally we did this, but the logic was inverted in commit
5b422fce87 in an unrelated change and
without explanation, likely by accident.

Normally this doesn't much matter, since a python invariably comes with
a predictably located libpython and the first condition evaluates true.
But that is not true for pypy, and in fact that is the reason the
link_libpython check was originally added in commit
1bd14b52b2.

Restore that original logic.

Fixes #8570
2022-03-07 20:35:43 -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
Eli Schwartz a009eacc65
treewide: string-quote the first argument to T.cast
Using future annotations, type annotations become strings at runtime and
don't impact performance. This is not possible to do with T.cast though,
because it is a function argument instead of an annotation.

Quote the type argument everywhere in order to have the same effect as
future annotations. This also allows linters to better detect in some
cases that a given import is typing-only.
2022-03-07 19:01:04 -05:00
Eli Schwartz 187dc656f4
merge various TYPE_CHECKING blocks into one
A bunch of files have several T.TYPE_CHECKING blocks that each do some
things which could just as well be done once, with a single `if`
statement. Make them do so.
2022-03-07 19:01:04 -05:00
Tristan Partin d072ebc955 Fix @typed_pos_args on java.generate_native_headers 2022-03-07 15:42:07 -08:00
Dylan Baker c08b6e29d9 Add support for rust proc-macro crates 2022-03-07 18:35:31 -05:00
Dylan Baker 0d0a4fa0fe backends/ninja: Add support for structured sources with rust 2022-03-07 12:33:33 -08: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
Dylan Baker ba3d9b5d16 dependencies: Dependency Sources can be StructuredSources 2022-03-07 12:33:33 -08:00
Dylan Baker 39433762a9 build: Add structured sources 2022-03-07 12:33:33 -08:00
Dylan Baker da2cdacb28 backend/ninja: add rules to copy files to the build dir 2022-03-07 12:33:33 -08:00
Dylan Baker 9519a5b7fd scripts: Add a script to copy files. 2022-03-07 12:33:33 -08:00
Dylan Baker aa03a0c346 build: fix typo in type alias
The declaration is `EnvInitValueType`, but when it's used it's
`EnvValueType`.
2022-03-07 12:33:33 -08:00
Dylan Baker df2a437b5b build: fix type annotation issue
I noticed by inspection
2022-03-07 12:33:33 -08:00