Commit Graph

1034 Commits

Author SHA1 Message Date
Olexa Bilaniuk 3410465178 Small patch to unittests to initialize CUDA compiler correctly.
Suggested by Dylan Baker.
2021-02-16 17:01:24 -05:00
Paolo Bonzini 3506d8daf2 mtest: TestSetup can have [] as an exe_wrapper
Fix "meson test --wrapper foo --setup bar", it should work just fine
if the setup does not define a wrapper.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2021-02-09 18:51:05 +01:00
Jussi Pakkanen d2c39e83ba Condense test directory names in preparation for rc1. 2021-02-09 00:30:20 +02:00
Jussi Pakkanen 71784e1002 Fix exe wrapper detection for run targets. 2021-02-08 23:19:41 +02:00
Luca Weiss 398df56298 Add Qt6 module 2021-02-07 22:43:00 +02:00
Peter Hutterer 3f8585676b Make installing non-existing subdirs a supported feature
install_subdir() with a non-existing subdir creates the directory in the
target directory. This seems like an implementation detail but is quite useful
to create new directories for e.g. configuration or plugins in the installed
locations.

git bisect says this started with 8fe8161014.
Let's add a test for it and document it to make this behavior official.

Limitation: it can only create at the install_dir location, trying to create
nested subdirectories does not work and indeed creates the wrong directory
structure. That is a bug that should be fixed separately:

        install_subdir('blah',
                        install_dir: get_option('prefix'))
        install_subdir('sub/foobar',
                        install_dir: get_option('prefix'))
        install_subdir('foo/baz',
                        install_dir: get_option('prefix'))

        $ tree ../_inst
        ../_inst
        ├── baz
        ├── blah
        └── foobar

Fixes #2904
2021-02-07 12:38:31 +00:00
Jussi Pakkanen 034b81a09f
Merge pull request #8288 from bonzini/test-setup-exclude-suites
introduce add_test_setup(exclude suites: ...) keyword argument
2021-02-07 12:03:10 +00:00
Jussi Pakkanen 8b82ffa9e4
Merge pull request #8305 from xclaesse/run-target-env
run_target: Add env kwarg
2021-02-07 11:46:41 +00:00
Dylan Baker 2650977c38 interpreterbase: Add support for optional arguments to typed_pos_args
This allows representing functions like assert(), which take optional
positional arguments, which are not variadic. More importnatly you can
represent a function like (* means optional, but possitional):
```txt
func(str, *int, *str)
```

typed_pos_args will check that all of your types are correct, and if not
provide None, which allow simplifying a number of implementation details
2021-02-06 13:11:25 -05:00
Dylan Baker 978eeddab8 interpreterbase: Add support for variadic arguments to typed_pos_args
This allows functions like `files()` to be decorated.
2021-02-06 13:11:25 -05:00
Dylan Baker 0ead2e10db interpreterbase: Add a helper method for typing positional arguments
We don't do a very good job of type checking in the interpreter,
sometimes we leave it to the mid layers of backends to do that (layering
violations) and sometimes we just don't check them at all. When we do
check them it's a ton of boilerplate and complicates the code. This
should help quite a bit.
2021-02-06 13:11:25 -05:00
Eli Schwartz ccd0cd3163 run_unittests: fix misc lint errors due to whitespace or unused imports/args 2021-02-05 16:33:23 -08:00
Eli Schwartz 67e99bb4ed run_unittests: fix undefined variable in error message
In commit fe973d9fc4, some uses of p got
rewritten to compiler.language, but not all. We'd still raise an error
message, but for the wrong thing. o_O
2021-02-05 16:33:23 -08:00
Eli Schwartz c3d516421f run_unittests: remove double definition of the same test case
In commit 591e6e94b9 we somehow ended up
with an identical extra copy.
2021-02-05 16:33:23 -08:00
Dylan Baker d7cbde4118 unittests: fix error message string 2021-02-05 16:31:33 -08:00
Xavier Claessens 522392e755 run_target: Add env kwarg
Re-implement it in backend using the same code path as for
custom_target(). This for example handle setting PATH on Windows when
command is an executable.
2021-02-05 17:53:09 -05:00
Xavier Claessens 95c0790711 minstall: Add --dry-run option
Closes: #1281
2021-02-04 16:24:38 +00:00
Dylan Baker 6f532b72c8 Add support for LLVM's thinLTO
This uses a separate option, b_lto_mode. It works in conjunction with
b_lto_threads.

Fixes #7493
2021-02-02 12:42:48 -08:00
Dylan Baker bffc94b08f compilers: Add support for using multiple threads with lto
Both Clang and GCC support using multiple threads for preforming link
time optimizaions, and they can now be configured using the
`-Db_lto_threads` option.

