Commit Graph

3231 Commits

Author SHA1 Message Date
Xavier Claessens cd63853ad2 build: Fix linking multiple libraries and some are promoted
When a link() is promoted to link_whole() we still have to handle the
rest of the list.

Fixes: #11956
2023-07-10 23:12:24 +03:00
Eli Schwartz 4166bf1eb2 Revert "backends: Cache creation of install data"
This reverts commit 904b47085f.

This is not a real bottleneck, and we want to create it thrice -- once
before the backend is generated. The final install data needs to be
created fresh.

Update unittest to demonstrate the issue.

Fixes https://bugs.gentoo.org/910050
2023-07-10 17:21:11 +03:00
Jussi Pakkanen bf9a6a1b5c Renumber test dirs for rc2. 2023-07-05 23:56:18 +03:00
Xavier Claessens d140342c14 comp.preprocess(): Do not treat every file as assembly
Fixes: #11940
2023-07-05 21:34:25 +03:00
Jussi Pakkanen d391e5281c
Merge pull request #11742 from xclaesse/link-whole-cases
Fix niche cases when linking static libs
2023-07-05 01:10:58 +03:00
Kacper Michajłow 7fe6e18a02 tests: add standard option to get_define() test
This properly tests MSVC case which produce different preprocessed
output depending on language version.
2023-07-04 16:29:15 -04:00
GertyP 36bf53bdfd
Experimental 'genvslite' WIP. (#11049)
* Capture all compile args from the first round of ninja backend generation for all languages used in building the targets so that these args, defines, and include paths can be applied to the .vcxproj's intellisense fields for all buildtypes/configurations.

Solution generation is now set up for mutiple build configurations (buildtypes) when using '--genvslite'.

All generated vcxprojs invoke the same high-level meson compile to build all targets;  there's no selective target building (could add this later).  Related to this, we skip pointlessly generating vcxprojs for targets that aren't buildable (BuildTarget-derived), which aren't of interest to the user anyway.

When using --genvslite, no longer inject '<ProjectReference ...>' dependencies on which a generated .vcxproj depends because that imposes a forced visual studio build dependency, which we don't want, since we're essentially bypassing VS's build in favour of running 'meson compile ...'.

When populating the vcxproj's shared intellisense defines, include paths, and compiler options fields, we choose the most frequent src file language, since this means more project src files can simply reference the project shared fields and fewer files of non-primary language types need to populate their full set of intellisense fields.  This makes for smaller .vcxproj files.

Paths for generated source/header/etc files, left alone, would be added to solution projects relative to the '..._vs' build directory, where they're never generated;  they're generated under the respective '..._[debug/opt/release]' ninja build directories that correspond to the solution build configuration. Although VS doesn't allow conditional src/header listings in vcxprojs (at least not in a simple way that I'm aware of), we can ensure these generated sources get adjusted to at least reference locations under one of the concrete build directories (I've chosen '..._debug') under which they will be generated.

Testing with --genvslite has revealed that, in some cases, the presence of 'c:\windows\system32;c:\windows' on the 'Path' environment variable (via the make-style project's ExecutablePath element) is critical to getting the 'meson compile ...' build to succeed.  Not sure whether this is some 'find and guess' implicit defaults behaviour within meson or within the MSVC compiler that some projects may rely on. Feels weird but not sure of a better solution than forcibly adding these to the Path environment variable (the Executable Path property of the project).

Added a new windows-only test to windowstests.py ('test_genvslite') to exercise the --genvslite option along with checking that the 'msbuild' command invokes the 'meson compile ...' of the build-type-appropriate-suffixed temporary build dir and checks expected program output.

Check and report error if user specifies a non-ninja backend with a 'genvslite' setup, since that conflicts with the stated behaviour of genvslite.  Also added this test case to 'WindowsTests.test_genvslite'

I had problems tracking down some problematic environment variable behaviour, which appears to need a work-around. See further notes on VSINSTALLDIR, in windowstests.py, test_genvslite.
'meson setup --help' clearly states that positional arguments are ... [builddir] [sourcedir].  However, BasePlatformTests.init(...) was passing these in the order [sourcedir] [builddir].  This was producing failures, saying, "ERROR: Neither directory contains a build file meson.build." but when using the correct ordering, setup now succeeds.

Changed regen, run_tests, and run_install utility projects to be simpler makefile projects instead, with commands to invoke the appropriate '...meson.py --internal regencheck ...' (or install/test) on the '[builddir]_[buildtype]' as appropriate for the curent VS configuration.  Also, since the 'regen.vcxproj' utility didn't work correctly with '--genvslite' setup build dirs, and getting it to fully work would require more non-trivial intrusion into new parts of meson (i.e. '--internal regencheck', '--internal regenerate', and perhaps also 'setup --reconfigure'), for now, the REGEN project is replaced with a simpler, lighter-weight RECONFIGURE utility proj, which is unlinked from any solution build dependencies and which simply runs 'meson setup --reconfigure [builddir]_[buildtype] [srcdir]' on each of the ninja-backend build dirs for each buildtype.
Yes, although this will enable the building/compiling to be correctly configured, it can leave the solution/vcxprojs stale and out-of-date, it's simple for the user to 'meson setup --genvslite ...' to fully regenerate an updated, correct solution again. However, I've noted this down as a 'fixme' to consider implementing the full regen behaviour for the genvslite case.

* Review feedback changes -
- Avoid use of 'captured_compile_args_per_buildtype_and_target' as an 'out' param.
- Factored a little msetup.py, 'run(...)' macro/looping setup steps, for genvslite, out into a 'run_genvslite_setup' func.

* Review feedback:  Fixed missing spaces between multi-line strings.

* 'backend_name' assignment gets immediately overwritten in 'genvslite' case so moved it into else/non-genvslite block.

* Had to bump up 'test cases/unit/113 genvslites/...' up to 114; it collided with a newly added test dir again.

* Changed validation of 'capture' and 'captured_compile_args_...' to use MesonBugException instead of MesonException.

* Changed some function param and closing brace indentation.
2023-06-28 15:29:57 +03:00
Jussi Pakkanen 9e1e4cafd5 Condense test directory names for release. 2023-06-28 15:28:52 +03:00
Dylan Baker 6bfb47a455 rust: Override the default MSVCRT when linking Rust and !rust together
Rust by default links with the default MSVCRT, (dynamic, release).
MSVCRT's cannot be mixed, so if Meson compiles a C or C++ library and
links it with the debug MSVCRT, then tries to link that with the Rust
library there will be failures. There is no built-in way to fix this for
rustc, so as a workaround we inject the correct arguments early in the
linker line (before any libs at least) to change the runtime. This seems
to work and is recommended as workaround in the upstream rust bug
report: https://github.com/rust-lang/rust/issues/39016.

Given that this bug report has been opened since 2017, it seems unlikely
to be fixed anytime soon, and affects all (currently) released versions
of Rust.
2023-06-27 11:53:18 -07:00
Dylan Baker 772cb92624 rust: get stdlib arguments for non-rust languages when linking
Otherwise we might not get things like libstdc++, which we need.
2023-06-27 11:53:18 -07:00
Dylan Baker 5d16bd5308 modules/rust: Add a keyword argument to pass extra args to the rust compiler
This may be necessary to, for example, stop rustc complaining about
unused functions
2023-06-27 11:53:18 -07:00
Dylan Baker 43f24060f3 modules/rust: Add a `link_with` kwarg to the test method
This was requested by Mesa, where a bunch of `declare_dependency`
objects are being created as a workaround for the lack of this keyword
2023-06-27 11:53:18 -07:00
Daniele Nicolodi c900e6b0b3 mintro: record subproject in install_plan 2023-06-26 23:06:29 -04:00
Eli Schwartz a71846d749
Revert "modules: move gnome targets into gnome module"
This reverts commit a2def550c5.

This results in a 2k line file being unconditionally imported at
startup, and transitively loading two more (for a total cost of 2759
lines of code), and it's not clear it was ever needed to begin with...
2023-06-26 13:10:33 -04:00
Eli Schwartz a1ef957e34
linkers: delay implementations import until detect is run
This saves on a 1500-line import at startup and may be skipped entirely
if no compiled languages are used. In exchange, we move the
implementation to a new file that is imported instead.

Followup to commit ab20eb5bbc.
2023-06-26 13:10:33 -04:00
Eli Schwartz 5849979afa
stop importing cmake when it isn't used
We don't need a CMakeInterpreter until and unless we actually attempt to
use a cmake subproject via the cmake module.

Minus 10 files and 3679 lines of code imported at startup.
2023-06-26 13:10:33 -04:00
Eli Schwartz b1ddfabf8f
dependencies: defer importing a custom dependency until it is used
This lessens the amount of code imported at Meson startup by mapping
each dependency to a dictionary entry and using a programmable import to
dynamically return it.

Minus 16 files and 6399 lines of code imported at startup.
2023-06-26 13:10:33 -04:00
Eli Schwartz c82305db0c
dependencies: delay often-unused imports
We expose detect.py as the mesonbuild.dependencies entrypoint and import
it upfront everywhere. But unless the `dependency()` function is
actually invoked, we don't need *any* of the private implementations for
this.

Avoid doing so until, as part of actual dependency lookup, we attempt
that specific dependency method. This avoids importing big modules if
`method:` is specified, and in most cases hopefully pkg-config works and
we can avoid importing the cmake implementation particularly.

Actually avoiding most of these imports requires more refactoring. But
even so, the garden path no longer needs to import the dub dependency
impl.
2023-06-26 13:10:32 -04:00
Eli Schwartz 620bdf5895
add profiling startup import check and testcase to count it 2023-06-26 13:08:57 -04:00
Alyssa Ross ab17bd2393 rust: fix -C prefer-dynamic behavior
I noticed when building a project that uses a proc macro that Meson
passed -C prefer-dynamic for the executable, and not the proc macro,
while cargo passed -C prefer-dynamic for the proc macro, but not for
the executable.  Meson's behavior broke setting -C panic=abort on the
executable.

As far as we can tell, because we explicitly pass each library path to
rustc, the only thing -C prefer-dynamic affects in Meson is how the
standard libraries are linked.  Generally, one does not want the
standard libraries to be dynamically linked, because if the Rust
compiler is ever updated, anything linked against the old standard
libraries will likely break, due to the lack of a stable Rust ABI.
Therefore, I've reorganised Meson's behavior around the principle that
the standard libraries should only be dynamically linked when Rust
dynamic linking has already been opted into in some other way.  The
details of how this manifests are now explained in the documentation.
2023-06-21 18:05:16 -04:00
Xavier Claessens 6f2956e76c interpreter: Accept more types in default_options dict values 2023-06-20 16:10:20 -07:00
Martin Dørum e869a09bc2 add str.splitlines method
The new splitlines method on str is intended to replace usage of
fs.read('whatever').strip().split('\n').
The problem with the .strip().split() approach is that it doesn't have a
way to represent empty lists (an empty string becomes a list with one
empty string, not an empty list), and it doesn't handle Windows-style
line endings.
2023-06-20 08:28:47 -04:00
Eli Schwartz 7126ca6e27
tests: remove unnecessary non-meson syntax from meson.build
We don't use parentheses for the if function, because it's not a
function.
2023-06-07 16:40:52 -04:00
Eli Schwartz e2e6fd2e61
tests: update llvm version exclusions for hopefully the last time
This is now fixed upstream and expected to be backported to the next
point release.
2023-06-07 16:40:52 -04:00
Eli Schwartz 95ee4d7d13
tests: be DRY in llvm framework test
It's a lot more readable to not repeat big arrays.
2023-06-07 16:40:52 -04:00
Eli Schwartz 96f6600832
tests: avoid hard to debug error when llvm is found with only one method
In commit 89146e84c9 we added some
complicated code to verify the llvm framework's "combination" matrix
lookup. It expects to find llvm with both cmake and config-tool, with
the same version. But the sanity check is wonky -- it checks that both
have the same found status, instead, so if both are not found then we
proceed to try to convert the string "unknown" to a mapping of semver
integers, and this is guaranteed to fail.

This can happen for example if the system llvm exists in the general
case, but actual modules cannot be found because the system llvm does
not distribute static modules. For example, this is the case on Gentoo.

Abort more obviously by just insisting that both be found. If they
aren't both found, then investigative efforts know to look at why they
weren't found.
2023-06-07 16:40:51 -04:00
Xavier Claessens 1781a481ee pkgconfig: Add include directories from internal deps in -uninstalled.pc
Fixes: #8651
2023-06-01 18:57:40 -04:00
Xavier Claessens d17e3ce6ba preprocess: Allow preprocessing any file extensions 2023-05-31 11:59:39 -04:00
Eli Schwartz b6833c1cc1
tests: bump java compat level up to 8
Fedora's java package no longer supports 7.
2023-05-28 18:24:09 -04:00
Randy Eckenrode f71ca2825c Fix test failures on Darwin on a case-sensitive fs
This issue was encounetered while working on a contribution to nixpkgs.
Nix allows the store to be installed on a separate, case-sensitive APFS
volume. When the store is on a case-sensitive volume, these tests fail
because they try to use `foundation` instead of `Foundation`.
2023-05-28 01:51:59 -04:00
Nirbheek Chauhan aee1bb2081 llvm: Bump broken micro version for CI
16.0.4 didn't fix the LLVM breakage.
2023-05-23 18:24:08 -04:00
Nirbheek Chauhan 22df45a319 qt: Allow specifying separate tools for qt4/5/6
Currently you can only use one of qt4, qt5, qt6 in a single project
when using a machine file because the config-tool lookup for qt only
looks at `qmake` in the machine files, instead of looking up the
binary names directly.

Allow specifying `qmake` `qmake4` `qmake5` and `qmake6`.

This is necessary for gstreamer, which can build separate qt5 and qt6
plugins that are distributed as static libraries, so the user can pick
which one to use.
2023-05-23 18:24:08 -04:00
Volker Weißmann 12a2dc86ca Allow generator.process(generator.process(...))
Fixes #1141
2023-05-21 22:12:57 +03:00
Xavier Claessens c6db870fc7 rust: Add system libs used by rust std to staticlib external deps 2023-05-20 10:35:42 -04:00
Remi Thebault d5ae94f571
Check dub version (#11794)
* DubDependency._check_dub returns the version

* check for compatible Dub version

Dub versions starting at 1.32 have a new cache structure
into which Meson doesn't  know where to find compatible artifacts

* skipping D tests involving Dub

* refactor _check_dub

makes mypy happier

* make linters happy

* localize some logic
2023-05-18 15:50:35 +03:00
Volker Weißmann a8b144b71b Make `dependency('foo', static: true, method: 'cmake') link statically
Fixes #1709
2023-05-13 11:18:11 +03:00
Volker Weißmann 8d81611114 Fix paths of Fortran order dependencies
Fixes #11047
2023-05-13 10:42:03 +03:00
Ralf Gommers 6834224d72 Fix `ERROR: no toolchain found` when run from unittests
[skip actions]
2023-05-05 12:23:52 -04:00
Ralf Gommers 91c7e79519 Use release buildtype in Cython tests, and skip unless ninja backend
This matches the tests for Python extensions.

Also include some other cleanups to these `meson.build` files:

Adding `python_dep` is no longer needed, this is automatic now.
Use a single line for `import('python').find_installation()`,
because the result of `import('python')` by itself is not used
for anything.
2023-05-05 12:23:52 -04:00
Eli Schwartz 6a1427401c
tests: add a python test for bytecode compilation
Some tweaks are added to the test case so that it supports python2 as
well.
2023-05-02 19:28:35 -04:00
Eli Schwartz 0e7fb07f91
python module: add an automatic byte-compilation step
For all source `*.py` files installed via either py.install_sources() or
an `install_dir: py.get_install_dir()`, produce `*.pyc` files at install
time. Controllable via a module option.
2023-05-02 19:28:35 -04:00
Xavier Claessens 2dadc3ae5b Rust: C static library cannot link_whole Rust static library 2023-05-01 12:57:45 -04:00
Xavier Claessens a78af23686 Fix niche cases when linking static libs
Case 1:
- Prog links to static lib A
- A link_whole to static lib B
- B link to static lib C
- Prog dependencies should be A and C but not B which is already
  included in A.

Case 2:
- Same as case 1, but with A being installed.
- To be useful, A must also include all objects from C that is not
  installed.
- Prog only need to link on A.
2023-05-01 12:57:45 -04:00
Volker Weißmann f5fa56fdfa Don't use dyndep scanner when preprocessing
Fixes #11504
2023-04-27 15:08:46 -04:00
Peter Hull 1fdcc30ae6 Specify c++ 11 flag as code uses c++ 11 features 2023-04-27 01:45:12 +03:00
Volker Weißmann 38b35eca30 Add env kwarg to gnome.generate_gir().
Fixes #384
2023-04-26 14:51:10 -04:00
Nirbheek Chauhan 9cc5009a44 ci: Don't search for llvm modules with LLVM 16.0.x
See: https://github.com/mesonbuild/meson/issues/11642
2023-04-24 11:42:40 -04:00
Matthieu Bouron 09ec4f6e22 dependencies: allow to fallback on CMake to find the SDL2 library
On Windows, the SDL2 library is generally provided with only CMake config
files. This commit allows meson to fallback on CMake as a last resort to
find the SDL2 library.
2023-04-24 11:41:55 -04:00
Charles Brunet bda799dff2
fix python.version() not working in some cases
import('python').find_installation('python').version() causes exception
because of a missing initialization, when `find_installation()` receives
a name or a path.
2023-04-23 23:03:25 -04:00
Sebastian Dröge 01420bf8fc rust: Add new `rust_dependency_map` target configuration
This allows changing the crate name with which a library ends up being
available inside the Rust code, similar to cargo's dependency renaming
feature or `extern crate foo as bar` inside Rust code.
2023-04-21 15:35:06 -04:00
Dylan Baker c62989ce80 rust: add support for b_ndebug
Rust has a `debug_assert!()` macro, which is designed to be toggled on
the command line. It is on by default in debug builds, and off by
default in release builds, in cargo. This matches what meson's b_ndebug
option does in `if-release` mode.
2023-04-21 15:18:56 +05:30
Eli Schwartz 7bdb4a6926
pkgconfig module: fix traceback on invalid missing description
If the optional first "mainlib" argument is there, then we infer several
values. Otherwise, some of those values fall back to a generic default,
and two of them -- name and description -- fall back to being mandatory.

In commit e84f293f67, we removed
validation for description as part of refactoring that never actually
validated anything.
2023-04-18 19:42:29 -04:00
Daniele Nicolodi 1bc3d91112 minstall: Fix install_subdir() excludes with path separators on Win
The paths in meson.build use / as path separator, however, the paths
constructed during the directory structure walk use native path
separators, thus the path never compare equal to the excluded ones.
Normalize the exclusion paths before the comparison.
2023-04-14 21:37:52 +03:00
Sebastian Dröge 49e62877d1 rust: Don't pass dependency compile arguments to the compiler
Rust doesn't have a concept of dependency compile arguments, i.e.
something like headers. Dependencies are linked in and all required
metadata is provided by the linker flags.
2023-04-14 06:11:44 -04:00
Josh Soref cf9fd56bc9 fix various spelling issues
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-11 19:21:05 -04:00
HiPhish 439a61affa Change "can not" to "cannot" throughout project
The word "cannot" expresses inability to do something whereas "can not"
expresses the ability to refrain from doing something.
2023-04-11 17:10:01 +03:00
Eli Schwartz 8fc4649bfe
propagate the most accurate node to error messages
During evaluation of codeblocks, we start off with an iteration of
nodes, and then while evaluating them we may update the global
self.current_node context. When catching and formatting errors, we
didn't take into account that the node might be updated from the
original top-level iteration.

Switch to formatting errors using self.current_node instead, to ensure
we can point at the likely most-accurate actual cause of an error.

Also update the current node in a few more places, so that function
calls always see the function call as the current node, even if the most
recently parsed node was an argument to the function call.

Fixes #11643
2023-04-04 15:06:17 -04:00
Christoph Reiter 3c655bca39 tests/94 threads: fix build error with clang 16
It fails with "incompatible-function-pointer-types" otherwise
2023-04-03 15:32:38 -04:00
Barnabás Pőcze 410f3dfc1b tests: add test to ensure that build dir is preferred to src dir
Extend the "common/include order" test to ensure that the build
directory is preferred over the source directory. For example,
when using `configure_file()`, the resulting file should be
preferred over a file with the same name in the source directory.
2023-03-30 22:06:31 -04:00
Eli Schwartz 5dc4fcae34
test cases: make various things werror-safe
Allows getting closer to `./run_project_tests.py -- -Dwerror=true`.

- when argc and argv are not *both* used, there's a standard, compliant
  mechanism to mark the variable as unused
- generated code should not build as -Werror
- more thoroughly comment out some commented code
2023-03-28 23:34:18 -04:00
Eli Schwartz 9d98b4cb84
test that python modules nominally compile without warnings
Because we poke around with the dependency, so we might introduce some,
and have at least once.
2023-03-28 15:15:45 -04:00
Jussi Pakkanen 78d8924d43 Condense test directories for rc1. 2023-03-28 17:18:57 +03:00
Jussi Pakkanen c4cc14c27c Fix validation regexes to handle rc version numbers. 2023-03-28 09:13:19 -04:00
Eli Schwartz a7930a2cd7 backends: fix bug where meson_exe crashed if constructed with found programs
Because we base the pickled data name on the name property of the
command being run... and for built targets, `exe.name` is always just
the name. However, for an ExternalProgram this is just whatever string
we searched for, so, NOT just the basename.

This became a bigger issue once we started using generator() with the
actual program in commit 6aeec80836,
rather than first casting it to a string, because the VS backend
*always* uses the meson_exe approach for various reasons related to VS
being VS.

Outside of that, it's difficult to actually get an ExternalProgram
object passed to meson_exe -- CustomTarget lowers it to a string,
capture is handled via argparse instead of pickling, etc.

Fixes #11593
2023-03-28 09:12:02 -04:00
Dylan Baker 4a014d1724 Add support for meson.options as a replacement for meson_options.txt
We will still try to load `meson_options.txt` if `meson.options` doesn't
exist. Because there are some advantages to using `meson.options` even
with older versions of meson (such as better text editor handling)
we will not warn about the existence of a `meson.options` file if a
`meson_options.txt` file or symlink also exists.

The name `meson.options` was picked instead of alternative proposals,
such as `meson_options.build` for a couple of reasons:

  1. meson.options is shorter
  2. While the syntax is the same, only the `option()` function may be
     called in meson.options, while, it may not be called in meson.build
  3. While the two files share a syntax and elementary types (strings,
     arrays, etc), they have different purposes: `meson.build` declares
     build targets, `meson.options` declares options. This is similar to
     the difference between C's `.c` and `.h` extensions.

As an implementation detail `Interpreter.option_file` has been removed,
as it is used exactly once, in the `project()` call to read the options,
and we can just calculate it there and not store it.

Fixes: #11176
2023-03-28 15:01:10 +03:00
Xavier Claessens 65c22d8c38 custom_target: libfoo.so.1 is linkable 2023-03-27 15:19:17 -04:00
Eli Schwartz b3b57342ef
tests: fix critical existence failure of doxygen test
It was totally subproject-unsafe, and setting a super bad example. This
is bad, because doxygen is annoying to get right and we occasionally
tell people to go use our example test case.

There is a fun nuance here, that makes doxygen unpredictably work on
some versions, and fail on others. Specifically, values must be quoted
in doxygen 1.8, but not in doxygen 1.9, or they break -- but only if the
output directory contains spaces. This was "fixed" in commit

ef91bacb7a

which actually caused it to act like an unquoted OUTPUT_DIRECTORY is not
provided at all, and then fixed for real in commit

eb3d1eb5ad

For portability, it is necessary to quote this just to be on the safe
side.

Fixes #11579
2023-03-26 00:37:39 -04:00
Eli Schwartz a024d75e15
backends: add a new "none" backend
It can only be used for projects that don't have any rules at all, i.e.
they are purely using Meson to:

- configure files
- run (script?) tests
- install files that exist by the end of the setup stage

This can be useful e.g. for Meson itself, a pure python project.
2023-03-20 17:22:50 -04:00
Daan De Meyer adb619db61 Stop using replace_if_different() for coredata pickle file
This was added in f774609 to only change the access time of the
coredata file if the coredata struct actually changed. However,
this doesn't work as pickle serializations aren't guaranteed to
be stable. Instead, let's manually check if options have changed
values and skip the save if they haven't changed.

We also extend the associated unit test to cover all the option
types and to ensure that configure does get executed if one of the
options changes value.
2023-03-16 17:18:30 -04:00
Jussi Pakkanen 58e6fb40f6 Make generator exe more resilient. 2023-03-11 22:56:13 +02:00
Eli Schwartz f8eba38801 tests: allow a long test to have more time to complete before timing out
This test is intended to test really long output, so it prints 100k
lines of stdout/stderr. It completes in two seconds on my machine, but
the default 30-second timeout is apparently too much for CI, because on
Windows we often get flaky tests due to this. e.g. we'll get within 200
lines of the end.

Bump the CI time by x2. We know this isn't particularly surprising
behavior, and allowing it to request another 30 seconds won't hang the
CI. But it will save us from some spurious failures and restarted jobs.
2023-03-09 21:36:33 -08:00
Eli Schwartz c91a6ad013 re-deduplicate feature warnings printed at the end of setup
In commit eaf365cb3e we explicitly sorted
them for neatness, with the rationale that we were restoring intentional
behavior and we only need a set for stylistic purposes.

This actually wasn't true, because we never sorted them to begin with
(we did sort the version numbers), but sorting them is fine. The bigger
issue is that we actually used a set to avoid printing the same feature
type multiple times. Now we do print them multiple times -- because each
registered feature includes the unique node.

Fix this by using both sorted and a set.

Fix tests that should in retrospect have flagged this as an issue, but
were added later on in the same series to check something else entirely,
happen to cover this too, and were presumably copied directly from
stdout as-is...
2023-03-09 22:04:38 -05:00
Xavier Claessens 0f67913dee typed_kwargs: Extend since_values and deprecated_values for types 2023-03-04 14:19:27 -05:00
Eli Schwartz a3f4f6c88f
interpreter: report FeatureNew for kwargs to project()
We need to know the project minimum version before evaluating the rest
of the function. There's three basic approaches:
- try to set it inside KwargInfo
- just run a minimal version of func_project for this, then load
  everything after
- drop down to the AST and set it before anything else

In order to handle FeatureNew emitted by a FunctionNode evaluated
before project() due to being inlined, such as `version: run_command()`,
only option 3 suffices, the rest all happen way too late. Since we have
just added AST handling support for erroring out, we can do that to set
the version as well.
2023-03-01 23:37:55 -05:00
Eli Schwartz 314382d6ff
handle meson_version after parsing but before invalid project() kwargs
If we add new kwargs to a function invoked on the first line, we also
need to validate the meson_version before erroring out due to unknown
kwargs. Even if the AST was successfully built.

Amusingly, we also get to improve the error message a bit. By passing
the AST node instead of an interpreter node, we get not just line
numbers, but also column offsets of the issueful meson_version. That
broke the stdout of another failing test; adapt it.
2023-03-01 23:36:31 -05:00
Eli Schwartz 878c1604e6
handle meson_version even when the build file fails to parse
If the meson.build file is sufficiently "broken", even attempting to lex
and parse it will totally fail, and we error out without getting the
opportunity to evalaute the project() function. This can fairly easily
happen if we add new grammar to the syntax, which old versions of meson
cannot understand. Setting a minimum meson_version doesn't help, because
people with a too-old version of meson get parser errors instead of
advice about upgrading meson.

Examples of this include adding dict support to meson.

There are two general approaches to solving this issue, one of which
projects are empowered to do:

- refactor the project to place too-new syntax in a subdir() loaded
  build file, so the root file can be interpreted

- teach meson to catch errors in building the initial AST, and just load
  enough of the AST to check for meson_version advice

This implements the latter, allowing to future-proof the build
grammar.
2023-03-01 23:30:49 -05:00
Xavier Claessens f0dc61a764 interpreter: Add testcase..endtestcase clause support
This is currently only enabled when running unit tests to facilitate
writing failing unit tests.

Fixes: #11394
2023-03-01 20:13:34 -05:00
Daniele Nicolodi f39ccde513 mintro: Add exclude_{files, dirs} to install_subdir install_plan
These are necessary for projects outside Meson itself that want to
extend the 'meson install' functionality as meson-python does to
assemble Python package wheels from Meson projects.

Fixes #11426.
2023-02-27 07:03:30 -05:00
Eli Schwartz cf07596cf6 test cases: use best practices method to find the python3 program
We do not need the python module's find_installation() for this, as this
does various things to set up building and installing python modules
(pure python and C-API). This functionality is already tested in the
python tests.

Elsewhere, when we just need an interpreter capable of running python
scripts in order to guarantee a useful scripting language for custom
commands, it suffices to use find_program(), which does not run an
introspection script or do module imports, and is thus faster and
a bit cleaner.

Either way, both methods are guaranteed to find the python3 interpreter,
deferring to mesonlib.python_command for that guarantee.

test "71 summary" can sometimes return the python command with the
".exe" part all uppercased for mysterious Windows reasons. Smooth this
over with ExternalProgram.
2023-02-24 20:45:00 -05:00
Dylan Baker c0db0b73da Implement rustc controlled whole-archive linking
Rustc as of version 1.61.0 has support for controlling when
whole-archive linking takes place, previous to this it tried to make a
good guess about what you wanted, which worked most of the time. This is
now implemented.

Additionally, rustc makes some assumptions about library names
(specifically static names), that meson does not keep. This can be fixed
with rustc 1.67, where a new +verbatim modifier has been added. We can
then force rustc to use the name we give it. Before that, we can sneak
through `/WHOELARCHIVE:` in cases of dynamic linking (into a dll or
exe), but we can't force the archiver to do what we want (rustc
considers the archiver to be an implementation detail). The only
solution I can come up with is to copy the library to the format that
rustc expects. I've run into some issues with that as well, so we warn
in that case.

The decisions to leave static into static broken on MSVC for 1.61–1.66
was made because:

 1) The work around is non-trivial, and we would have to support that
    workaround for a long time
 2) The number of users of Rust in Meson is small
 3) The number of users of Rust in Meson on Windows, with MSVC is tiny
 4) Using rustup to update rustc on windows is trivial, and solves the
    problem completely

Fixes: #10723
Fixes: #11247

Co-authored-by: Nirbheek Chauhan <nirbheek@centricular.com>
2023-02-22 15:35:50 -08:00
L. E. Segovia 088727164d interpreter/mesonmain: Add build_options method
This method allows meson.build to introspect on the changed options.
It works by merely exposing the same set of data that is logged by
MesonApp._generate.

Fixes #10898
2023-02-20 11:05:06 -05:00
Xavier Claessens 744e6ebe1d nasm: Link with windows CRT libs when nasm is used as linker language 2023-02-20 09:58:34 -05:00
Dylan Baker b2473b61cc interpreter: add FeatureOption.enable_if and .disable_if
This adds two new methods, that are conceptually related in the same way
that `enable_auto_if` and `disable_auto_if` are. They are different
however, in that they will always replace an `auto` value with an
`enabled` or `disabled` value, or error if the feature is in the
opposite state (calling `feature(disabled).enable_if(true)`, for
example). This matters when the feature will be passed to
dependency(required : …)`, which has different behavior when passed an
enabled feature than an auto one.

The `disable_if` method will be controversial, I'm sure, since it
can be expressed via `feature.require()` (`feature.require(not
condition) == feature.disable_if(condition)`). I have two defences of
this:

1) `feature.require` is difficult to reason about, I would expect
   require to be equivalent to `feature.enable_if(condition)`, not to
   `feature.disable_if(not condition)`.
2) mixing `enable_if` and `disable_if` in the same call chain is much
   clearer than mixing `require` and `enable_if`:
   ```meson
   get_option('feat') \
     .enable_if(foo) \
     .disable_if(bar) \
     .enable_if(opt)
   ```
   vs
   ```meson
   get_option('feat') \
     .enable_if(foo) \
     .require(not bar) \
     .enable_if(opt)
   ```
   In the first chain it's immediately obvious what is happening, in the
   second, not so much, especially if you're not familiar with what
   `require` means.
2023-02-15 22:58:50 -05:00
Dylan Baker 3589815eb9 interpreter: add a feature.enable_auto_if
It's always been strange to me we don't have an opposite method of the
`disable_auto_if` method, but I've been pressed to find a case where we
_need_ one, because `disable_auto_if` can't be logically contorted to
work. I finally found the case where they're not equivalent: when you
don't want to convert to a boolean:

```meson
f = get_option('feat').disable_auto_if(not foo)
g = get_option('feat').enable_auto_if(foo)

dep1 = dependency('foo', required : f)
dep2 = dependency('foo', required : g)
```
2023-02-15 22:58:50 -05:00
Xavier Claessens d21b64487e preprocess: Add dependencies kwarg 2023-02-15 15:12:34 -05:00
Xavier Claessens c2a55bfe43 preprocess: Allow custom_tgt, custom_idx and generated_list
It was documented to be supported but only File and str were actually
working.
2023-02-15 15:12:34 -05:00
Charles Brunet 04f233a80d allow install script to run in dry-run mode 2023-02-14 10:50:10 -05:00
Eli Schwartz e0b63d539e add a CI runner testing that Meson runs correctly under PyPy3
Silence a couple of framework tests that need to be skipped since we
don't install their dependencies for pypy3.
2023-02-13 09:09:10 -05:00
Eli Schwartz 94a190baa2
cython: add unittest to verify that depfiles work 2023-02-10 02:16:54 -05:00
Eli Schwartz 66740b4ce1
CI: skip gpgme-config test on Arch
gpgme has decided that config-tool is bad, which makes sense. They've
also decided that they will only install theirs, if gpg-error also
installs one, which is a bit... confusing. Anyway, it's impossible to
know whether it should or should not exist, so just accept that this
test is ready to be skipped on distros that currently no longer have
this ancient config-tool script.

Victory is within reach!
2023-02-08 18:52:27 -05:00
Nirbheek Chauhan 301de27529 test cases/vala: Fix clang error during int to pointer coercion
```
clang [...] -c valaprog.p/GLib.Thread.c
../test cases/vala/5 target glib/GLib.Thread.vala:17:17: error: incompatible integer to pointer conversion passing 'gint' (aka 'int') to parameter of type 'gpointer' (aka 'void *') [-Wint-conversion]
        g_thread_exit (get_ret_code ());
                       ^~~~~~~~~~~~~~~
/usr/include/glib-2.0/glib/gthread.h:158:66: note: passing argument to parameter 'retval' here
void            g_thread_exit                   (gpointer        retval);
                                                                 ^
1 error generated.
```
2023-02-07 05:43:39 -05:00
Dudemanguy f2cb8e2ad5 add cc.has_function_attribute('vector_size') 2023-02-01 13:26:09 -08:00
Eli Schwartz 08e722d44c
log running commands a bit better by doing proper shell quoting 2023-01-31 00:25:43 -05:00
Konstantin 92ac0e48e5 tests/llvm: require cmake 3.11
This is a weird but working way to skip this test from running on
bionic (where it should not run).
2023-01-28 20:16:06 +01:00
Konstantin 89146e84c9 cmake: allow dynamic linking with LLVM
llvm-config is unsuitable for standard cross-compile,
because we need to build llvm especially for it, which
is not done is almost any distros, so, for example,
standard bootstrap chroot will be unsuitable.

This patch is trying to acheive feature parity between
config-tool searching of LLVM and CMake-based one,
which is arch-agnostic.

Signed-off-by: Konstantin <ria.freelander@gmail.com>
2023-01-28 20:16:06 +01:00
Eli Schwartz a38ad3039d
tests: avoid unexpected failure when cmake is not installed
This test case checks stdout and demands a `dependency()` lookup fail.
The resulting error message can be different depending on whether cmake
is installed, or not. For cmake-specific tests we would simply skip the
test if cmake is not installed, but here we can just fine-tune the
pattern matching we use to determine if the test failed "correctly".

Fixes #11320
2023-01-25 22:03:11 -05:00
Dylan Baker 43a2404707 Deprecate passing strings to non-string options
Currently Meson allow the following (Muon does not):
```meson
option('foo', type : 'boolean', value : 'true')
option('bar', type : 'integer', value : '42')
```

This is possibly a holdover from very old code, but it's a bad idea and
we should stop doing it. This deprecation is the first stop on that
journey.
2023-01-20 00:18:42 -05:00
Dylan Baker f5eaebb4b4 use typed_kwargs for the various option subparsers
We make use of allow_unknown=True here, which allows us to only look at
the common arguments in the main option parser, and then look at the
specific options in the dispatched parsers. This allows us to do more
specific checking on a per overload basis.
2023-01-20 00:18:42 -05:00
Xavier Claessens 1a0eff0054 devenv: Allow dumping into file and select a format
It is often more useful to generate shell script than dumping to stdout.
It is also important to be able to select the shell format.

Formats currently implemented:
- sh: Basic VAR=prepend_value:$VAR
- export: Same as 'sh', but also export VAR
- vscode: Same as 'sh', but without substitutions because they don't
  seems to work. To be used in launch.json's envFile.
2023-01-18 11:06:48 -05:00
Gijs Peskens 5a4168c410 Fix nasm when target has threads as added dependency 2023-01-18 10:05:33 -05:00
Thomas Li 9b999ddc87 BUG: Fix generated sources not being included as dependencies in cython transpilation 2023-01-15 16:59:47 -05:00
Dylan Baker 6aeec80836 backends: Stop passing generator exes to ExecutableSerialisation as strings
The code below this already handles being passed an Executable or
ExternalProgram, and it does it correctly, since it handles host
binaries that need an exe_wrapper correctly, while the code in the
generator paths doesn't.

The xcode backend is, like always, problematic, it doesn't handle things
the same way as the ninja and vscode backends, and generates a shell
script instead of using meson as a wrapper when needed (it seems likely
that just forcing the meson path for xcode would be better). I don't
have a working mac to develop a fix for, so I've left a todo comment
there.

Fixes: #11264
2023-01-10 13:02:07 -08:00
Paolo Bonzini 3e917eba0e add testcase for declare_dependency(objects: ...)
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2023-01-04 09:44:32 -08:00
Paolo Bonzini 8d2940024b allow passing generated objects in the "objects" keyword argument
Generated objects can already be passed in the "objects" keyword argument
as long as you go through an extract_objects() indirection.  Allow the
same even directly, since that is more intuitive than having to add them
to "sources".

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2023-01-04 09:44:32 -08:00
Eli Schwartz 2fa0749175
add license_files kwarg to project
Hook this up to installed dependency manifests. This is often needed
above and beyond just an SPDX string -- e.g. many licenses have custom
copyright lines.
2022-12-27 20:29:46 -05:00
Eli Schwartz 26b83eee94 tests: fix test that has source code incompatible with modern C
Delayed until clang 16, -Werror=incompatible-function-pointer-types is
the default. GCC 14 is "likely to do the same".

See https://wiki.gentoo.org/wiki/Modern_C_porting
2022-12-27 09:12:28 -08:00
Paolo Bonzini b38bf09b94 add more testcases for prebuilt objects
Cover more cases including passing objects via ExtractedObjects and
CustomTarget.
2022-12-21 13:36:18 -08:00
Jussi Pakkanen 27bd499772
Merge pull request #11174 from bgilbert/jar-manifest
depfixer: silence `fix_jar()` and make it do something
2022-12-16 20:51:12 +02:00
Tristan Partin 7254db36a7
Try to find the jni dependency when javac is a Darwin stub
Darwin-based systems, at least macOS, provide various JDK executable
stubs in
/System/Library/Frameworks/JavaVM.framework/Versions/*/Commands.
These stubs are placed in such a way that they break the heuristics of
the JNI system dependency. If a javac being analyzed to find a Java home
is a stub, use /usr/libexec/java_home.

See https://stackoverflow.com/a/15133344/7572728 for more details.

Closes #11173
2022-12-15 20:24:25 -06:00
Benjamin Gilbert 35e230e48c depfixer: silence fix_jar() and make it do something
fix_jar() tries to remove an existing Class-Path entry from the jar
manifest by postprocessing the manifest and passing it to `jar -um`.
However, `jar -um` can only add/replace manifest entries, not remove
them, and it also complains loudly when replacing an entry:

    Dec 13, 2022 7:11:19 PM java.util.jar.Attributes read
    WARNING: Duplicate name in Manifest: Manifest-Version.
    Ensure that the manifest does not have duplicate entries, and
    that blank lines separate individual sections in both your
    manifest and in the META-INF/MANIFEST.MF entry in the jar file.

Thus fix_jar() produces one such warning for each entry in the manifest
and accomplishes nothing else.

Use jar -uM instead.  This completely removes the manifest from the jar
and allows adding it back as a normal zip member, fixing fix_jar() and
avoiding the warnings.

Fixes: https://github.com/mesonbuild/meson/issues/10491
Fixes: c70a051e93 ("java: remove manifest classpath from installed jar")
2022-12-14 15:37:59 -05:00
Eli Schwartz 100456de07
fix broken fs.copyfile function that crashed if you tried to use it
At least, if you tried to use it when passing an install_dir. Because
T.Sequence is horrible and we should never use it, and the annotations
are a lie that produces bugs.

So, fix the annotations on CustomTarget to never allow this to happen
again, and also fix the function too. Move some definitions elsewhere
inline to satisfy the linter.

Fixes #11157
2022-12-11 18:28:39 -05:00
Tristan Partin 2e600ef710
Rename java.generate_native_headers to java.native_headers
This follows the Meson naming scheme which typically leaves off a verb
like generate.
2022-12-11 14:50:26 -06:00
Eli Schwartz 5bea2ca198 CI: skip libgcrypt test on msys2
This is no longer implicitly installed due to libxslt. Actually though,
we don't need to test this in order to ensure that the custom dependency
works -- we have other jobs that test it, and the config-tool handling
itself won't suddenly fail on msys2 specifically.
2022-12-11 22:43:31 +02:00
Jussi Pakkanen dbb33aaf92
Merge pull request #11024 from dcbaker/submit/bindgen-dependencies
Add a `dependencies` keyword argument to bindgen
2022-12-11 00:09:27 +02:00
Marvin Scholz bcd50e71d5 test: Add get_define test with prefix array 2022-12-06 10:59:00 -05:00
Eli Schwartz 9e8a3b9cbd when generating optional utility targets in ninja, skip existing aliases too
When auto-generating e.g. a `clang-format` target, we first check to see
if the user has already defined one, and if so we don't bother creating
our own. We check for two things:

- if a ninja target already exists, skip
- if a run_target was defined, skip

The second check is *obviously* a duplicate of the first check. But the
first check never actually worked, because all_outputs was only
generated *after* generating all utility rules and actually writing out
the build.ninja file. The check itself compares against nothing, and
always evaluates to false no matter what.

Fix this by reordering the target creation logic so we track outputs
immediately, but only error about them later. Now, we no longer need to
special-case run_target at all, so we can drop that whole logic from
build.py and interpreter.py, and simplify the tracked state.

Fixes defining an `alias_target()` for a utility, which tried to
auto-generate another rule and errored out. Also fixes doing the same
thing with a `custom_target()` although I cannot imagine why anyone
would want to produce an output file named `clang-format` (unless clang
itself decided to migrate to Meson, which would be cool but feels
unlikely).
2022-12-05 12:33:17 -08:00
Dylan Baker d49e6bc038 modules/rust: Add support for dependencies in bindgen
This is needed for cases where we need external C headers, which are
passed to clang.
2022-12-05 12:23:55 -08:00
Dylan Baker bb875280b6 modules/rust: Add support for string include_directories
Which we support for basically every other case, but not this one.
2022-12-05 15:20:09 -05:00
David Robillard e85138fcc8 Fix various spelling errors
Found with codespell.
2022-11-24 15:17:23 -05:00
Jussi Pakkanen 3ae89a7150 Handle freezing tests. Fixes #10752. 2022-11-21 16:44:24 +02:00
Eli Schwartz 174e05d0f6
tests: fix qt project test when running with qt4
*.qrc files converted to C++ sources could make use of Qt headers, and
in practice for qt4 they seem to. Since this is Qt code to begin with,
it makes sense to depend on the Qt being targeted regardless of version.
2022-11-17 19:10:51 -05:00
Eli Schwartz aa84c55bef
tests: fix edge case where non-default python is used, by skipping it
In a couple of python module tests, we try to test things that rely on
the default python being the same one we look up in the python module.
This is unsolvable for the deprecated python3 module, as it actually
uses the in-process version of python for everything. For the python
module, we could actually look up the default system python instead of
the one we are running with, but then we wouldn't be testing the
functionality of that alternative python... and also the install
manifest tests would see files installed for the wrong version of
python, and report a combination of missing+extra files...

Solve both tests by just skipping the parts we cannot check.
2022-11-14 19:16:57 -05:00
Xavier Claessens a6db624aad Implement `in` operator on string 2022-11-06 17:22:00 +02:00
Xavier Claessens f5871e240d backends: Try guessing install tag for all installed files
It was only trying to guess install tag, and log missing tags, for files
installed by install_data(). Do it also for all other files, especially
custom_taget() that commonly installs generated headers.
2022-11-02 14:53:35 +02:00
Jussi Pakkanen 060595f0d0 Add regression test for pch link_whole bug. 2022-11-01 18:43:08 +02:00
L. E. Segovia 7e5b0760ce minstall: make do_strip run with -Sx for macOS targets
This commit also adds some extra symbol noise to lib.c, in order to aid
detection of the debug information with nm.

Fixes #10943
2022-11-01 17:56:18 +02:00
Eli Schwartz f9d6ae8d57
Revert "tests: Test extern'd globals on MacOS with the Apple Archiver"
This reverts commit d285be763f.

This is part of #10628 and needs to be reverted, as it breaks other
things.

See https://github.com/mesonbuild/meson/pull/10628#issuecomment-1230560772
2022-10-31 23:22:07 -04:00
Xavier Claessens 81763e610f both_libraries: Make sure to select the right linker for static lib
Regression test: libccpp has both C and C++ sources. The executable only
has C sources. It should still link using the C++ compiler. When using
both_libraries the static has no sources and thus no compilers,
resulting in the executable linking using the C compiler.
https://github.com/Netflix/vmaf/issues/1107
2022-10-31 20:21:07 -04:00
Paolo Bonzini 212af2b278 gnome: allow generator outputs as gdbus-codegen inputs
GeneratedLists as sources to `gnome.gdbus_codegen` worked until
version 0.60 of Meson, but broke in 0.61 because of the conversion to
typed_pos_args and typed_kwargs.  Reinstate this by adding them to the
decorators and annotations.

Note that gdbus_codegen desugars to two custom_targets and therefore the
generator is invoked twice.  This is not optimal, but it should not be
an issue and can be changed later.

Fixes: 53a187ba2 ("modules/gnome: use typed_pos_args for gdbus_codegen", 2021-11-01)
Fixes: ef52e6093 ("modules/gnome: use typed_kwargs for gdbus_codegen", 2021-11-08)
2022-10-28 13:06:52 +03:00
Paolo Bonzini 2fe3271f77 gnome: allow custom targets as gdbus-codegen inputs
Custom targets as sources to `gnome.gdbus_codegen` worked until version 0.60
of Meson, but broke in 0.61 because of the conversion to typed_pos_args
and typed_kwargs.  Reinstate this by adding custom targets to the
decorators and annotations.

While generators also used to work, they are a bit tricky because
gdbus_codegen desugars to two custom_targets and therefore the generator
is invoked twice.  This should not be a problem, but be explicit and
leave that to a separate commit to highlight the problem.

Fixes: 53a187ba2 ("modules/gnome: use typed_pos_args for gdbus_codegen", 2021-11-01)
Fixes: ef52e6093 ("modules/gnome: use typed_kwargs for gdbus_codegen", 2021-11-08)
2022-10-28 13:06:52 +03:00
Xavier Claessens 725f77650d tests: Add nasm compiler checks 2022-10-25 18:09:36 +03:00
Xavier Claessens d67c4c6ab0 nasm: Use an hello world test that works on 32bits too
Fixes: #10956
2022-10-25 18:09:36 +03:00
Jussi Pakkanen 458dcf8aac Condense test directory numbers. 2022-10-25 00:03:32 +03:00
Xavier Claessens 942aea230f Add MASM compiler
ml and armasm are Microsoft's Macro Assembler, part of MSVC.
2022-10-24 14:52:13 +02:00
Elliott Sales de Andrade 9c4d6088b1 Accept disablers in summary values
They are commonly used as a replacement for a `dependency`, and not
accepting them in `summary` breaks the last example in [1] when used as
a value.

[1] https://mesonbuild.com/Disabler.html#disabling-parts-of-the-build
2022-10-24 11:17:18 +02:00
Xavier Claessens 4f4076bfc0 nasm: Harcode default path on Windows
NASM's installer does not add itself into PATH, even when installed by
choco.
2022-10-24 11:06:57 +02:00
Xavier Claessens d29ef2b128 Add yasm as fallback for nasm language 2022-10-24 11:06:57 +02:00
Xavier Claessens 01ee141339 Add NASM compiler 2022-10-24 11:06:57 +02:00
Jussi Pakkanen 4c2b64188d
Merge pull request #10916 from xclaesse/preprocess
Add cc.preprocess() method
2022-10-23 17:24:46 +03:00
Xavier Claessens ebbaeec51b gnulike: Fix preprocessing files with any extension 2022-10-23 12:21:46 +02:00
Xavier Claessens 1d56df9409 Add unit test for cc.preprocess() 2022-10-23 12:21:46 +02:00
Xavier Claessens 064165485c Fix excluding sources for static lib in both_libraries()
When using both_libraries(), or library() with default_library=both, we
remove all sources from args and kwargs when building the static
library, and replace them by the objects from the shared library. But
sources could also come from any InternalDependency, in which case we
currently build them twice (not efficient) and link both objects into
the static library.

It also means that when we needlessly build those source for the static
library, it miss order dependency on generated headers that we removed
from args/kwargs, which can cause build errors in the case the source
from static lib is compiled before the header in shared lib gets
generated.

This happened in GLib:
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2917.
2022-10-23 13:18:34 +03:00
Jan Tojnar a590cfde0c compilers: Add optimization=plain option
https://github.com/mesonbuild/meson/pull/9287 changed the `optimization=0`
to pass `-O0` to the compiler. This change is reasonable by itself
but unfortunately, it breaks `buildtype=plain`, which promises
that “no extra build flags are used”.

`buildtype=plain` is important for distros like NixOS,
which manage compiler flags for optimization and hardening
themselves.

Let’s introduce a new optimization level that does nothing
and set it as the default for `buildtype=plain`.
2022-10-09 14:43:18 +03:00
Xavier Claessens ed129a5311 wrap: If the directory exists in a sub-subproject, uses it inplace
A subproject could have a sub-subproject as a git submodule, or part of
the subproject's release tarball, and still have a wrap file for it
(e.g. needed for [provide] section). In that case we need to use the
source tree for the sub-subproject inplace instead of downloading a new
copy into the main project.

This is the case with GLib 2.74, it has a subproject "gvdb" as git
submodule, and part of release tarball, it ships gvdb.wrap file as well.
2022-09-28 00:17:42 -04:00
Eli Schwartz eb69fed2f6
python module: allow specifying the pure kwarg in the installation object
Fixes #10523
2022-09-19 21:13:37 -04:00
Eli Schwartz 719dd0d2a0
dependencies: log the real reason for a dependency lookup failing
In the debug logs, always log if a dependency lookup raises a
DependencyException. In the `required: false` case, this information
would otherwise disappear forever, and we would just not even log that
we tried it -- it doesn't appear in "(tried x, y and z)".

In the `required: true` case, we would re-raise the first exception if
it failed to be detected. Update the raise message with the same
information we print to the debug logs, indicating which dependency and
which method was used in the failing attempt.
2022-09-12 19:16:59 -04:00
Dylan Baker 37663da83e tests: Add a test for a target with no sources
Since this was broken for a long time, we should have a test for it.
2022-09-09 19:13:46 -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
Jan Alexander Steffens (heftig) d682d3f837 Add missing cdata update in genmarshal tests
Otherwise the test is flaky, as it may try to include a header that's
not generated yet.
2022-09-04 00:07:34 -04:00