Commit Graph

1031 Commits

Author SHA1 Message Date
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
Jussi Pakkanen c2b1e7d58c Rename test dirs to sequential order. 2020-01-08 13:21:00 +02:00
Ting-Wei Lan 04e08f5a1f PkgConfigDependency: Sort -L flags according to PKG_CONFIG_PATH
When there is more than one path in PKG_CONFIG_PATH. It is almost always
preferred to find things in the order specified by PKG_CONFIG_PATH
instead of assuming pkg-config returns flags in a meaningful order.

For example:

/usr/local/lib/libgtk-3.so.0
/usr/local/lib/pkgconfig/gtk+-3.0.pc
/usr/local/lib/libcanberra-gtk3.so
/usr/local/lib/pkgconfig/libcanberra-gtk3.pc
/home/mesonuser/.local/lib/libgtk-3.so.0
/home/mesonuser/.local/lib/pkgconfig/gtk+-3.0.pc

PKG_CONFIG_PATH="/home/mesonuser/.local/lib/pkgconfig:/usr/local/lib/pkgconfig"

libcanberra-gtk3 is a library which depends on gtk+-3.0. The dependency
is mentioned in the .pc file with 'Requires', so flags from gtk+-3.0 are
used in both dynamic and static linking.

Assume the user wants to compile an application which needs both
libcanberra-gtk3 and gtk+-3.0. The application depends on features added
in the latest version of gtk+-3.0, which can be found in the home
directory of the user but not in /usr/local. When meson asks pkg-config
for linker flags of libcanberra-gtk3, pkg-config picks
/usr/local/lib/pkgconfig/libcanberra-gtk3.pc and
/home/mesonuser/.local/lib/pkgconfig/gtk+-3.0.pc. Since these two
libraries come from different prefixes, there will be two -L arguments
in the output of pkg-config. If -L/usr/local/lib is put before
-L/home/mesonuser/.local/lib, meson will find both libraries in
/usr/local/lib instead of picking libgtk-3.so.0 from the home directory.

This can result in linking failure such as undefined references error
when meson decides to put linker arguments of libcanberra-gtk3 before
linker arguments of gtk+-3.0. When both /usr/local/lib/libgtk-3.so.0 and
/home/mesonuser/.local/lib/libgtk-3.so.0 are present on the command
line, the linker chooses the first one and ignores the second one. If
the application needs new symbols that are only available in the second
one, the linker will throw an error because of missing symbols.

To resolve the issue, we should reorder -L flags according to
PKG_CONFIG_PATH ourselves before using it to find the full path of
library files. This makes sure that we always follow the preferences of
users, without depending on the unreliable part of pkg-config output.

Fixes https://github.com/mesonbuild/meson/issues/4271.
2019-12-18 11:34:24 -05:00
Jussi Pakkanen 3122bac28a
Merge pull request #4649 from dcbaker/summary-function
Add a summary() function for configuration summarization
2019-12-18 01:17:27 +02:00
Dylan Baker 614372aa55 mlog: Add a log_once function
There are a number of cases where we end up spamming users with the same
message over and over again, which is really annoying. This solves that.
2019-12-13 09:57:05 -05:00
Xavier Claessens 38953d8ee3 summary: Add bool_yn keyword argument 2019-12-12 18:30:17 -05:00
Xavier Claessens 49082f9669 summary: Allow section with no title, and passing key/value separately 2019-12-12 18:30:17 -05:00
Xavier Claessens 6e865a2330 Add a summary() function for configuration summarization
Based on patch from Dylan Baker.

