Commit Graph

74 Commits

Author SHA1 Message Date
Paolo Bonzini e71d1dc6c3 unittests: add test for CFLAGS in linker command line
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-05-15 02:03:46 -04:00
Paolo Bonzini fc9fd42899 interpreter: do not use pathlib for DependencyVariableString creation
Path.is_dir() can raise a PermissionError if a parent does not have
the executable permission set; plus the "in p.parents" tests are
very expensive.  Do not use Path at all.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-04-24 17:52:13 +03:00
Jussi Pakkanen cdf4b39e6f Condense directory names for 1.8 rc1. 2025-04-14 23:36:31 +03:00
Jon Turney f164ec692f CI: Fix filemode tests with cygwin 3.6.0
Put cygwin filemode tests back under the sourcedir
Remove inheritable permissions from the sourcedir

For :reasons:, the unit tests which check file mode were built in the
tempdir.

Instead, remove inheritable permissions from the working directory
(which the GitHub VM image has set for some reaons), since they can
interfere with getting exactly the file mode you asked for.

Partially reverts 04ae1cfb79
2025-03-21 14:44:46 -07:00
Patrick Steinhardt 43ea11ea49 compilers: convert `b_sanitize` to a free-form array option
In the preceding commit we have started to perform compiler checks for
the value of `b_sanitize`, which allows us to detect sanitizers that
aren't supported by the compiler toolchain. But we haven't yet loosened
the option itself to accept arbitrary values, so until now it's still
only possible to pass sanitizer combinations known by Meson, which is
quite restrictive.

Lift that restriction by adapting the `b_sanitize` option to become a
free-form array. Like this, users can pass whatever combination of
comma-separated sanitizers to Meson, which will then figure out whether
that combination is supported via the compiler checks. This lifts a
couple of restrictions and makes the supporting infrastructure way more
future proof.

A couple of notes regarding backwards compatibility:

  - All previous values of `b_sanitize` will remain valid as the syntax
    for free-form array values and valid combo choices is the same. We
    also treat 'none' specially so that we know to convert it into an
    empty array.

  - Even though the option has been converted into a free-form array,
    callers of `get_option('b_sanitize')` continue to get a string as
    value. We may eventually want to introduce a kwarg to alter this
    behaviour, but for now it is expected to be good enough for most use
    cases.

Fixes #8283
Fixes #7761
Fixes #5154
Fixes #1582

Co-authored-by: Dylan Baker <dylan@pnwbakers.com>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
2025-03-09 18:06:14 -04:00
Dylan Baker f64cda3d80
unittests: Use more subtests 2025-03-06 23:01:53 -05:00
Jussi Pakkanen d37d649b08 Make all Meson level options overridable per subproject. 2025-02-13 23:57:48 +02:00
Jussi Pakkanen 0279acbfe5 Condensed directory names for release. 2025-01-09 16:52:16 +02:00
Jussi Pakkanen 16cf71f051 Handle top level options set in subprojects. Closes #13847. 2024-12-16 21:12:39 +02:00
Andoni Morales Alastruey c02e0b7b1e pkgconfig: fix use of uninstalled libraries
Prepend the path of uninstalled libraries to PKG_CONFIG_PATH
so they have preference over other search paths set by the
user.

see: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/3247
2024-10-23 08:04:50 -04:00
Jussi Pakkanen fbeedf4b14 Condense test directories. 2024-10-20 21:20:13 +03:00
Pierre Lamot 6797f9bc15 qt module: allow has_tools to specify which tools to check
This allows checking for tools that may not be available in older version of qt
or avoiding requesting tools that may not be necessary for a given project

Co-authored-by: Nirbheek Chauhan <nirbheek@centricular.com>
2024-09-24 10:24:47 -07:00
L. E. Segovia 761e2470d4 compilers: Allow prelinking with Apple Clang 2024-08-26 01:05:42 +03:00
Dylan Baker e808aa161c
unittests: use TestCase.addCleanup for cleaning up builddirs 2024-08-15 14:15:03 -04:00
Eli Schwartz 077d540c10
unittests: fix EncodingWarnings. minus 123 warnings collected by pytest 2024-07-30 14:13:12 -04:00
Jussi Pakkanen 61c742fae9 Remove language (AKA compiler) type from OptionKey. 2024-07-17 18:37:51 +03:00
Jussi Pakkanen 0d7bb776e2 Move OptionKey in the option source file. 2024-07-11 11:53:39 +03:00
Jussi Pakkanen 9a6fcd4d9a Replace direct indexing with named methods. 2024-06-14 17:19:53 +03:00
Jussi Pakkanen c0d86024f5 Rename option variable to optstore to make it unique. 2024-06-14 17:19:53 +03:00
Jan Alexander Steffens (heftig) 05bbe45cc2 tests: Fix unit tests with high parallelism
On Arch's shiny new 48-core/96-thread build server, the
`test_install_log_content` test fails because of an unexpected
`invalid-symlink.txt` file. Apparently the test runs in parallel with
`test_install_subdir_symlinks`, which modifies the `59 install subdir`
source directory.

