Commit Graph

1033 Commits

Author SHA1 Message Date
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
Marcel Hollerbach 18b99b3bc3 compilers: corretify deduplication direction
so: when building compile args, meson is deduplicating flags. When a
compiler argument is appended, a later appearance of a dedup'ed is going
to remove a earlier one. If the argument is prepended, the element
*before* the new one is going to be removed. And that is where the
problem reported in https://github.com/mesonbuild/meson/pull/7119 is
coming in. In the revision linked there, the order of replacement in the
prepend case was revesered.

With this patch, we restore this behaviour again.
2020-06-11 01:42:59 +03:00
Dan Kegel 25085483b9 run_unittests.py: skip test_internal_include_order for now if forcing response files on msys2
That test looks at the compdb very carefully, but
isn't yet set up to handle gcc responsefile quoting on windows, it seems.
2020-06-05 14:15:32 -07:00
Daniel Mensinger 210b57a136
ast: add unittest 2020-05-23 18:13:25 +02:00
Jussi Pakkanen 2b1ca518cf
Merge pull request #7123 from dcbaker/use-feature-deprecated
Use FeatureDeprecated (and other cleanups)
2020-05-22 17:08:44 +03:00
Jussi Pakkanen 589a6249f0
Merge pull request #5986 from dcbaker/fix-tests-with-cross-binary-arguments
Fix tests with cross binary arguments
2020-05-19 00:23:19 +03:00
Jussi Pakkanen b4b1a2c5a1 Build private directory name from output file name. 2020-05-19 00:22:45 +03:00
Dylan Baker af787874a8 pass exe_wrapper to test scripts through the environment
This adds a new MESON_EXE_WRAPPER environment variable containing the
string form of the exe_wrapper, if there is an exe_wrapper defined.

Fixes #4427
2020-05-18 13:53:58 -07:00
Dylan Baker 0ec94ca062 backends: Consider arguments passed to a test when cross compiling
Otherwise a wrapper script which takes an executable as an argument will
mistakenly run when that executable is cross compiled. This does not
wrap said executable in an exe_wrapper, just skip it.

Fixes #5982
2020-05-18 13:53:58 -07:00
Dylan Baker cb6662b572 backends: ensure that test executables can be run when passed as arguments
If an executable is passed as an argument to a script in the build
directory that it resides in then it will not execute (on *nix) due to a
lack of ./. Ie, `foo` must be called as `./foo`. If it is called from a
different directory it will work. Ie `../foo` or `bar/foo`.

Fixes #5984
2020-05-18 13:53:58 -07:00
Dylan Baker e822889754 tests: Add tests for cross file exe_wrapper
tests needs_exe wrapper but doesn't have one, !needs_exe_wrapper, and
needs_exe_wrapper and has one.
2020-05-18 13:53:58 -07:00
Dylan Baker 88f4bc6b55 run_unittests: move cross_file_system_paths to the cross tests 2020-05-18 13:53:58 -07:00
Jussi Pakkanen 751ea3df72
Merge pull request #7103 from dankegel/bug4027-rpath-remember
Let .pc files and LDFLAGS provide rpaths.
2020-05-18 23:17:34 +03:00
Dan Kegel f8cfb74e9b Let LDFLAGS specify rpath.
Fixes #2567
2020-05-16 20:26:03 +00:00
Dan Kegel d7235c5905 Let .pc files specify rpath.
Fixes #4027
2020-05-16 20:25:58 +00:00
Dylan Baker cb4e4f625f run_unittests: Use unittest.mock instead of a handrolled mock 2020-05-14 12:15:03 -07:00
Nirbheek Chauhan cb97c3baf8 unit tests: Fix broken test_cross_libdir test
test_cross_libdir() was broken because we were passing `--libdir=lib`
when invoking meson.