Fixes #7820
2021-02-02 12:42:48 -08:00
Paolo Bonzini c7c2bc8db1 interpreter, mtest: introduce add_test_setup(exclude_suites: ...)
This new keyword argument makes it possible to run specific
test setups only on a subset of the tests.  For example, to
mark some tests as slow and avoid running them by default:

    add_test_setup('quick', exclude_suites: ['slow'], is_default: true)
    add_test_setup('slow')

It will then be possible to run the slow tests with either
`meson test --setup slow` or `meson test --suite slow`.
2021-02-02 11:23:33 +01:00
Jussi Pakkanen f0fbb31ccf
Merge pull request #8200 from bonzini/mtest-asyncio-logs
mtest: improvements to logging
2021-01-30 09:52:43 +00:00
Jussi Pakkanen 3f0a0c1582 Can read project version from a file. 2021-01-29 16:42:59 +00:00
Xavier Claessens baa9eeebe4 dist: Allow packaging subproject in same git repo as main project 2021-01-26 21:32:03 -05:00
Paolo Bonzini 52a2f46af1 unittests: use utf-8 encoding for child processes
Ensure that unit tests will be able to parse UTF-8 output of "meson test".
2021-01-22 12:18:59 +01:00
Paolo Bonzini adb1b2f3f6 interpreter: accept external programs and dependencies for summary 2021-01-21 08:54:35 -05:00
Fini Jastrow 5dd1aac5c9 unittests: Remove double install for case 10
[why]
In test case 10 the project is installed twice. This has been introduced
with commit
  55abe16 unit tests: Test that relative install_rpath works correctly
where the cxx tests where added by copy and paste.

[how]
First test all build rpaths, then after install all install rpaths.

[note]
The aforementioned commit is a bit strange in that it adds a tests with
a relative rpath with cxx files but not with c files.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2021-01-20 19:01:47 +00:00
Fini Jastrow 49cde9653c ninjabackend: Correct RPATH order
[why]
If we build and test a library we need to make sure that we find the
currently build library object first, before an older system installed
one.
This can be broken if the library in question is installed in a custom
path, and another library we depend on also is installed there.

[how]
Just move the rpath to the current build artifacts to the front.

Solves #8030.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2021-01-20 19:00:25 +00:00
Jussi Pakkanen 8133a7b9a4 Keep buildtype the same even if user changes debug and/or optimization. 2021-01-19 20:25:55 +00:00
Jussi Pakkanen c64d407076 Fix cases where text leaks to stdout in unit tests. 2021-01-18 19:55:42 +00:00
Xavier Claessens 5db77fd103 coredata: Add missing nopromote wrap_mode choice 2021-01-14 18:29:28 +00:00
Antonin Décimo 39ede12aa5 Fix misspells
Signed-off-by: Antonin Décimo <antonin.decimo@gmail.com>
2021-01-13 12:53:10 -05:00
Eli Schwartz adfcf77109
summary: align left, not align middle
aligning along the left is, I think, what most projects want to do.
Aligning along the middle looks subjectively ugly, and objectively
prevents me from further indenting an element, e.g.

  Build information:
    prefix                : /usr
    sysconfdir            : /etc
        conf file         : /etc/myprogram.conf