Fixes #757
2019-12-12 18:30:17 -05:00
Paolo Bonzini 3778a34979 mintro: include test protocol in introspection data 2019-12-13 00:47:10 +02:00
Jussi Pakkanen 17dd9e5bff
Merge pull request #6207 from dcbaker/linker-option
Add a way to select the dynamic linker meson uses
2019-12-11 23:29:33 +02:00
Daniel Mensinger fc800a2cb8 mintro: Add version key to --scan-dependencies (fixes #6287) 2019-12-10 20:17:21 +02:00
Xavier Claessens 1dda7cde39 run_unittests: Disable pytest with python <= 3.5
It's causing issues in some CI runners, it looks like it could be that
bug: https://github.com/pytest-dev/pytest-xdist/issues/204.
2019-12-10 18:02:41 +02:00
Xavier Claessens 552e78da4d assert(): Make message argument optional 2019-12-10 18:02:41 +02:00
Xavier Claessens 1298f71b1c dist: Add --include-subprojects option 2019-12-08 20:21:43 +02:00
Dylan Baker 875ef354d0 compilers: Rework the CompilerArgs to be less awful
There are two awful things about CompilerArgs, one is that it directly
inherits from list, and there are a lot of subtle gotcahs with
inheriting from builtin types. The second is that the class allows
arguments to be passed in whatever order. That's bad. This also fully
annotates the CompilerArgs class, so mypy can type check it for us.
2019-12-05 22:15:40 +02:00
Dylan Baker f8aa17d8e6 run_unittests: Add tests for LD on windows 2019-12-03 13:08:42 -08:00
Dylan Baker 75c1874bb3 run_unittests: Add unittests for ld overriding 2019-12-03 13:08:42 -08:00
Dylan Baker 8091b4c744 Intel: Dump worthless Xild abstractions
This dumps xild on mac and linux. After a lot of reading and banging my
head I've discovered we (meson) don't care about xild, xild is only
useful if your invoke ld directly (not through icc/icpc) and you want to
do ipo/lto/wpo. Instead just make icc report what it's actually doing,
invoking ld or ld64 (for linux and mac respectively) directly. This
allows us to get -fuse-ld working on linux.
2019-12-03 13:08:42 -08:00
Dylan Baker 71e3fac5af run_unittests: remove unused PatchModule class 2019-12-02 16:39:06 -08:00
Dylan Baker ef9aeb188e Allow selecting the dynamic linker
This uses the normal meson mechanisms, an LD environment variable or via
cross/native files.

Fixes: #6057
2019-12-02 16:39:06 -08:00
Michael Hirsch, Ph.D 83b4e981c4 Use strict function prototypes 2019-11-18 22:21:36 +02:00
Jussi Pakkanen bf800101c2
Merge pull request #6182 from mensinda/depInfo
Better dependency logs
2019-11-17 14:29:47 +02:00
Daniel Mensinger c361181cd9
mintro: dependencies: added version key 2019-11-14 18:16:47 +01:00
Paulo Neves 07389e23bc coredata: CmdLineFileParser no longer interpolates strings.
Previously if a user tried to pass a command line build
option that contained a '%' character the command line
parser assumed that there was string interpolation to be
done. As there is no sense in such a scenario no code
provides any input for the interpolation. This then leads to
a failure.

In this commit we specifically override the defaults in
ConfigParser and set interpolation to None, which disables
command line build option interpolation.

Fixes #6157
2019-11-13 22:04:15 +02:00
Jussi Pakkanen 2a73517e08 Revert "Add `-Wl,-rpath-link` for secondary dependencies"
This reverts commit 7b9c348102.

Closes #6027.
2019-11-13 17:46:34 +02:00
Marvin Scholz 273d6e75ea dependencies/pkgconfig: Fix error reporting
The stderr of pkg-config was never used, leading to no details about
failures at all in exception messages.
2019-11-07 17:50:00 +05:30
Wolfgang Stöggl f037e7ef45 Fix typos found by codespell
- Typos were found by codespell v1.16.0
2019-11-06 09:55:30 -05:00
Michael Hirsch, Ph.D bbe6db08e3 Minit templates modularization 2019-11-02 23:34:58 +02:00
Aleksey Gurtovoy 6eee9e48bb MSVC: support -LIBPATH
Fixes #6101 (with a test), following up #5881
2019-10-29 22:40:13 +02:00
Orlando Wingbrant 9ee9a1e1b2 Fix for issue #4499, multiple entries per file in install-log.txt 2019-10-23 22:37:45 +03:00
Jussi Pakkanen f96a8cbdf5 Test that running configure on a build dir works. 2019-10-22 22:32:34 +03:00
Daniel Mensinger 80ec5e9d28 Fix all flake8 warnings 2019-10-20 17:44:43 +03:00
Jussi Pakkanen 7bc7ff1433 Do not try to run dist test with VS backend. 2019-10-20 13:30:17 +03:00
Ross Burton a1a8772034 Add test case to verify identity cross builds
A build with a cross file should always be identified as a cross build, even if
the host and build machine are identical.  This was the case in 0.50, regressed
in 0.51, and is fixed again in 0.52, so add a test case to ensure it doesn't
regress again.
2019-10-15 23:46:35 +03:00
Jussi Pakkanen b6af3f3810
Merge pull request #5833 from dcbaker/remove-compiler-type
Remove compiler type
2019-10-09 19:53:56 +03:00
Jakub Adam 1bf1782476 Fix *.pdb files missing in meson introspect --installed output
On Windows, make sure the introspect command lists all Program database
(PDB) files containing debugging information that Meson will install.
2019-10-09 15:50:20 +02:00
Jan Beich 217036f2d9 Skip more tests if pkg-config is missing
meson.build:13:2: ERROR: Pkg-config binary for machine MachineChoice.HOST not found. Giving up.
2019-10-08 22:03:25 +03:00
Dylan Baker 0c22798b1a compilers: replace CompilerType with MachineInfo
Now that the linkers are split out of the compilers this enum is
only used to know what platform we're compiling for. Which is
what the MachineInfo class is for
2019-10-07 12:08:20 -07:00
Daniel Mensinger b1b8a7a7e3
Use -isystem instead of -idirafter 2019-10-03 10:06:04 +02:00
Jussi Pakkanen 48a5d17830
Merge pull request #5873 from mesonbuild/py2optional
Make Python 2 tests optional(er) to prepare for py2 purge in Debian.
2019-10-01 22:03:43 +03:00
Jussi Pakkanen d3b389f349 Add clang-tidy target. Closes #2383. 2019-10-01 22:02:51 +03:00
Jussi Pakkanen 5b422fce87 Make Python 2 tests optional(er) to prepare for py2 purge in Debian. 2019-10-01 21:12:04 +03:00
Xavier Claessens 058f89c2f2 Fix test_static_link() on MacOSX
test3-static was actually always using the shared library because that
warning was not fatal:
  WARNING: Static library 'func6' not found for dependency 'func6', may
  not be statically linked

The reason why the libfunc6.a wasn't found is because the prefix in the
generated pc file was not set to install dir.
2019-10-01 13:06:45 -04:00
Xavier Claessens dc5ad1fad9 pkgconfig: Do not include uninstalled static libraries 2019-10-01 13:06:45 -04:00
Xavier Claessens f396c71c52 Fix link_whole of static libraries 2019-10-01 13:06:45 -04:00
Marc-André Lureau 01569fee2e Add depfile to configure_file()
In qemu, minikconf generates a depfile that meson could use to
automatically reconfigure on dependency change.

Note: someone clever can perhaps find a way to express this with a
ninja rule & depfile=. I didn't manage, so I wrote a simple depfile
parser.
2019-09-30 22:17:50 +03:00
Aleksey Gurtovoy 7dbabdc7b6 Correctly handle platform-specific LDFLAGS options 2019-09-27 00:57:21 +03:00
Marc-André Lureau 6a12f3fc16 mtest: TAP: ignore empty lines
According to http://testanything.org/tap-specification.html

"Any output line that is not a version, a plan, a test line, a
diagnostic or a bail out is considered an “unknown” line. A TAP parser
is required to not consider an unknown line as an error but may
optionally choose to capture said line and hand it to the test
harness, which may have custom behavior attached [...] TAP::Harness
reports TAP syntax errors at the end of a test run".

(glib gtest can generate empty lines)
2019-09-23 13:28:11 -04:00
Xavier Claessens 5d0ced220c pkgconfig: Fix ordering of public libraries
The main library must come before extra libraries, because they are
likely to be dependencies of the main library that get promoted from
private to public. This was causing static link issues with glib-2.0.pc.
2019-09-17 11:56:46 -04:00
Daniel Mensinger 47bdea5040 mconf: Fix meson configure crash (fixes #5909) 2019-09-13 15:44:02 +03:00
Dylan Baker 3a011df4df unitests: dont assume cc exists or is valid
On illumos (and presumably Solaris, though I can't test) cc normally
points to Sun CC, which we don't support. So ensure that gcc is used
explicitly in that case.
2019-09-09 21:22:26 -07:00
David Seifert e19a49b895 Fix static archives stripping (#5905)
* Do not strip static archives

Stripping static archives without more fine-grained options (e.g. `-g`)
leads to failures such as

    ld: libfoo.a: error adding symbols: archive has no index; run ranlib to add one

because GNU strip removes *every* symbol in a static archive by default.
Given that static archives are not final build artifacts (unlike
executables and shared libraries), stripping them gains little and only
causes more edge case failures.

* Gentoo's portage only strips debug information:
  86f211e3a5/bin/estrip (L322)
* Fedora also only strips debug information:
  e9c13c6565/scripts/brp-strip-static-archive (L18)
* Debian also only does some very light stripping:
  72ed1d3261/dh_strip (L374)

Fixes #4138

* Add test case for static archive stripping
2019-09-08 19:48:57 -04:00
David Seifert c9042fc3ee Rename 'rpath-link secondary' unit test 2019-09-08 16:28:57 +03:00
David Seifert 7b9c348102 Add `-Wl,-rpath-link` for secondary dependencies 2019-09-06 22:16:16 +03:00
Aleksey Gurtovoy 75daed27bc mesonlib.split_args/quote_arg/join_args 2019-09-05 23:42:47 +03:00
Dylan Baker 0efab591da compilers: Move the compiler argument to proxy linker flags to the compiler class
Instead of the DynamicLinker returning a hardcoded value like
`-Wl,-foo`, it now is passed a value that could be '-Wl,', or could be
something '-Xlinker='

This makes a few things cleaner, and will make it possible to fix using
clang (not clang-cl) on windows, where it invokes either link.exe or
lld-link.exe instead of a gnu-ld compatible linker.
2019-08-30 00:01:32 +03:00
Jussi Pakkanen 3a04d325aa Fix packaging. [skip ci] 2019-08-26 20:23:35 +03:00
Dylan Baker 2bd85c614a unittests: Create a fake DynamicLinker when necessary 2019-08-14 13:13:23 -07:00
Dylan Baker 3fbb450166 environment: Detect dynamic linker class 2019-08-14 13:13:23 -07:00
Dylan Baker 9b3a1fabc5 unittests: add b_lundef=false to address sanitizer test
Clang doesn't really like having no-undefined plus the address sanitizer, but
gcc doesn't mind. This all happens to work with clang + gnu ld, but with clang
+ apple ld this turns into a dumpster fire. Just add b_lundef=false to make
everyone happy.
2019-08-14 13:13:22 -07:00
Dylan Baker a6ab28b199 run_unittests: extend binary wrapper creater for Wl,--version
which is needed by swift.
2019-08-14 13:13:22 -07:00
James Hilliard b21fd95f73 Add is_disabler function
This is useful if one needs to check if a variable is a disabler.

Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
2019-08-12 01:05:45 +03:00
Jussi Pakkanen 5fd4963766 Made build. options alias basic ones when native building. 2019-08-06 21:34:15 +03:00
Jussi Pakkanen 534c95cc3e Made set_option kwargs named-only. 2019-08-06 21:34:15 +03:00
Jussi Pakkanen f39600647d Condense test directory names. 2019-08-03 02:29:44 +03:00
Nirbheek Chauhan fcecedc10e unit tests: Convert unittest args to pytest
Allows people to run specific tests and/or enable verbose mode.
2019-07-26 11:56:39 +03:00
Jussi Pakkanen f2e018c7f3 Create multiple different archive types with dist. 2019-07-23 23:26:46 +03:00
Nirbheek Chauhan 4200afc74d unit tests: Check whether pytest-xdist is available
Also, always run pytest using the module format to ensure that we're
always using the Python interpreter selected by the user.

Fixes issue reported in https://github.com/mesonbuild/meson/pull/5621#issuecomment-513034198
2019-07-20 07:39:18 +00:00
Nirbheek Chauhan 81b6c9ef8c unit tests: Use a timeout for tests that use the network
It's better to quickly skip when the network is unavailable or slow.
2019-07-20 06:14:22 +00:00
Nirbheek Chauhan 43aae8243c unit tests: Test more syntax highlighting data
@TingPing has a repository that contains a grammar for meson which is
used by linguist (GitHub), and by many editors such as Atom, VS Code,
TextMate, Sublime Text, etc. Add CI so that we notice that the
function list in it is out of date, such as https://github.com/TingPing/language-meson/pull/3

It's harder to do this generically for other syntax such as the `in`
keyword, but it's better than nothing.
2019-07-18 23:44:45 +03:00
Daniel Mensinger 3b3f53ab55 mintro: Fix section key in buildoptions
This reverts the changes to the `section` key for the
buildoptions and moves the machine choice into it's
own `machine` key.

With this commit the __undocumented__ breaking change
to the introspection format (introduced in 0.51.0) is
reverted and a new key is added instead.
2019-07-17 19:20:33 +03:00
Dylan Baker 7803056ef2 run_unittests: use sys.executable on Windows for python
Instead of trying to guess whether we need py or python3, and then
falling over when whatever we guessed isn't in the path or isn't right,
just use sys.executable which should always work.
2019-07-15 10:59:22 -07:00
David Seifert cd12a6fc39 Add test to catch `-Werror=unused-parameter` brittleness 2019-07-14 15:12:16 +00:00
Nirbheek Chauhan 264533cb67 unit tests: Don't keep builddirs inside source tree on Cygwin
Seems to cause the umask tests to fail:
https://github.com/mesonbuild/meson/pull/5546#issuecomment-509666523
2019-07-12 21:49:48 +03:00
Michael Hirsch, Ph.D d5cb1c2f19
Merge pull request #5560 from scivision/cstd18_bug
add clang c_std=c18 alias and cleanup logic for compiler version unit tests
2019-07-11 19:23:05 -04:00
Jussi Pakkanen 19cda6b7c9
Merge pull request #5606 from xclaesse/alias_target
Add alias_target() function
2019-07-11 00:34:40 +03:00
Xavier Claessens 12d4031f52 Add alias_target() function 2019-07-10 15:01:18 -04:00
Jussi Pakkanen b1fbbde0b0 Use pytest parallelisation if available. 2019-07-09 22:38:30 +03:00
Nirbheek Chauhan 716140ddb4 unit tests: Fix CI failures in NativeFileTests
We can't rely on 'py' always being available in PATH, use
sys.executable which is the real path to Python 3.
2019-07-09 19:28:51 +05:30
Michael Hirsch, Ph.D 2dc11bcb53
typo 2019-07-08 22:33:34 -04:00
Michael Hirsch, Ph.D 763b05e074
cleanup clang version minimum 2019-07-08 22:28:25 -04:00
Michael Hirsch, Ph.D c756d06fbb
add clang c_std=c18 alias
fix unit test skips for clang c18

correct unittests clang minimum version

cleanup unittest clang skip c_std

finesse unittest vs. clang version
2019-07-08 22:27:35 -04:00
Jussi Pakkanen 380dcedb86 Hack envvar override when running tests in-process. 2019-07-08 22:57:04 +03:00
Jussi Pakkanen b9a771fef8 Use environment variable overrides. 2019-07-08 22:57:04 +03:00
Jussi Pakkanen 84ac5ce51e Convert some methods to use mandatory named kwargs. 2019-07-08 19:36:15 +03:00
Jussi Pakkanen 74611ecb1f Fix unittests. 2019-07-05 22:27:10 +03:00
Daniel Mensinger 54b1c43277 mintro: Add installed subdirs introspection (fixes #5556) 2019-07-01 11:28:54 -07:00
Aleksey Gurtovoy 7423247413 Fix failing test_find_program test (Windows-only)
Skip finding a .py script w/o extension on Windows if `.PY` isn't in
PATHEXT; closes #4355
2019-06-27 21:30:34 +03:00
Aleksey Gurtovoy 8ebe3d46bb Fix faling test_msvc_toolset_version test
VCToolsVersion is not always set, and MS docs  recommend getting the
info from a file
2019-06-27 20:44:29 +03:00
Dylan Baker 42bef8d418 run_unitests: Skip the native_file_is_pipe test on cygwin
Since it hangs and causes azure to time out.
2019-06-24 13:51:34 -07:00
Jussi Pakkanen 59e5ad66f2 Keep all build dirs inside the source tree.
VS and virus scanners complain when generating executables
in temporary directories.
2019-06-24 01:52:54 +03:00
Dylan Baker 56f7e5c74f coredata: Correctly handle receiving a pipe for native/cross files
* coredata: Correctly handle receiving a pipe for native/cross files

In some cases a cross/native file may be a pipe, such as when using bash
process replacement `meson --native-file
<([binaries]llvm-config='/opt/bin/llvm-config')`, for example. In this
case we copy the contents of the pipe into a file in the meson-private
directory so we can create a proper ninja dependency, and be able to
reload the file on --wipe/--reconfigure. This requires some extra
negotiation to preserve these native/cross files.

Fixes #5505

* run_unitests: Add a unit test for native files that are pipes

Using mkfifo.
2019-06-23 17:53:17 +03:00
Nirbheek Chauhan 9042130e9a compilers: Fix bitcode and other options for objc code
We were setting the base options for the Objective-C compiler
manually, due to which options such as b_bitcode and b_ndebug were not
getting set at all.

The base options here are the same as for C code with the Clang
compiler, so just use the same inherited list.

Also expand the bitcode test to ObjC and ObjC++ so this doesn't happen
again.
2019-06-23 16:50:24 +03:00
John Ericson 6d6af46edc Make test for identity
(cherry picked from commit ae6426cd8acfe0ccc5d7958d55edb613b4a5bf01)
2019-06-09 13:14:55 -04:00
John Ericson 07777e15d4 Purge `is_cross` and friends without changing user interfaces
In most cases instead pass `for_machine`, the name of the relevant
machines (what compilers target, what targets run on, etc). This allows
us to use the cross code path in the native case, deduplicating the
code.

As one can see, environment got bigger as more information is kept
structured there, while ninjabackend got a smaller. Overall a few amount
of lines were added, but the hope is what's added is a lot simpler than
what's removed.
2019-06-09 13:13:25 -04:00
Jussi Pakkanen 82e36a6bfe Add tests for std usage. Closes #5097.
(cherry picked from commit 27ae70dfaaff1298e68df70098acaa96f7ca748a)
2019-06-05 23:05:49 -04:00
John Ericson af2d7af998 Per machine do 'build.' and '' option prefixes
See the docs/ changes for details.
2019-06-05 23:05:34 -04:00
Dylan Baker 2e2c3c968c tests: Test the cmake parser more thuroughly
It turns out there are bugs, in particular with spaces in variables...
2019-05-29 11:25:27 -07:00
Dylan Baker 0714ba58c7 coredata: add cmake_prefix_path option 2019-05-27 01:24:08 +03:00
Christoph Reiter 7ce9e56a4b Fix path splitting in get_compiler_dirs() with GCC/clang on Windows
It was using ':' as a path separator while GCC uses ';' resulting in bogus
paths being returned. Instead assume that the compiler uses the platform native
separator.

The previous splitting code still worked sometimes because splitting
"C:/foo;C:/bar" resulted in the last part "/bar" being valid if "<DriveOfCWD>:/bar"
existed.

The fix also exposes a clang Windows bug where it uses the wrong separator:
https://reviews.llvm.org/D61121 . Use a regex to fix those first.

This resulted in linker errors when statically linking against a library which
had an external dependency linking against system libs.

Fixes #5386
2019-05-16 23:05:49 +03:00
Dylan Baker 61750494f5 run_unittests: make cross file location test robust against environment
Currently this test assumes that the user doesn't have XDG_DATA_HOME
set in their path, but this isn't a good assumption, and can result in
the test not actually testing what it means to.
2019-05-16 22:51:38 +03:00
John Ericson 957d8e051c Make `PerMachine` and `MachineChoice` have just `build` and `host`
Meson itself *almost* only cares about the build and host platforms. The
exception is it takes a `target_machine` in the cross file and exposes
it to the user; but it doesn't do anything else with it. It's therefore
overkill to put target in `PerMachine` and `MachineChoice`. Instead, we
make a `PerThreeMachine` only for the machine infos.

Additionally fix a few other things that were bugging me in the process:

 - Get rid of `MachineInfos` class. Since `envconfig.py` was created, it
   has no methods that couldn't just got on `PerMachine`

 - Make `default_missing` and `miss_defaulting` work functionally. That
   means we can just locally bind rather than bind as class vars the
   "unfrozen" configuration. This helps prevent bugs where one forgets
   to freeze a configuration.
2019-05-16 00:27:57 +03:00
Jussi Pakkanen 7b8ef78bc0
Merge pull request #5331 from dcbaker/icl
ICL (Intel for Windows) support
2019-05-14 00:24:48 +03:00
Dylan Baker 080f59cf43 compilers: rename IntelCompiler to IntelGnuLikeCompiler
The Intel compiler is strange. On Linux and macOS it's called ICC, and
it tries to mostly behave like gcc/clang. On Windows it's called ICL,
and tries to behave like MSVC. This makes the code that's used to
implement ICC support useless for supporting ICL, because their command
line interfaces are completely different.
2019-05-13 11:22:31 -07:00
Antoine Jacoutot e2f6f47fa3 unittests: adapt pkg-config test for OpenBSD
pkg-config(1) on OpenBSD is not the one from freedesktop.org and hence has
subtle differences (which don't impact real usage). The meson test fails
because white space between operators are stripped by our pkg-config:

$ grep Require /usr/local/lib/pkgconfig/xmlsec1.pc
Requires: libxml-2.0 >= 2.8.0 libxslt >= 1.0.20
$ pkg-config --print-requires xmlsec1
libxml-2.0>=2.8.0
libxslt>=1.0.20
2019-05-13 02:46:51 +03:00
Dylan Baker dcfd918548 run_unittests: assume that on windows that intel means icl
There actually is an ICC for windows that can be used to cross compile
from Windows to Linux, but it's not supported in meson currently and I
don't plan to enable it.
2019-05-10 13:51:24 -07:00
Dylan Baker 3e82a4b517 run_unittests: intel-cl links like msvc 2019-05-10 13:43:20 -07:00
Dylan Baker 73eca8255b run_unittests: Don't assume that VS like compilers have MSVC versions 2019-05-10 13:38:20 -07:00
Dylan Baker c72fd1e333 run_unittests: ICL also doesn't do proper resource dependency detection 2019-05-10 13:38:20 -07:00
Dylan Baker 541523eeba compilers: Split C-Like functionality into a mixin classes
Currently C++ inherits C, which can lead to diamond problems. By pulling
the code out into a standalone mixin class that the C, C++, ObjC, and
Objc++ compilers can inherit and override as necessary we remove one
source of diamonding. I've chosen to split this out into it's own file
as the CLikeCompiler class is over 1000 lines by itself. This also
breaks the VisualStudio derived classes inheriting from each other, to
avoid the same C -> CPP inheritance problems. This is all one giant
patch because there just isn't a clean way to separate this.

I've done the same for Fortran since it effectively inherits the
CCompiler (I say effectively because was it actually did was gross
beyond explanation), it's probably not correct, but it seems to work for
now. There really is a lot of layering violation going on in the
Compilers, and a really good scrubbing would do this code a lot of good.
2019-05-03 10:36:50 -07:00
Martin Hostettler ed109801c6 munstable_coredata: Adapt to coredata changes. 2019-05-02 23:55:53 +03:00
Jussi Pakkanen 1f4023fa47
Merge pull request #5311 from mensinda/flake8Plugins
Added flake8 plugins and some code fixes
2019-05-02 23:30:29 +03:00
Peter Hutterer 70997ca969 mtest: check for an empty suite list
For consistency, it can be useful to have an explicit empty test suite list
for a test:

   test('test-name', binary, suite: [])

This currently passes meson but fails when running meson tests:

Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/mesonbuild/mesonmain.py", line 122, in run
    return options.run_func(options)
  File "/usr/lib/python3.7/site-packages/mesonbuild/mtest.py", line 1005, in run
    return th.doit()
  File "/usr/lib/python3.7/site-packages/mesonbuild/mtest.py", line 756, in doit
    self.run_tests(tests)
  File "/usr/lib/python3.7/site-packages/mesonbuild/mtest.py", line 896, in run_tests
    visible_name = self.get_pretty_suite(test)
  File "/usr/lib/python3.7/site-packages/mesonbuild/mtest.py", line 875, in get_pretty_suite
    rv = TestHarness.split_suite_string(test.suite[0])[0]
IndexError: list index out of range

Fix it by simply checking for the test suite to be a valid list we can pass on

Fixes #5340

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-05-02 22:12:58 +03:00
Daniel Mensinger 236221061a
Fixed unnecessary .items() 2019-04-29 12:23:13 +02:00
Daniel Mensinger e75211d321
Fix builtin variable names 2019-04-29 12:17:40 +02:00
Daniel Mensinger bf98ffca9e
Fix blind exceptions 2019-04-29 12:16:06 +02:00
Dylan Baker 914b591692 run_unittets: extend version tests to cover other cases
Before this we only covered >, <, and ==, but we an apply some basic
logic to know that a > b == !(a <= b), or that if a > b then a != b.
This uncovered some bugs I wrote while working on this code.
2019-04-25 12:28:51 -07:00
Dylan Baker 397ac5921a run_unittests: rewrite version test to not call private methods
We really should be testing using the operators themselves, not the
internal implementations, ie we should use a > b not a.__cmp__(b) == 1
in our tests, because __cmp__ is just an implementation detail.
2019-04-25 12:28:51 -07:00
Dylan Baker add821db64 Don't use mutable types as default arguments
This isn't safe given the way python implements default arguments.
Basically python store a reference to the instance it was passed, and
then if that argument is not provided it uses the default. That means
that two calls to the same function get the same instance, if one of
them mutates that instance every subsequent call that gets the default
will receive the mutated instance. The idiom to this in python is to use
None and replace the None,

def in(value: str, container: Optional[List[str]]) -> boolean:
   return src in (container or [])

if there is no chance of mutation it's less code to use or and take
advantage of None being falsy. If you may want to mutate the value
passed in you need a ternary (this example is stupid):

def add(value: str, container: Optional[List[str]]) -> None:
    container = container if container is not None else []
    container.append(value)

I've used or everywhere I'm sure that the value will not be mutated by
the function and erred toward caution by using ternaries for the rest.
2019-04-23 02:03:19 +03:00
Dylan Baker 3edc7f343b coredata: store cross/native files in the same form they will be used (#5224)
* coredata: store cross/native files in the same form they will be used

Currently they're forced to absolute paths when they're stored in the
coredata datastructure, then when they're loaded we de-absolute path
them to check if they're in the system wide directories. This doesn't
work at all, since the ninja backend will generat a dependency on a
file that is in the source directory unless the path was already given
as absolute. This results in builds being retriggereed forever due to
a non-existant file.

The right way to do this is to figure out whether the file is in the
build directory, is absolute, or is in one of the system paths at
creation time, and store that path as absolute. Then the code that
reads the file and the code that generates the dependencies in the
ninja backend just takes the computed list and there is no mismatch
between them.

Fixes #5257

* run_unittests: Add a test for correct native file storage

This tests the bug in #5257
2019-04-21 23:10:02 +03:00
makise-homura 94b7ff3823 Correctly find lfortran for Elbrus compiler 2019-04-19 18:39:04 +03:00
Nirbheek Chauhan 2795f942be interpreter: Check the meson version before parsing options
Also add a test for it so we don't regress this in the future.

Closes https://github.com/mesonbuild/meson/issues/5281
2019-04-18 19:18:21 +00:00
Nirbheek Chauhan 2e93ed58c3 unit tests: Skip toolset version test on VS2015 and older 2019-04-18 09:01:23 +00:00
Nirbheek Chauhan 7654db511c vs: Update toolset table for VS 2019
Also add a test to ensure that we don't forget it in the future.
2019-04-18 09:01:23 +00:00
Paolo Bonzini 2942467148 add test case for generator dependencies 2019-04-16 01:46:31 +00:00
Nirbheek Chauhan 10468b3a28 interpreter: Warn when environment() ops are overriden
Warn when someone tries to use append() or prepend() on an env var
which already has an operation set on it. People seem to think that
multiple append/prepend operations stack, but they don't.

Closes https://github.com/mesonbuild/meson/issues/5087
2019-04-13 22:53:33 +03:00
TheQwertiest 2499e25476 Added a unit test for built-in options docs 2019-04-12 00:24:07 +03:00
Daniel Mensinger d72d98d3af mintro: removed deprecated --target-files API 2019-04-08 21:06:15 +03:00
Nirbheek Chauhan ef87d11dcd
Merge pull request #4931 from dcbaker/pkg-config-builtin
dependencies: Add command line option for pkg_config_path
2019-04-07 07:55:36 +00:00
Dylan Baker 91b2475e30 dependencies/pkg-config: Add support for different cross_flags 2019-04-05 15:08:17 -07:00
Dylan Baker 569e646e1e dependencies: Add command line option for pkg_config_path
This creates a new command line option to store pkg_config_path into,
and store the environment variable into that option. Currently this
works like the environment variable, for both cross and native targets.
2019-04-05 15:08:17 -07:00
Antoine Jacoutot d4cece3b34 test_pkgconfig_formatting: OpenBSD, libintil is a separate library 2019-04-03 08:54:06 -07:00
Daniel Mensinger 1937bbafac
mintro: Fix crash when required is a function (closes #5177) 2019-04-02 11:21:05 +02:00
Jussi Pakkanen 75219989ca
Merge pull request #5128 from Ericson2314/sanity-check-with-flags
Sanity check with external args
2019-04-02 00:40:05 +03:00
Jussi Pakkanen e3e83e2acd Also format headers with Clang-Format. Closes #5184. 2019-04-01 01:26:53 +03:00
John Ericson 507b1dc40e Fix test_compiler_*_stds tests after last commit
Since sanity check now includes CFLAGS, the test fails earlier.

But if the compiler is ICC, it will only fail during the build proper as
before, since that's where where the flag making `-std=unknown` an error
not warning is used.
2019-03-27 10:54:56 -04:00
John Ericson d361da991b Change test to reflect new semantics 2019-03-27 14:45:42 +00:00
Jussi Pakkanen f46b485fc2
Merge pull request #5083 from rossburton/crossfiles
Support multiple --cross-file options
2019-03-20 18:46:32 +02:00
Dylan Baker ac627bcea7 replace library type strings with an enum
This patch creates an enum for selecting libtype as static, shared,
prefer-static, or prefer-shared. This also renames 'static-shared'
with 'prefer_static' and 'shared-static' with 'prefer_shared'. This is
just a refactor with no behavioral changes or user facing changes.
2019-03-20 18:45:56 +02:00
Ross Burton a87b51f75c Add test case for multiple cross files 2019-03-20 10:06:17 +00:00
Ross Burton 1a2b5d3b53 run_unittest: update for cross_file being a list 2019-03-20 10:06:17 +00:00
Nirbheek Chauhan 07818dac6a compilers: Try harder to dedup builtin libs
Compiler internal libs should always be de-duplicated, no matter what.

Closes https://github.com/mesonbuild/meson/issues/2150

Test case is by Bruce Richardson in the issue.
2019-03-14 12:21:05 +00:00
Antoine Jacoutot 5d3e20984d compilers: -fsanitize is not supported on OpenBSD (second pass)
Similar to https://github.com/mesonbuild/meson/pull/5067
This part was missed in my previous commit.
2019-03-13 08:57:46 +00:00
Antoine Jacoutot f7af1a6285 compilers: -fsanitize is not supported on OpenBSD
OpenBSD doesn't have any support for the compiler sanitizers yet.
While this may change in the future, better fix test suite run in "failfast"
mode for now. This can be revisited once (if) we get support in the future.

* clang 7.0.1
$ make CFLAGS=-fsanitize=address foo
cc -fsanitize=address   -o foo foo.c
cc: error: unsupported option '-fsanitize=address' for target 'amd64-unknown-openbsd6.5'

* gcc 4.2.1
*** Error 1 in /tmp (<sys.mk>:85 'foo')
$ make CC=gcc CFLAGS=-fsanitize=address foo
gcc -fsanitize=address   -o foo foo.c
cc1: error: unrecognized command line option "-fsanitize=address"

* gcc 8.2.0
$ make CC=egcc CFLAGS=-fsanitize=address foo
egcc -fsanitize=address   -o foo foo.c
ld: error: unable to find library -lasan
collect2: error: ld returned 1 exit status
2019-03-13 06:35:58 +00:00
John Ericson 9409155d5a Avoid module patching in `test_find_library_patterns`
This is less hacky, and also prepares the way for #4010.
2019-03-12 04:03:47 +00:00
Niklas Claesson dd2c44cdf6 Add static as keyword to find_library 2019-03-11 20:56:52 +02:00
Ignacio Casal Quinteiro c6f84a223c Add unit test for pkgconfig relative paths 2019-03-11 17:38:22 +00:00
Antoine Jacoutot c1c699eda4 Fix unit test: test_find_library_patterns 2019-03-11 06:02:17 +00:00
Jussi Pakkanen 7589471978 Condense directory numbering for release. 2019-03-10 18:39:03 +02:00
Daniel Mensinger 91918262e7
rewriter: Fixed unit tests 2019-03-04 13:14:48 +01:00
Daniel Mensinger 594bf678c7
rewriter: Require '/' for the project ID 2019-03-04 13:00:30 +01:00
Daniel Mensinger 609a21ff9f
rewriter: Abort on error by default 2019-03-04 13:00:30 +01:00
Daniel Mensinger 5d2f14fce7
rewriter: Quiet logging by default 2019-03-04 13:00:30 +01:00
Daniel Mensinger e724fd5438
rewriter: Handle duplicate target 2019-03-04 13:00:29 +01:00
Daniel Mensinger b55dbf0fae
rewriter: Dump JSON to stderr instead of stdout 2019-03-04 13:00:07 +01:00
Daniel Mensinger 740f6b8f06
rewriter: Implemented a CLI 2019-03-04 13:00:05 +01:00
Daniel Mensinger 2582f311b0
rewriter: Make sure target sources are relative 2019-03-04 13:00:05 +01:00
Daniel Mensinger 760d1bff9c rewriter: Sort source files (#5010)
* rewriter: Sort source files

* rewriter: Natural sorting

* rewriter: Fix flake8

* rewriter: Fixed sorting

* rewriter: Make sorting key more readable

* rewriter: Even simpler key
2019-03-04 13:58:35 +02:00
Daniel Mensinger 7074f12644
mintro: Renamed --dependencies --> --scan-dependencies 2019-03-03 23:19:04 +01:00
Daniel Mensinger 9e659b3130
Added test cases 2019-03-03 23:19:03 +01:00
Daniel Mensinger bd5d54513c rewriter: Handle Arithmetic node 2019-03-03 20:25:07 +02:00
Paolo Bonzini 91f847d308 mtest: implement TAP parsing
This provides an initial support for parsing TAP output.  It detects failures
and skipped tests without relying on exit code, as well as early termination
of the test due to an error or a crash.

For now, subtests are not recorded in the TestRun object.  However, because the
TAP output goes on stdout, it is printed by --print-errorlogs when a test does
not behave as expected.  Handling subtests as TestRuns, and serializing them
to JSON, can be added later.

The parser was written specifically for Meson, and comes with its own
test suite.

Fixes #2923.
2019-03-02 09:07:54 +01:00
Daniel Schulte f0b0bcf86d mintro: Add subproject_dir to --projectinfo 2019-03-01 23:40:33 +02:00
Daniel Schulte 924cf5e622 mintro: Add name of subproject the target is contained in to --target output 2019-03-01 22:29:52 +02:00
Jussi Pakkanen 97555cf6d9
Merge pull request #4939 from mensinda/rwDefOpts
rewriter: Set and delete project default options
2019-02-26 22:34:33 +02:00
John Ericson 9cf0f31ec0 unit tests: Use unittest.skipUnless to simplify main()
This makes the testsuite work better with other test runners, like
pytest. This is important because better test runners are very useful to
development (e.g. avoiding running succeeding tests again and again),
even if we want to still support 0 dependency testing of Meson though
keeping the default test runnner working.
2019-02-26 15:42:17 +00:00
Daniel Mensinger 16b6b2d411
Use c++14 instead of c++17 in the tests 2019-02-26 09:34:58 +01:00
Daniel Mensinger 9e247cb52e
rewriter: Set and delete default options 2019-02-26 09:34:58 +01:00
Daniel Mensinger 74bb79e26e
rewriter: Remove matching regex from list 2019-02-26 09:34:57 +01:00
Jussi Pakkanen 5d751a2506 Pick target exactly rather than relying on dict order. 2019-02-26 01:26:54 +02:00
Raphael Salamon c23ac0b3dc Allow custom targets with same name in project and subprojects
closes #4377
2019-02-19 19:41:57 +02:00
Jussi Pakkanen 6e15bcc504
Merge pull request #4929 from mensinda/rwAddRmTgt
rewriter: Add and remove targets
2019-02-19 00:08:58 +02:00
jml1795 a9e63568fe Add warning level zero 2019-02-19 00:06:27 +02:00
Daniel Mensinger 5184465280
rewriter: Added support for adding targets 2019-02-16 14:17:01 +01:00
Daniel Mensinger 056c533ede
rewriter: Added support for removing targets 2019-02-16 14:14:16 +01:00
Jussi Pakkanen 939b011114
Merge pull request #4858 from mensinda/rwKWARGS
rewriter: Add support for kwargs modification
2019-02-16 14:17:49 +02:00
Dylan Baker b5d847e38c allow paths to be set in the cross file
Just like the previous patch, but for cross files

Fixes #1433
2019-02-11 12:50:32 -08:00
Dylan Baker 5b896ed70b allow setting directory locations in a native file
This allows the person running configure (either a developer, user, or
distro maintainer) to keep a configuration of where various kinds of
files should end up.
2019-02-11 12:50:32 -08:00
Jussi Pakkanen 902aaf2ce6
Merge pull request #4626 from Ericson2314/consolidate-properties
Go through coreutils.compiler_options.{build.host.target}
2019-02-04 23:06:46 +01:00
Daniel Mensinger 69cb314718 Fix introspection test case for solaris (fixes #4866) 2019-02-04 20:25:03 +01:00
John Ericson 19f81d3e33 Never access environment.properties downstream
Instead use coredata.compiler_options.<machine>. This brings the cross
and native code paths closer together, since both now use that.

Command line options are interpreted just as before, for backwards
compatibility. This does introduce some funny conditionals. In the
future, I'd like to change the interpretation of command line options so

 - The logic is cross-agnostic, i.e. there are no conditions affected by
   `is_cross_build()`.

 - Compiler args for both the build and host machines can always be
   controlled by the command line.

 - Compiler args for both machines can always be controlled separately.
2019-02-02 13:59:14 -05:00
Daniel Mensinger da7b9df16c Ensure that func dicts provide the same set of functions 2019-02-01 11:49:52 +00:00
Nirbheek Chauhan 50b863032e find_library: Check arch of libraries on Darwin
macOS provides the tool `lipo` to check the archs supported by an
object (executable, static library, dylib, etc). This is especially
useful for fat archives, but it also helps with thin archives.

Without this, the linker will fail to link to the library we mistakenly
'found' like so:

ld: warning: ignoring file /path/to/libfoo.a, missing required architecture armv7 in file /path/to/libfoo.a
2019-01-31 20:36:49 +00:00
Nirbheek Chauhan c0166355ce Rewrite appleframework and extraframework dependency classes
Instead of only doing a naive filesystem search, also run the linker
so that it can tell us whether the -F path specified actually contains
the framework we're looking for.

Unfortunately, `extraframework` searching is still not 100% correct in
the case when since we want to search in either /Library/Frameworks or
in /System/Library/Frameworks but not in both. The -Z flag disables
searching in those prefixes and would in theory allow this, but then
you cannot force the linker to look in those by manually adding -F
args, so that doesn't work.
2019-02-01 00:14:09 +05:30
Daniel Mensinger 8c364952af
Added dependecy kwargs support 2019-01-31 15:57:02 +01:00
Daniel Mensinger 5655865246
Added test case 2019-01-31 15:43:04 +01:00
Daniel Mensinger 8bb942ef25
Rewriter infodump modifications 2019-01-31 15:43:04 +01:00
Daniel Mensinger 8224ecfbe6
Some fixes and assignment based target find 2019-01-31 15:43:04 +01:00
Nirbheek Chauhan 00b59c9ad6 pkg-config: Fix another case where we were throwing a traceback
Also add a test for it. In the process, also remove an overly-zealous
try..except statement that was catching *all* exceptions, not just
expected ones, which was masking programming errors.
2019-01-31 20:12:21 +05:30
Nirbheek Chauhan 4268e156a3 unit tests: darwin tests must never require pkg-config 2019-01-31 20:12:21 +05:30
Nirbheek Chauhan 3997e8762e unit tests: Fix sdl2 failure test on macOS
Also ensure that the test's no-pkg-config codepath will always be run,
even on the CI where we always have pkg-config available.

This counts as a test case for #4728
2019-01-31 20:12:21 +05:30
Nirbheek Chauhan 58852e6290 unit tests: Simplify get_fake_env()
Almost every test already uses '' for the srcdir/builddir/etc.
Make it official.
2019-01-31 20:12:21 +05:30
Nirbheek Chauhan 36779c0500 unit tests: Run native file tests on the CI
The native file tests were never run on the CI since they were skipped
on Windows and also skipped on Linux and macOS since CC/CXX/etc are
always set by the CI.

Also fix test failure on macOS. The test was assuming that because
/usr/bin/gcc and /usr/bin/clang exist on macOS, they must be different
compilers. They're not. gcc is just a wrapper around clang, and we
correctly detect it as such.
2019-01-30 23:21:59 +02:00
Michael Hirsch, Ph.D da34bea893 pep8 py37 2019-01-29 22:06:11 +02:00
Michael Hirsch, Ph.D 8636f31d9c BUGFIX: broken/missing Fortran code/unit tests 2019-01-27 20:57:21 +02:00
Jussi Pakkanen 733f9a7765
Merge pull request #4814 from mensinda/astVisitor
rewriter: Rewrote the meson rewriter - now works with AST modification
2019-01-27 20:46:29 +02:00
Christoph Reiter 8df5afc98a configure_file: preserve newlines of the input file. Fixes #4817
In some cases (see #4817) it's helpful if the output file uses the
same newlines as the input file without translating them to the
platform defaults.

open() by default recognizes all newline styles and translates them
to "\n" and then to the platform default when writing.
Passing "" to "newline" disables the translation and lets us pass through
the original newline characters.
2019-01-24 21:02:34 +02:00
Nirbheek Chauhan d02ec7111e coredata: Only reject a load if major version differs
Our builddir ABI is stable across minor (stable) releases, so there is
no need to force a wipe. We already release pretty often, no need to
force people to wipe twice as often.
2019-01-23 19:50:50 +05:30
Daniel Mensinger 4b3e21b894
Fixed test case and setup.py 2019-01-22 17:47:51 +01:00
Daniel Mensinger 6fe2c2b209
Fixed flake8 issues 2019-01-22 17:31:15 +01:00
Daniel Mensinger 027c3c9ac7
Added subdir test 2019-01-22 17:04:43 +01:00
Daniel Mensinger b7c6f3ec72
Can now rewrite files 2019-01-22 16:41:25 +01:00
Daniel Mensinger 8dd9b44831
Added support for removing sources from a target 2019-01-22 16:41:25 +01:00