To fix this, make `install_subdir_invalid_symlinks` copy the entire test
into a tmpdir before modifying it.
2024-03-15 09:24:06 -07:00
Alyssa Ross 9322a29d7f Skip pkg-config-dependent tests if it's missing 2023-12-17 16:21:11 -05:00
Dylan Baker e991c4d454 Use SPDX-License-Identifier consistently
This replaces all of the Apache blurbs at the start of each file with an
`# SPDX-License-Identifier: Apache-2.0` string. It also fixes existing
uses to be consistent in capitalization, and to be placed above any
copyright notices.

This removes nearly 3000 lines of boilerplate from the project (only
python files), which no developer cares to look at.

SPDX is in common use, particularly in the Linux kernel, and is the
recommended format for Meson's own `project(license: )` field
2023-12-13 15:19:21 -05:00
Eli Schwartz 5f659af870
ninja backend: don't hide all compiler warnings for transpiled languages
This was originally added for vala only, with the rationale that vala
generates bad code that has warnings. Unfortunately, the rationale was
fatally flawed. The compiler warns about a number of things, which the
user can control depending on their code (or their code generator's
code), but some of those things are absolutely critical to warn about.

In particular, GCC 14 and clang 17 are updating their defaults to warn
-- and error by default for -- invalid C code that breaks the standard,
but has been silently accepted for over 20 years "because lots of people
do it". The code in question is UB, and compilers will generate faulty
machine code that behaves erroneously and probably has a mass of CVEs
waiting to happen.

Compiler warnings are NOT safe to just... universally turn off. Compiler
warnings could be either:

- coding style lints

- threatening statements that the code is factually and behaviorally wrong

There is no magic bullet to ignore the former while respecting the
latter. And the very last thing we should ever do is pass `-w`, since
that causes ALL warnings to be disabled, even the manually added
`-Werror=XXX`.

If vala generated code creates warnings, then the vala compiler can
decrease the log level by generating better code, or by adding warning
suppression pragmas for *specific* issues, such as unused functions.
2023-12-05 19:51:56 -05:00
Jussi Pakkanen 97dc8801a6 Renumber test dirs for rc3. 2023-11-12 19:18:06 +02:00
Jussi Pakkanen 3bbe66e971 Condense test directories for RC1. 2023-10-27 17:43:03 +03:00
Benjamin Redelings 84b8d257e4 Allow c++23 in gcc-11. 2023-10-09 23:53:31 +03:00
Xavier Claessens f1c35b561f pkgconfig: Set PKG_CONFIG in env for devenv and g-ir-scanner 2023-09-18 13:51:27 -04:00
Xavier Claessens 0eae4e0936 pkgconfig: Restore logging of pkg-config version
While at it, make more methods private by storing the version found on
the instance. That avoids having to call check_pkgconfig() as static
method from unittests.
2023-09-18 13:51:27 -04:00
Xavier Claessens 30d7f506c7 Remove get_pkgconfig_variable()
Make sure that pkgconfig_define is a pair of strings and not a list with
more than 2 strings.
2023-09-18 13:51:27 -04:00
Xavier Claessens 926c3a6919 Error when an installed static library links to internal custom target
When an installed static library A links to an internal static library B
built using a custom_target(), raise an error instead of a warning. This
is because to be usable, A needs to contain B which would require to
extract the archive to get its objects files.

This used to work, but was printing a warning and was installing a
broken static library, because we used to overlink in many cases, and
that got fixed in Meson 1.2.0. It now fails at link time with symbols
from the custom target not being defined. It's better to turn the
warning into a hard error at configure time.

While at it, noticed this situation can happen for any internal custom
or rust target we link to, recursively.
get_internal_static_libraries_recurse() could be called on CustomTarget
objects which do not implement it, and even if we did not call that
method, it would still fail when trying to call extract_all_objects() on
it.