2021-01-12 19:19:00 -05:00
Luke Elliott 9efcdba0d5 Allow '//' as project function id due to git bash path conversion.
See https://stackoverflow.com/questions/54258996/git-bash-string-parameter-with-at-start-is-being-expanded-to-a-file-path
2021-01-12 17:42:57 +00:00
Dylan Baker f3fcbba1f8 boost: default machine file properties to env var values
This both moves the env reading to configuration time, which is useful,
and also simplifies the implementation of the boost dependency. The
simplification comes from being able to delete basically duplicated code
since the values will be in the Properties if they exist at all.
2021-01-11 11:15:07 -08:00
Dylan Baker e7a5c75285 Move BinaryTable environment lookups to Environment
This means that all the env lookups are done once, at initial configure
time. This has all of the expected advantages.
2021-01-11 11:15:07 -08:00
Dylan Baker 38c7a7590c pull env to program mappings out of BinaryType class
These really aren't pivotal to that class, and they're used outside of
it. In a follow up patch they're not going to be used inside it at all.
2021-01-11 11:15:07 -08:00
Dylan Baker 4580433b82 rename cflags_mapping to CFLAGS_MAPPING
This is PEP8 convention for a const variable. Also, make the type
Mapping, which doesn't have mutation methods. This means mypy will warn
us if someone tries to change this.
2021-01-11 11:15:06 -08:00
Dylan Baker 9f343212e0 unittests: Clang on windows can use either ld or link.exe
it generally uses the ld style linkers with msys2 and link.exe style
linkers otherwise, but anything's possible.
2021-01-11 11:15:06 -08:00
Jussi Pakkanen a8c138ebc1
Merge pull request #8029 from bonzini/mtest-asyncio-next
mtest: asynchronous TAP parsing, improved progress report
2021-01-10 21:44:34 +00:00
Eli Schwartz c18a9715b8
Hotdoc: use template for Commands.md instead of generating the entire file (#8154)
* doc: fix hotdoc misuse for dynamically generated content

hotdoc has a native include feature for including files inline. Use this
to generate one file for each dynamically generated code block, and
include that file in Commands.md; see:
https://hotdoc.github.io/syntax-extensions.html#smart-file-inclusion-syntax

This permits us to move back to using the in-tree version of the hotdoc
*.md sources, thus fixing the incorrect inclusion of "builddir/" in the
"Edit on github" links which resulted from using copies as the source.

Fixes #8061

* doc: call the dummy file a "stamp" as it is a better known term
2021-01-10 14:48:34 +02:00
Paolo Bonzini e50861e62f mtest/TAPParser: use typing.NamedTuple
It is cleaner than collections.namedtuple.  It also catches that "count()" is
a method on tuple, so rename the field to num_tests.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2021-01-07 19:20:11 +01:00
Paolo Bonzini 304abaf9ee mtest: remove argument to the TAPParser constructor
Pass the StringIO object to the parse method instead, because
there will be no T.Iterator[str] to use in the asynchronous
case.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2021-01-06 08:44:22 +01:00
Dylan Baker e81acbd606 Use a single coredata dictionary for options
This patches takes the options work to it's logical conclusion: A single
flat dictionary of OptionKey: UserOptions. This allows us to simplify a
large number of cases, as we don't need to check if an option is in this
dict or that one (or any of 5 or 6, actually).
2021-01-04 12:20:58 -08:00
Dylan Baker 71db6b04a3 use OptionKey for builtin and base options
I would have prefered to do these seperatately, but they are combined in
some cases, so it was much easier to convert them together.

this eliminates the builtins_per_machine dict, as it's duplicated with
the OptionKey's machine parameter.
2021-01-04 12:20:40 -08:00
Dylan Baker f9b19e73a5 move OptionKey to mesonlib
There's starting to be a lot of things including coredata that coredata
needs to itself include. putting it in mesonlib makes more sense
2021-01-04 12:20:40 -08:00
Dylan Baker fe973d9fc4 use OptionKey for compiler_options 2021-01-04 12:20:39 -08:00
Dylan Baker e2ef6930ff use OptionKey for coredata.user_options 2021-01-04 12:15:41 -08:00
Dylan Baker b25a423a64 use the OptionKey type for command line and machine files 2021-01-04 12:15:41 -08:00
Dylan Baker fa9c1a7a72 run_unittests: Add fatal-warnings to test_command_line
Otherwise bugs like "option c_args is unknown" can slip through. that's
bad.
2021-01-04 12:15:41 -08:00
Dylan Baker 5db0d86b5c run_unittests: make another test inprocess safe 2021-01-04 12:15:41 -08:00
Dylan Baker 0574134bf8 run_unittests: Make test_command_line safe witn inprocess
This is pretty important to be able to debug the test, as it's huge and
really should be a test split into subtests.
2021-01-04 12:15:41 -08:00
Jussi Pakkanen 9f1ba40252
Merge pull request #8013 from mesonbuild/cppmodules
C++ module support
2020-12-14 15:00:04 +00:00
Oleg B b8052f9e50
Support native tests in crossbuild 2020-12-13 16:32:52 +02:00
Jussi Pakkanen 3df064484a Add unit test. 2020-12-13 14:03:22 +02:00
Dylan Baker b65168c558 unit tests: correctly skip c++20 checks if the compiler doesn't support
them

I can't find a supported version for AppleClang, and you need relatively
recent versions of GCC and Clang for -std=c++20 to work.
2020-12-11 17:46:11 +05:30
Jussi Pakkanen c21b04ba08 Add prelinking support for static libraries. 2020-12-03 22:58:07 +02:00
Jussi Pakkanen b53505a9dc
Merge pull request #7982 from dcbaker/submit/unittest-fixups
Unittest fixups
2020-11-24 00:02:22 +02:00
Dylan Baker f6672c7a19 use real pathlib module
We added the _pathlib module to work around defeciencies in python 3.5's
implementation, since we now rely on 3.6 lets drop this
2020-11-20 15:08:40 -08:00
Dylan Baker cef406b3a5 run_unittests: delete test for external syntax highlighting
It's a bit odd we have a test for an external project that's not even in
the meson organization. Regardless, the json file was recently replaced
by a cson file. There is an  coffee-script-notation parser in pypi,
but I couldn't get it to work. Just delete the test
2020-11-20 10:24:00 -08:00
Dylan Baker 460cb9af08 unittests: ignore nix rpaths
As a necessity nix adds a bunch of rpaths to files, this is unavoidable
do to the way nix package management works. Meson doesn't expect this
however, and fails all rpath tests. To correct this we just ignore any
rpath entries that start with `/nix`.
2020-11-18 14:44:07 -08:00
Dylan Baker 3e89c30bae unittests: Simplify and make test_templates more reliable
env.detect_<lang>_compiler only checks that there is a binary called
whatever that returns a version. There are several cases where the found
binary doesn't work:
 1) gcc for ojbc[pp], when support isn't compiled in.
 2) the compiler is broken (rust in appveyor somtimes)