We didn't notice that https://github.com/mesonbuild/meson/issues/6115
broke because of this.
2020-05-14 15:38:44 +00:00
Eric Lemanissier ab6a410426 macos: Remove framwork linkerlike args
fixes-up 33fbc548ab
2020-05-13 15:55:07 +00:00
Jussi Pakkanen 4ea7c6ee12
Merge pull request #7064 from dcbaker/gtest-protocol
Add support for Gtest as a test protocol
2020-05-06 23:57:44 +03:00
Dylan Baker 083c5f6357 Add native support for gtest tests
Gtest can output junit results with a command line switch. We can parse
this to get more detailed results than the returncode, and put those in
our own Junit output. We basically just throw away the top level
'testsuites' object, then fixup the names of the tests, and shove that
into our junit.
2020-05-04 11:33:19 -07:00
Jussi Pakkanen d61f7a1e84 Add regression test for libdir reset. 2020-05-04 18:12:44 +03:00
GustavoLCR 27bbf37cf0
Fix incremental debug builds in VS 2020-05-04 02:21:20 +03:00
Dylan Baker fdd6022530 interpreter: Add link_language to all build targets
If the feature hadn't been broken in the first place it would have
worked on them anyway, so we might as well expose it. I'm loathe to do
it because one of the best features of meson in a mixed C/C++ code base
is that meson figures out the right linker every time, but there are
cases people have where they want to force a linker. We'll let them keep
the pieces.
2020-04-30 10:38:55 -07:00
Dylan Baker 650023f0cc unittests: Add test to show that link_language is broken 2020-04-30 10:38:55 -07:00
Dylan Baker 7b7f93a09f mtest: Generate a JUnit xml result file
JUnit is pretty ubiquitous, lots of services and results viewers
understand it, in particular gitlab and jenkins know how to consume
JUnit xml. This means projects using CI services can have their test
results consumed automatically.

Fixes: #6972
2020-04-23 13:26:01 -07:00
Jussi Pakkanen 84f28fc3f1
Merge pull request #6816 from dcbaker/framework-matrix
project test junit schema + a few more uses
2020-04-21 00:37:34 +03:00
John Ericson 278c294aa4 Compiler options per lang
A current rather untyped storage of options is one of the things that
contributes to the options code being so complex. This takes a small
step in synching down by storing the compiler options in dicts per
language.

