Commit Graph

1033 Commits

Author SHA1 Message Date
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
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