Because of that we need to call compiler.sanity_check() as well, and if
we get an EnvironmentException from that skip the language

Also, instead of having a long line of try: ... except: pass, roll all
of the checking up into a loop using getattr(), which is less code and
makes adding a new language easier
2020-11-16 10:19:15 -08:00
Dylan Baker 85550e8fce run_unittests: correctly handle users setting init.defaultBranch 2020-11-16 10:19:15 -08:00
Dylan Baker 6431a0f89d run_unittests: Don't assume things are in /usr/bin
This is generally a safe assumption, except for some of the more exotic
OSes/distros like nixos, where env is the only thing in /usr/bin
2020-11-16 09:47:54 -08:00
Paolo Bonzini fc9b0cbb7f stabilize sets that are converted to lists
The order of elements in sets cannot be relied upon, because the hash
values are randomized by Python.  Whenever sets are converted to lists
we need to keep their order stable, or random changes in the command line
cause ninja to rebuild a lot of files unnecessarily.  To stabilize them,
use either sort or OrderedSet.  Sorting is not always applicable, but it
can be faster because it's done in C and it can produce slightly nicer
output.
2020-11-15 14:21:31 +01:00
Dylan Baker 6ce3812762 environment: Fix detection of rust compilers, more 2020-11-13 09:00:35 -08:00
Dylan Baker 5c74cccbb9 run_unittests: use textwrap.dedent
So that editors that can fold code (vim, vscode, etc) can correctly fold
functions, instead of getting confused by code that doesn't follow the
current indention. Also, it makes the code easier to read.
2020-11-13 09:00:35 -08:00
Jussi Pakkanen 41a79a0757
Merge pull request #7965 from dcbaker/wip/2020-11/macos-github-actions
Migrate osx CI from travis to github actions
2020-11-12 20:36:27 +02:00
Haelwenn (lanodan) Monnier d2aac3d809 dependencies: Put pkgconfig options before operands
This fixes building with meson when the POSIX behavior of getopt is used, such as when GNU libc is used with POSIXLY_CORRECT=1 defined
2020-11-12 20:27:40 +02:00
Dylan Baker 220da39c7c actions: Add unittests for macos 2020-11-11 07:42:40 -08:00
Dylan Baker 11ece5dbf3 unittests: Don't try to set alternative linkers for apple-clang 2020-11-10 14:24:35 -08:00
Jussi Pakkanen 9d1e747d17 Condense test directory names again. 2020-11-03 21:05:20 +02:00
Dylan Baker 47d071a34f interpreter: store correct files for project regeneration
Right now sub-sub projects are not correctly registered, because we
don't have a way to pass up past the first level of subproject. This
patch changes that by making the build_Def_files as defined in the
Interpreter initializer accurate for translated dependencies, ie, cmake
dependencies won't define a dependency on a non-existent meson.build.
This means that it can always add the subi.build_def_files because they
are always accurate.
2020-11-01 19:26:31 +02:00
Jussi Pakkanen 0f4f0acaff Remove a status message that leaks to stdout. 2020-10-19 00:04:38 +03:00
Jussi Pakkanen 64f8479097 In text, betterer grammer usings. 2020-10-19 00:04:14 +03:00
Jussi Pakkanen ac6041e110 Add delays to test for timestamp issues on mac. 2020-10-19 00:03:37 +03:00
Xavier Claessens 0c95d92404 pkgconfig: InternalDependency's ext_deps should be private by default
This fixes a regression introduced by
https://github.com/mesonbuild/meson/pull/7488.