Fixes: #12006
2023-08-07 05:44:08 -07:00
Xavier Claessens 183e4b8e90 PkgConfigDependency: Move CLI handling into its own abstraction
This makes the code cleaner and will allow to have other implementations
in the future.
2023-08-03 16:27:52 -04:00
Jussi Pakkanen 1cd16a7cc5
Merge pull request #11986 from williamspatrick/clang-enable-cpp23
add support for newer C++ -std= flags on Clang/GCC
2023-07-31 16:59:16 +03:00
Steven Noonan 51d04776a3 tests: add support for c++23/c++26 detection
Signed-off-by: Steven Noonan <steven@uplinklabs.net>
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
2023-07-14 13:29:16 -05:00
Tristan Partin 3784f72973 Silence some encoding warnings
By specifiying explicit encodings, we can silence warnings like:

 /__w/meson/meson/test cases/common/100 postconf with args/postconf.py:15: EncodingWarning: 'encoding' argument not specified
  with open(input_file) as f:

in CI.
2023-07-13 09:55:10 -07:00
Xavier Claessens 1fef03c0f0 build: dependencies should come after link_with on link command
This fixes regression caused by
3162b901ca
that changes the order in which libraries are put on the link command.

In addition, that commit was wrong because libraries from dependencies
were processed before process_compiler() is called, which that commit
wanted to avoid.
2023-07-10 23:12:24 +03:00
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
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
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
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
Jussi Pakkanen 78d8924d43 Condense test directories for rc1. 2023-03-28 17:18:57 +03:00
Eli Schwartz da23630a97
refactor pkg-config dependency to allow statically finding the program
The pkg-config dependency class has some interesting logic for finding a
good pkg-config that will be used for dependency lookups. We sometimes
need to use it, though, outside of the class. Make that possible.
2022-12-04 17:56:03 -05:00
Marvin Scholz 7cbc15b812 unittests: add and use get_meson_log_raw function
This is like get_meson_log but returns the whole contents
not split into individual lines.
2022-11-22 22:53:07 -05:00
Jussi Pakkanen 3ae89a7150 Handle freezing tests. Fixes #10752. 2022-11-21 16:44:24 +02:00
Eli Schwartz b40e4de3c6
tests: fix potential failure to verify pkg-config generation
We use a dummy project with a vague name and try to find flags for it
based on the installable pkg-config files. This sort of works,
generally, because it attempts to match `-lct` which doesn't exist
because the test case isn't installed, and that link argument is passed
directly through.

Except, sometimes that library does exist. It is provided by the
"freetds" project, which may be a dependency other tools. In that case,
Meson finds a library, and the `dependency()` resolves to
`/usr/lib/libct.so` and the test fails.

Fortunately, we do have an API to say that we really want to get back
the same flags pkg-config returned. Use this.
2022-11-17 19:10:51 -05: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
Jussi Pakkanen 458dcf8aac Condense test directory numbers. 2022-10-25 00:03:32 +03:00
Dylan Baker 1917b9253e modules/gnome: make_native_glib_version an instance var
This removes the need for the use of the global statement. I've also
updated the test that overrides this to use mock.patch instead of hand
monkey patching.
2022-09-22 18:17:43 -04:00
Eli Schwartz d3dac3cfb2
compilers: don't export every compiler as a top-level property
This is wasteful and generally unneeded, since code can just use the
compiler they detected instead of manually poking at the internals of
this subpackage.

It also avoids importing an absolute ton of code the instant one runs
`from . import compilers`
2022-09-19 15:19:00 -04:00
Yang Bo 83d18d137d Use os.path.realpath for default include paths testing in -isystem.
This ensures correct removal of default include paths in -isystem
options when symbolic links are involved.

A test for this is also added.
2022-09-13 02:24:38 -04:00
Eli Schwartz f8ebfdf7b1
install modes should not apply sticky bit to files
This is generally a bad idea, e.g. it causes OSError on freebsd.

It also gets ignored by solaris and thus causes unittest failures.

The proper solution is to simply reject any attempt to set this, and log a
warning.

The install_emptydir function does apply the mode as well, and since it
is a directory it actually does something. This is the only place where
we don't reset the mode.

Although install_subdir also installs directories, and in theory it
could set the mode as well, that would be a new feature. Also it doesn't
provide much granularity and has mixed semantics with files. Better to
let people use install_emptydir + install_subdir.

Fixes #5902
2022-08-23 21:07:00 -04:00