Future work might be replacing the langauge strings with an enum, and
defaultdict with a custom struct, just like `PerMachine` and
`MachineChoice`.
2020-04-20 23:23:15 +03:00
Xavier Claessens f798207a9a interpreter: Correctly ignore def files in build directory
See https://gitlab.freedesktop.org/gstreamer/gst-build/-/issues/85.
2020-04-17 22:02:41 +00:00
Dylan Baker e0c9259e79 Add a json schema for the test.json used in tests
This does a couple of nice things, one is that editors like vscode can
be configured to use this schema to provide auto completion and error
highlighting if invalid values are added or required values are missing.
It also allows us test that the format of the test matrix work in a unit
test, which I've added. It does require that the python jsonschema
package is installed.
2020-04-17 10:49:09 -07:00
Xavier Claessens a6239d5100 wrap: Add fallback urls
It can happen that a server is temporaly down, tarballs often have
many mirrors available so we should be able to add at least one fallback
mirror in wrap files.
2020-04-13 13:29:33 +03:00
dabrain34 97a72a1c53
cmake: support cmake config file syntax (#6917)
* cmake: enhance support of cmake config file syntax

Enhance the cmakedefine support by accepting 2 or 3 tokens
in the conf line as mesondefine supports strictly 2 tokens

* fixup! cmake: enhance support of cmake config file syntax

* fixup! fixup! cmake: enhance support of cmake config file syntax
2020-04-10 11:14:54 -07:00
Jussi Pakkanen d20529784e Rename test dir names with dircondenser.py. 2020-04-05 22:51:47 +03:00
Cerbero df5113252b qt dependency: Pick debug libraries based on b_vscrt
`b_vscrt` has existed forever, and is the canonical source for
which CRT to link to, and hence whether to use the debug libraries
or not.
2020-04-05 13:39:41 +03:00
Jussi Pakkanen 7924e5f9c2 Revert "Naturally use env vars a bit more to match Autoconf"
This reverts commit 097dfc085e.
2020-03-23 18:07:24 +02:00
John Ericson 097dfc085e Naturally use env vars a bit more to match Autoconf
PR #6363 made it so our interpretation of env vars no longer clashed
with Autoconf's: if both Meson and Autoconf would read and env var, both
would do the same things with the value they read.

However, there were still cases that autoconf would read an env var when
meson wouldn't:

 - Autoconf would use `CC` in cross builds too

 - Autoconf would use `CC_FOR_BUILD` in native builds too.

There's no reason Meson can't also do this--if native cross files
overwrite rather than replace env vars, cross files can also overwrite
rather than replace env vars.

Because variables like `CC` are so ubiquitous, and because ignoring them
in cross builds just makes those builds liable to break (and things more
complicated in general), we bring Meson's behavior in line with
Autoconf's.
2020-03-23 17:51:36 +02:00
John Ericson 3a4388e51d Fix legacy env var support with cross
Fix #3969
2020-03-23 17:51:36 +02:00
John Ericson f6b0425576 Fix linker evn var tests
Just because we are on windows doesn't mean we can use `link`.

This ought to be done better, but this will do for now.
2020-03-23 17:14:00 +02:00
Jussi Pakkanen 1cf7799df2 Do not try to mix gcc with link.exe. 2020-03-22 22:48:47 +02:00
Dylan Baker 9074c7f8a4 envconfig: Make compiler and linker environment variables match 2020-03-17 10:40:39 -07:00
Dylan Baker 2ac480a0bd unittests: Add tests for overriding D linker language 2020-03-12 13:21:04 -07:00
Dylan Baker 0bb1e949e2 run_unittests: Use skip_if_not_language for linker tests
A couple used checks for specific compiler binaries, but those might not
be accurate for cross compiling. All the languages other than C and C++
(which we basically always assume we have) should have a
skip_if_not_lang check.
2020-03-12 13:21:04 -07:00
Nirbheek Chauhan 69e9d32bca coredata: Warn on usage of both -Dbuildtype and -Doptimization/-Ddebug
It may not be obvious to users that these two ways to set build-types
override each other and specifying both is redundant, and conflicts
are resolved based on whichever is specified later.

Closes https://github.com/mesonbuild/meson/issues/6742
2020-03-11 07:11:59 -04:00
Nirbheek Chauhan bd953b6b29 coredata: Passing an option is supposed to set it, not flip the default
With the current logic passing `--debug` will actually be parsed as
`-Ddebug=false`, which is absolutely not what is expected.

There is no case in which the presence of a boolean option in `--foo`
form will mean 'I want feature foo disabled', regardless of the
*default* value of that option.

Also includes a test.

Closes https://github.com/mesonbuild/meson/issues/4686
2020-03-11 07:11:59 -04:00
Nirbheek Chauhan c7aa4c8861 coredata: Set default options as cmdline args that override each other
The previous code was assuming that options do not depend on each
other, and that you can set defaults using `dict.setdefault()`. This
is not true for `buildtype` + `optimization`/`debug`, so we add
defaults + overrides in the right order and use the options parsing
code later to compute the values.

Includes a test.

Closes https://github.com/mesonbuild/meson/issues/6752
2020-03-11 07:11:59 -04:00
Jussi Pakkanen 3a57e5177b Fix introspection of symlink targets on macOS. 2020-03-09 00:39:13 +02:00
Jussi Pakkanen 44ff3e6c7d
Merge pull request #6736 from dcbaker/mesonlib-type-annotations
Mesonlib type annotations
2020-03-08 14:49:23 +02:00
Michael a16db4e918 update test_templates 2020-03-08 13:52:01 +02:00
Michael 5df106592c update test_templates to add dlang and find rust 2020-03-08 13:51:03 +02:00
Daniel Mensinger 4ce90bcb08 intro: List symlinks in installdata (fixes #6734) 2020-03-08 13:49:53 +02:00
Xavier Claessens d40c26e5fd override_dependency: Add failure tests 2020-03-06 15:26:02 -05:00
Xavier Claessens 943e9368f7 Simplify dependency() fallback
Now that subprojects can override the dependency name, there is no need
to provide a variable name for the fallback any more.
2020-03-06 15:26:02 -05:00
Xavier Claessens 2fdedc4d0f Add meson.override_dependency()
Similar to meson.override_find_program() but overrides the result of the
dependency() function.

Also ensure that dependency() always returns the same result when
looking for the same dependency, this fixes cases where parts of the
project could be using a system library and other parts use the library
provided by a subproject.
2020-03-06 15:25:46 -05:00
Dylan Baker 581d69a8d3 remove ability to pass multiple keys to extract_as_list
This makes the typing annotations basically impossible to get right, but
if we only have one key then it's easy. Fortunately python provides
comprehensions, so we don't even need the ability to pass multiple keys,
we can just [extract_as_list(kwargs, c) for c in ('a', 'b', 'c')] and
get the same result.
2020-03-05 09:58:52 -08:00
Dylan Baker a8293dd59c mesonlib: Replace unholder argument to listify
listify shouldn't be unholdering, it's a function to turn scalar values
into lists, or flatten lists. Having a separate function is clearer,
easier to understand, and can be run recursively if necessary.
2020-03-05 09:31:29 -08:00
Nirbheek Chauhan 7476961790 unit tests: Test the buildtype table in the docs 2020-03-05 00:37:57 +05:30
Nirbheek Chauhan 1cfa2c3aca unit tests: Rewrite documentation table parsing code
The old logic was completely broken, and didn't even assert that the
specified section was found at all. The CPU families test was broken
because of this. Luckily, the table didn't go out of sync with the
code.

It now also doesn't assume that each section has only one table. This
fixes the test now that we document the buildtype/optimization/debug
mapping in a second table inside the `Universal options` section.
2020-03-05 00:37:57 +05:30
Dylan Baker 1210a67f66 mesonbuild: Add mcompile command
This is tested working with both msbuild and ninja/samu. Since our xcode
support is pretty much broken I didn't bother.

Fixes #6670
2020-03-04 14:07:27 -05:00
Daniel Mensinger c48b0dea27
types: Annotate ast/interpreter.py 2020-03-02 10:34:55 +01:00
Jussi Pakkanen 200738a3e6
Merge pull request #6692 from xclaesse/summary-warnings
Summary improvements
2020-03-01 19:30:10 +02:00
Jon Turney a8cd01af42
Extend unit test to cover cwd-relative warning location formatting 2020-02-28 11:54:08 +00:00
Jon Turney 585bf2b867
Add unit test of cwd-relative error location formatting 2020-02-28 11:54:07 +00:00
Dylan Baker 2b6531a09b
Fix python2 rename (#6703)
* unittests: fix finding python2 if the binary is named python2

Because of the way the python module works the simplicity of the test
function is no longer valid, we need to have and additional name
parameter to make the python module work, as it doesn't look for an
entry called "python2" or "python3", only "python"

* unittests: Don't make our python 2.x check debian specific

* unittests: On macOS the python2 binary is still called python
2020-02-27 01:05:46 +02:00
Xavier Claessens 8101b0ddab summary: Add more info in Subprojects section
This adds a warnings counter for subprojects that passed. This is to
encourage developpers to check warnings in the logs and hopefully fix
them. Otherwise they could be hidden in hundreds lines of logs.

This also print the error message for subprojects that did not pass. The
error message is often enough to fix the issue (e.g. missing
dependency) and it's easier than searching in the logs why a subproject
failed.
2020-02-26 14:24:12 -05:00
Xavier Claessens c175e97a88 summary: Add list_sep keyword argument
This allows having lists on a single line instead of having each value
aligned on a new line.
2020-02-26 14:24:12 -05:00
Jussi Pakkanen 9c604320a0
Merge pull request #6637 from mesonbuild/nirbheek/implement-symbolextractor-windows
Implement symbolextractor on windows + some cleanups/fixes
2020-02-23 20:23:03 +02:00
Nirbheek Chauhan 04e89d0867 symbolextractor: Add support for Cygwin 2020-02-22 06:49:34 +05:30
Nirbheek Chauhan cace70c64e symbolextractor: Add a Windows implementation
Supports both MSVC and MinGW toolchains. Checks for MSVC first, then
falls back to MinGW.
2020-02-22 06:49:34 +05:30
Nirbheek Chauhan 3320e13d91 unit tests: Add a test for the symbolchecker script
When a source file for a library is changed without adding new extern
symbols, only that library should be rebuilt. Nothing that uses it
should be relinked.

Along the way, also remove trailing `.` in all Ninja rule
descriptions. It's very confusing to see messages like:

```
Linking target mylib.dll.
```

It's confusing that the period at the end of that is not part of the
filename. Instead of removing that period manually in the tests (which
feels wrong!) just don't print it at all.
2020-02-22 06:49:34 +05:30
Nirbheek Chauhan b0061257c9 unit tests: Add a test for reconfigure causing no-op build
meson setup && ninja && touch meson.build && ninja

should only reconfigure but not cause anything to be rebuilt.
2020-02-22 06:49:34 +05:30
Nirbheek Chauhan 225d842e4c unit tests: Make assertBuildNoOp check stricter
We also need to verify that no CustomBuild targets were rebuilt.
2020-02-22 06:49:34 +05:30
Nirbheek Chauhan 26615ac422 unit tests: Skip if pkg-config is not found
Of course, this does not skip on the CI, but helps on Windows.
2020-02-22 06:49:34 +05:30
Jussi Pakkanen 33fbc548ab
Merge pull request #6668 from mesonbuild/nirbheek/strip-more-unused-linkerlike-args
macOS: Remove more unused linkerlike args
2020-02-21 17:03:08 +02:00
Nirbheek Chauhan 36b4dec262 macOS: Remove more unused linkerlike args
`-L` and `-headerpad_max_install_names` are both linker arguments that
are commonly passed in CFLAGS too.

Closes https://github.com/mesonbuild/meson/issues/6294
2020-02-21 05:45:34 +05:30
Dylan Baker 48f3e72493 linkers: Update the linker names to be more consistent
This makes two basic changes, 1 it moves the name of the linker into the
linker class, this should reduce the number of errors and typos, and
ensure that a linker always has one name. This then renames the linkers
to have more consistent names.

Posix/gnu linkers are called ld.<name>: ld.gold, ld.lld, ld.solaris.

Apple linkers are renamed ld64.
2020-02-21 05:15:25 +05:30
Nirbheek Chauhan 090eaac918 unit tests: Remove an unused variable 2020-02-21 05:08:55 +05:30
Rohan Garg 73f03e6093 Introduce dataonly for the pkgconfig module
This allows users to disable writing out the inbuilt variables to
the pkg-config file as they might actualy not be required.

One reason to have this is for architecture-independent pkg-config
files in projects which also have architecture-dependent outputs.

For example : https://gitlab.freedesktop.org/wayland/weston/issues/269

Fixes #4011
2020-02-20 10:19:19 -05:00
Jussi Pakkanen 47759550e5 Add unity block size option. 2020-02-12 22:31:08 +02:00
Nirbheek Chauhan a41a902f5e unit tests: Ensure that --profile-self keeps working 2020-02-12 04:00:10 +05:30
Jussi Pakkanen dc8d241583
Merge pull request #6573 from michaelbadcrumble/add_sample_templates
Add new Meson sample templates
2020-02-05 19:45:59 +02:00
Xavier Claessens 4c5a9523be pkgconfig: Generate -uninstalled.pc files
Closes: #3472.
2020-02-05 16:54:01 +01:00
Jon Turney a3e2aa2d66
Fix prefix dependent option defaults (#6552)
* Extend test_prefix_dependent_defaults unit test to cover default case

Extend test_prefix_dependent_defaults unit test to cover the default
case, when the default prefix is '/usr/local'. (On Windows, the default
prefix is 'c:/')

* Restore adjusting option defaults depending on the default prefix

Restore adjusting option defaults, depending on the default prefix.
Droppped in d778a371
2020-02-04 23:27:59 +02:00
Michael b2b7fca320 update test_templates in run_unittests.py 2020-02-02 17:19:42 -08:00
Xavier Claessens 31f00c11d3 summary: Fix empty list case
Fixes: #6557.
2020-02-01 11:21:16 +01:00
Michael Hirsch, Ph.D 00f5dadd5b
Bugfix: sanitize_dir: use pathlib to handle case-insensitive filesystems (#6398) 2020-01-30 23:07:44 +02:00
Jussi Pakkanen 15ab30383e Skip ld tests if no compiler installed.
Fixes https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=950020
2020-01-29 09:16:36 -08:00
Dylan Baker 751f6fb90f run_unitests: Add a test for DependencyFactory ordering 2020-01-29 09:11:24 -08:00
Dylan Baker af4acc8e05 run_unittests: Add a chdir context manager
Because seriously
2020-01-29 09:11:24 -08:00
makise-homura 6300007396 Fix broken link on Elbrus Fortran compiler
Error is raised due to Elbrus Fortran compiler can't
generate debug information for now, because it's a 2-step
compiler where 1st step is code conversion from Fortran to C,
so debug information which C compiler would produce, is useless.
2020-01-27 22:35:26 +03:00
makise-homura 7ca53e40a3 ObjC/ObjC++ compilers are not available for Elbrus, so don't fail 2020-01-27 22:35:26 +03:00
Xavier Claessens b74ece344f Support multiple args to message() and warning() 2020-01-26 07:51:16 -05:00
Xavier Claessens f54f27b1a8 Fix required dependency() not failing when wrap-mode=nofallback
When a dependency is required, not found on the system, and its fallback
is disabled with --wrap-mode=nofallback, meson should abort instead of
returning not-found.
2020-01-25 08:51:46 -05:00
Nirbheek Chauhan 8be4802b0b unit tests: summary() test does not fail on Windows anymore 2020-01-24 02:53:34 +05:30
Nirbheek Chauhan e99e742454 summary: Ensure that output is deterministic
Use OrderedDict instead of dict() to ensure that the order is the same
every time, and change the unit test to check for that.
2020-01-24 02:53:34 +05:30
Nirbheek Chauhan 4d93a11427 unit tests: Open all documentation as utf-8
Fixes compatibility of unit tests with Python 3.5.2 on Ubuntu 16.04
2020-01-24 02:53:34 +05:30
Mike Gilbert b51ba60b80 test_pkgconfig_gen_deps: set PKG_CONFIG_SYSTEM_LIBRARY_PATH=/usr/lib
pkgconf automatically prunes "system library paths" from its output. The
system library paths depend on the system toolchain. A common value on a
64-bit system is as follows:

/lib64:/usr/lib64:/usr/local/lib64

So, if -L/usr/lib64 appears in the Libs section, it will be pruned from
the output of pkg-config --libs.

The pc files generated for this test contain something like this:

libdir=/usr/lib
Libs: -L${libdir} ...

pkgconf may not consider /usr/lib to be a system library path, so it is
not pruned as the test expects. To work around this, override the
compiled-in list of paths via the PKG_CONFIG_SYSTEM_LIBRARY_PATH
environment variable.

Fixes: https://github.com/mesonbuild/meson/issues/6004
2020-01-22 14:10:54 -08:00
Dylan Baker 255fa5a320 tests: Add a test case for finding ld 2020-01-22 23:39:33 +02:00
Dylan Baker 730a7b296f environment: Replace LD with <LANG>LD
The rust code is ugly, because rust is annoying. It doesn't invoke a
linker directly (unless that linker is link.exe or lld-link.exe),
instead it invokes the C compiler (gcc or clang usually) to do it's
linking. Meson doesn't have good abstractions for this, though we
probably should because some of the D compilers do the same thing.
Either that or we should just call the c compiler directly, like vala
does.

This changes the public interface for meson, which we don't do unless we
absolutely have to. In this case I think we need to do it. A fair number
of projects have already been using 'ld' in their cross/native files to
get the ld binary and call it directly in custom_targets or generators,
and we broke that. While we could hit this problem again names like
`c_ld` and `cpp_ld` are far less likely to cause collisions than `ld`.
Additionally this gives a way to set the linker on a per-compiler basis,
which is probably in itself very useful.

Fixes #6442
2020-01-22 23:39:33 +02:00
Stéphane Cerveau 958df63dac envconfig: add pkg_config_libdir property
In order to unify the use of sysroot in the cross-file,
the pkg_config_libdir can now be passed directly in the file.
2020-01-22 15:42:13 -05:00
Nirbheek Chauhan bd17c9ad4f tests: Add a unit test for checksums
Adds a CI dependency on the `pefile` python module.
2020-01-22 19:34:05 +05:30
Xavier Claessens 711969c3b5 wrap: Fix support of file:// URLs
Fixes: #6445
2020-01-17 11:36:37 -05:00
Nirbheek Chauhan 04e275cdcc find_program: Always use USERPROFILE instead of HOME
On MSYS2 and MSYS, Python reads HOME instead of USERPROFILE, which
gets the path wrong.

Serves me right for not writing a test!!
2020-01-15 01:45:14 +05:30
Eli Schwartz 71bbcc7669 pkgconfig module: add FeatureNew for requires: dependency('foo')
Introduced in https://github.com/mesonbuild/meson/pull/3131
2020-01-09 22:08:03 -05:00