InternalDependency's ext_deps previously where simply ignored, but that
PR has effect to add many more public Requires in generated pc files.
2020-10-17 15:53:46 +03:00
Xavier Claessens ed70c6df52 Subprojects should not inherit parent override
This was the behaviour in 0.55.0, so this test was assuming a behaviour
change. Revert it to the behaviour we had in 0.55.0.
2020-10-16 17:42:24 -04:00
Xavier Claessens 7271b1e942 Machine file pkg_config_path overrides environment
This is consistent with c_args in machine file overriding CFLAGS from
env. This also spotted an issue where in a native build this resulted
in pkg_config_path being /bar instead of /foo:
`-Dpkg_config_path=/foo -Dbuild.pkg_config_path=/bar`

Fixes: #7573
2020-10-16 17:42:24 -04:00
Xavier Claessens bcf369ea3c Fix consistency in variables kwarg
Share common code to extract the `variables` kwarg in
declare_dependency() and pkg.generate().
2020-10-16 18:09:56 +03:00
Daniel Mensinger 7c377e5a5d intro: Add extra_files key to intro output (fixes #7310) 2020-10-15 01:56:59 +03:00
Xavier Claessens 3a01823786 wrap: Add 'redirect' type and use it when auto promote 2020-10-13 17:55:16 -04:00
Xavier Claessens 6333ee88c1 Merge wraps from subprojects into wraps from main project
wraps from subprojects are now merged into the list of wraps from main
project, so they can be used to download dependencies of dependencies
instead of having to promote wraps manually. If multiple projects
provides the same wrap file, the first one to be configured wins.

This also fix usage of sub-subproject that don't have wrap files. We can
now configure B when its source tree is at
`subprojects/A/subprojects/B/`. This has the implication that we cannot
assume that subproject "foo" is at `self.subproject_dir / 'foo'` any
more.
2020-10-13 17:55:16 -04:00
Daniel Mensinger 7e58f33376
cmake: Add cross compilation support 2020-10-13 17:04:19 +02:00
Xavier Claessens dccff1f2bc msubprojects: Handle wrap-file to wrap-git case 2020-10-13 11:12:49 +00:00
Dylan Baker 94ac51fdda options: Handle updates to choices in options
Currently if you change the `choices` field in the meson_options.txt
file, no update will be done until `meson setup --wipe` is called. Now
if the choices change then the options will be properly merged.

If the currently select value is still valid it is guaranteed to be
kept, if it is now invalid the new default value will be used and a
warning will be printed.

Fixes #7386
2020-10-05 23:10:35 +03:00
Bernd Busse c4fa876925 Never run clang-format / clang-tidy against directories
`pathlib.Path.glob()` also returns directories that match source
filenames (i.e. a directory named `test.h/`), but `clang-format` and
`clang-tidy` fail when handed a directory. We manually skip calling
`clang-format` and `clang-tidy` on those directories.
2020-10-05 23:07:20 +03:00
Dylan Baker 4b1c1d83c8 machinefiles: Allow keys to be stored case insensitive
This is required to make the various keys in the [user options] section
work the same as they do in the meson_options.txt file, where we don't
have any rules about case sensitivity.

There is some risk here. Someone may be relying on this lower by default
behavior, and this could break their machine files.

Fixes #7731
2020-10-05 08:59:45 -04:00
Daniel Mensinger 1dfaccfd91 pathlib: Fix resolve() by overriding it in Python 3.5 2020-10-04 10:45:48 +02:00
Dylan Baker 135f5d5838 compilers: make get_optimization_args abstract 2020-10-01 15:06:10 -07:00
Dylan Baker bb3fe3c451 compilers/mixins/clike: fix mypy issues 2020-09-24 12:14:13 -07:00
Dylan Baker 79d1ecd5bc compilers/compilers: Fully type annotate 2020-09-24 12:14:13 -07:00
Xavier Claessens 17f07a53d0 msubprojects: Fix unit tests on Windows 2020-09-18 03:01:15 +00:00
Xavier Claessens da72e6284e msubprojects: Revert back to rev-parse instead of --show-current
It is undocumented in manpage, but --show-current is new in git 2.22
which is too recent for distros we want to support like Ubuntu 18.04.
2020-09-18 03:01:15 +00:00
Xavier Claessens e0cd54a322 msubprojects: Stop trying to guess subproject type
It was done to include them in `meson subprojects foreach` without
--types argument, but it's better to special case missing --types and
include wraps that have type=None too. It was a bad idea because that
was messing them in `meson subprojects update`, now they are ignored by
that command.
2020-09-18 03:01:15 +00:00
Xavier Claessens c203e2f92b msubprojects: Add basic unit tests 2020-09-18 03:01:15 +00:00
Dylan Baker e9fea0fecf unittests: mock os.environ before mucking with it 2020-09-17 11:26:50 +00:00
Dylan Baker 80ec7ec681 tests: Make monkey patching smarter
There are two problems here. The first is that we're doing manual monkey
patching which is fragile and verbose, when unittest.mock is designed
specifically to solve this exact problem. The second is that we're
monkey patching os.environ at two different levels with the same
information. So let's only do it once.
2020-09-17 11:26:50 +00:00
Dylan Baker 3526b36a77 linkers: fully type annotate and fix mypy issues
This makes GnuDynamicLinker not suitable for instantiation, so the tests
need to be changed to use the BFD class.
2020-09-16 20:28:56 -07:00
Xavier Claessens 67c0ec1640 InternalDependency: Add as_link_whole() method 2020-09-14 20:32:22 -04:00
Nirbheek Chauhan 1945f381b2 unit tests: Print total time taken for running tests 2020-09-11 23:27:15 +00:00
Nirbheek Chauhan c7adeac137 unit tests: Don't use pytest when running single tests
On my machine this spawns 24 processes and then runs like the single
test I asked it to run. With this change, running a single test goes
from 7 seconds to less than a second.
2020-09-11 23:27:15 +00:00
Jon Turney 88e13c5f7c Split tests out from 'common' which require a native compiler
Split out tests (and parts of tests) which require a native compiler
from the 'common' suite to a new suite called 'native', so we can
selectively avoid running those tests when only a cross-compiler is
available.

Also move test '211 cmake module' to 'cmake' suite, since it appears
that the way we use cmake requires a native compiler.
2020-09-10 07:20:41 +00:00
Jon Turney 461c14b8b7
Add a test of add_languages(native:) introspection
If the meson.build doesn't use a native compiler, the native compiler
options (e.g. 'c_args') shouldn't be present in the output of 'meson
introspect --buildoptions'.
2020-09-09 15:06:02 +01:00
Nirbheek Chauhan 757b838d81 Fix picking up tools with args from the env on Windows
This was a regression in https://github.com/mesonbuild/meson/pull/7059.
We do not need to do a full search for all windows special cases. We
only want to check whether the command provided is actually a full
path to a script so we can add the interpreter.

Fixes https://github.com/mesonbuild/meson/issues/7645
2020-09-08 14:38:59 +00:00
Paolo Bonzini fa5c2363eb introspect: add test dependencies info to test/benchmark JSON
Add the ids of any target that needs to be rebuilt before running the
tests as computed by the backend, to the introspection data for tests and benchmarks.
This also includes anything that appears on the test's command line.

Without this information, IDEs must update the entire build before running
any test.  They can now instead selectively build the test executable
itself and anything that is needed to run it.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2020-09-04 14:45:20 +02:00
Xavier Claessens 9365486104 Special case meson.version().version_compare() statement
when that statement gets evaluated, the interpreter remembers the
version target and if it was part of the evaluation of a `if` condition
then the target meson version is temporally overriden within that
if-block.

Fixes: #7590
2020-09-02 12:55:31 -04:00
James Hilliard e1f82a1199 unittests: continue on exception instead of break
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
2020-08-30 19:02:09 +03:00
Pierrick Bouvier 1900720353 D: fix include order
Commit 93c3ec7e introduced a new way to handle deduplication with
compiler args. This resulted in D includes to be reversed.
2020-08-30 18:56:24 +03:00
Daniel Mensinger 6fc067344d tests: make chdir more robust in run_unittests.py 2020-08-27 23:47:56 +03:00
Nirbheek Chauhan 6f74692ae0 Fix typo when fetching buildtype option for compiler checks
This type happened in https://github.com/mesonbuild/meson/pull/7432
and wasn't noticed because I didn't add a test for it. Rectified now.

If we don't specify the CRT, MSVC will pick /MT by default (!?) and
link to `libcmt.lib`. This actually *breaks* UWP because `libcmt.lib`
is not available by default when building for UWP.

Was noticed here: https://github.com/cisco/libsrtp/pull/505
2020-08-27 00:13:58 +00:00
makise-homura abc3b8e9cb Skip nostdlib test on non-x86(_64) platforms 2020-08-20 23:49:18 +03:00
Xavier Claessens 1c403e20e7 Interpreter: Fix c_stdlib usage
- Exceptions raised during subproject setup were ignored.
- Allow c_stdlib in native file, was already half supported.
- Eliminate usage of subproject variable name by overriding
  '<lang>_stdlib' dependency name.
2020-08-18 14:47:38 -04:00
Nirbheek Chauhan 9fdb97733b ninjabackend: Fix coverage rule generation
Without the parenthesis, the command evaluates to `[]` if
`use_llvm_cov` is `False`.

Also fix tests to actually check whether or not coverage reports are
generated.

Fixes https://github.com/mesonbuild/meson/issues/7553
2020-08-15 08:41:52 +00:00
Xavier Claessens 435db35962 interpreter: Don't force fallback when subproject failed to configure
Fixes: #7534
2020-08-12 13:38:55 +00:00
Paolo Bonzini 2c3ad37f24 Test for spurious warning from get_target_filename
Fixed by #7494 without a test, so here's a test.

Extracted from https://github.com/mesonbuild/meson/pull/7539
2020-08-12 12:02:39 +00:00
Zbigniew Jędrzejewski-Szmek 6006987ce5 "Downgrade" warning when regenerating after version bump
There is nothing to "warn" about, this is a completely routine
occurence. OTOH, when something is corrupted, we should warn. Keep
the red color and "WARNING:" prefix in that case.

Example output:
$ ninja -C build
Regenerating configuration from scratch: Build directory has been generated with Meson version 0.55.999, which is incompatible with current version 0.56.0.
The Meson build system
Version: 0.56.0
...
2020-08-04 17:15:37 +03:00
John Ericson 2447a1132a Capitalize some constants in coredata
I've been getting confused between them and similarly-named other
things, so I figured it was high time to clean this up.
2020-08-04 00:24:05 +03:00
Dylan Baker 4d2a17041f run dircondensor.py 2020-08-01 22:00:06 -07:00
Dylan Baker 591e6e94b9 Put machine file and cmd line parsing in Environment
This creates a full set of option in environment that mirror those in
coredata, this mirroring of the coredata structure is convenient because
lookups int env (such as when initializing compilers) becomes a straight
dict lookup, with no list iteration. It also means that all of the
command line and machine files are read and stored in the correct order
before they're ever accessed, simplifying the logic of using them.
2020-08-01 22:00:06 -07:00
Dylan Baker 601789cc7c machine-files: deprecate the paths section 2020-08-01 22:00:06 -07:00
Dylan Baker bbba6a7f36 Allow setting built-in options from cross/native files
This is like the project options, but for meson builtin options.

The only real differences here have to do with the differences between
meson builtin options and project options. Some meson options can be set
on a per-machine basis (build.pkg_config_path vs pkg_config_path) others
can be set on a per-subproject basis, but should inherit the parent
setting.
2020-08-01 22:00:06 -07:00
Dylan Baker a6164ca5a8 Allow setting project options from cross or native files
This allows adding a `[project options]` section to a cross or native file
that contains the options defined for a project in it's meson_option.txt
file.
2020-07-30 19:34:37 -07:00
Xavier Claessens 40c197d524 pkgconfig: Fix various corner cases
See unit tests for the exact scenarios this PR fixes.
2020-07-30 18:59:10 +03:00
James Hilliard 1ce4258c21 backends: fix rpath match pattern
Since -Wl,-rpath= is not the only valid rpath ldflags syntax we
need to try and match all valid rpath ldflags.

In addition we should prevent -Wl,--just-symbols from being used to
set rpath due to inconsistent compiler support.

Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
2020-07-30 16:36:11 +03:00
Marcel Hollerbach 903d5dd8a7 ninjabackend: check if target has compiler attribute
otherwise we are getting errors like:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/mesonbuild/mesonmain.py", line 131, in run
    return options.run_func(options)
  File "/usr/local/lib/python3.6/dist-packages/mesonbuild/msetup.py", line 245, in run
    app.generate()
  File "/usr/local/lib/python3.6/dist-packages/mesonbuild/msetup.py", line 159, in generate
    self._generate(env)
  File "/usr/local/lib/python3.6/dist-packages/mesonbuild/msetup.py", line 215, in _generate
    intr.backend.generate()
  File "/usr/local/lib/python3.6/dist-packages/mesonbuild/backend/ninjabackend.py", line 518, in generate
    self.generate_coverage_rules()
  File "/usr/local/lib/python3.6/dist-packages/mesonbuild/backend/ninjabackend.py", line 991, in generate_coverage_rules
    self.generate_coverage_command(e, [])
  File "/usr/local/lib/python3.6/dist-packages/mesonbuild/backend/ninjabackend.py", line 975, in generate_coverage_command
    for compiler in target.compilers.values():
AttributeError: 'RunTarget' object has no attribute 'compilers'

This extends the 109 generatecode test case to also define a test, so
coverage can really detect something.
2020-07-28 17:59:03 +03:00
Jussi Pakkanen 18aff92d7a
Merge pull request #7461 from mensinda/noMoreSetuptools
Remove the setuptools dependency with mesondata.py
2020-07-23 13:01:29 +03:00
Xavier Claessens 7f1e9b7492 summary: Wrap lines when printing lists
When a list_sep is provided (e.g. ', ') all items are printed on the
same line, which gets ugly on very long lists (e.g. list of plugins
enabled).
2020-07-21 07:30:37 +00:00
Jussi Pakkanen 804a71e8f2 Do not add rpaths for static libs. Closes #5191. 2020-07-20 14:14:49 +00:00
Daniel Mensinger 393d6e133d
mdata: Add test to ensure mesondata.py is up-to-date 2020-07-16 21:03:23 +02:00
Jussi Pakkanen fa929b4714 Check that hg is actually working. 2020-07-12 00:07:26 +03:00
Jussi Pakkanen a296ee44a1 Skip doc test when docs are not available. 2020-07-02 20:02:50 +03:00
Xavier Claessens 56c9e95b04 Implicit dependency fallback when a subproject wrap or dir exists 2020-07-01 09:45:33 -04:00
TheQwertiest b6981bd16e
Made Commands.md dynamically generated (#7346) 2020-06-30 23:56:08 +03:00
Xavier Claessens 4a371c97f4 wrap: Apply patch even in VCS cases 2020-06-30 19:42:43 +03:00
Xavier Claessens 1c8731a100 envconfig: Add [constants] section in machine files
Machine files already supports `+` operator as an implementation detail,
since it's using eval(). Now make it an officially supported feature and
add a way to define constants that are used while evaluating an entry
value.
2020-06-29 20:16:21 +03:00
TheQwertiest 5696a5abba Added ability to specify target in `meson compile` 2020-06-29 19:54:38 +03:00
TheQwertiest 4d0233540f Added ability to pass arguments to backend in `meson compile` 2020-06-28 18:13:49 -04:00
Xavier Claessens d0f468fef1 pkgconfig: Add missing cflags in uninstalled files
Fixes: #7365
2020-06-24 22:53:09 +03:00
Alan Coopersmith feef5a1c06 unittests: Fix 51 ldflagdedup on Solaris
If the linker doesn't support --export-dynamic, skip test to deduplicate
it, since it always fails finding 0 copies instead of 1.
2020-06-22 15:01:45 -07:00
Alan Coopersmith e06b04dc80 unittests: Fix test_compiler_detection on Solaris
Accept Solaris linker in addition to GNU linker.  Previously using the
system provided gcc (which calls the Solaris linker) caused it to fail with:

======================================================================
FAIL: test_compiler_detection (__main__.AllPlatformTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "run_unittests.py", line 2525, in test_compiler_detection
    self.assertIsInstance(cc.linker, mesonbuild.linkers.GnuLikeDynamicLinkerMixin)
AssertionError: <SolarisDynamicLinker: v9.2.0 `gcc`> is not an instance of <class 'mesonbuild.linkers.GnuLikeDynamicLinkerMixin'>

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2020-06-22 15:00:27 -07:00
Dylan Baker 93c3ec7e2d compilers: Return CompilerArgs from compiler instance
Since the CompileArgs class already needs to know about the compiler,
and we really need at least per-lanaguage if not per-compiler
CompilerArgs classes, let's get the CompilerArgs instance from the
compiler using a method.
2020-06-22 12:06:10 -07:00
Dylan Baker 9d0ad66c29 compilers: Split CompilerArgs into a separate module
I've also moved this out of the compilers pacakge because we're soon
going to need it in linkers, and that creates some serious spagetti
2020-06-22 12:06:10 -07:00
Cary Converse 8620ca2066 disable coverage tests on msys2 2020-06-17 23:08:51 -04:00
Cary Converse a198e5d191 coverage: llvm-cov support 2020-06-17 23:02:50 -04:00
Mathieu Duponchelle 20709af4d2 interpreter: add support for --force-fallback-for
This new command line option allows specifying dependencies for
which to force fallback.

See the documentation for more information

Fixes: #7218
2020-06-16 13:45:40 -04:00
Michael Hirsch 6f2eb6233c pep8: add missing import, remove unused variable 2020-06-15 23:33:40 +03:00
Michael Hirsch 1ec84c570f run_*tests*.py: print Meson version at start of test suite
on some systems, tests may take over an hour to run--only to find
you might have used an unintended Meson version (e.g. release instead
of dev). This change prints the Meson version at the start of the
run_*tests*.py scripts.

Also, raise SystemExit(main()) is preferred in general over
sys.exit(main())
2020-06-15 23:33:40 +03:00
Michael Hirsch 0b9e8e39dd environment: fallback regex for versions like 2020.01
add four-digit version unit_test cases
2020-06-15 10:06:34 -07:00
TheQwertiest 399303b534
Added docs for all meson commands + corresponding unit test (#7217) 2020-06-15 11:20:20 +05:30
Nirbheek Chauhan 63f1b5bb70 unit tests: Pass args to pytest
Gets --help working and --failfast too.
2020-06-11 07:10:43 +00:00