Commit Graph

698 Commits

Author SHA1 Message Date
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
Paolo Bonzini 4b5cf3f7c5 interpreter: add "protocol" kwarg to test
This is the first step towards adding support for TAP.
2019-03-02 09:07:54 +01:00
John Ericson 2622e9ec32 Move some configuration classes out of environment.py
First of all, I'd like compilers and other modules that environment.py
currently imports to be able to take these without creating
hard-to-follow module cycles.

Second of all, environment.py's exact purpose seems a bit obscured.
Splitting the data types (and basic pure functions) from the more
complex logic that infers that data seems like a good way to separate
concerns.
2019-02-27 13:10:16 -08:00
Jussi Pakkanen 067ff7eeae Fall back to current interpreter when python3 not found. 2019-02-26 01:26:54 +02:00
John Ericson 3e9396f259 Fix cross static linker lookup
Need to search based off of `cross_comp`, not `comp`.

Fixes #4822
2019-02-14 11:18:55 -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
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 e1a83793ae CMake: Added support for CMAKE_MODULE_PATH and extra CMake args (closes #4779) 2019-02-01 00:25:21 +02:00
Nirbheek Chauhan 1575bd988a configure_file: Allow setting install_dir: false with deprecation
Also add location node for two more deprecations

See: https://github.com/mesonbuild/meson/pull/4489#issuecomment-459246879
2019-01-31 13:48:59 -05:00
Michael Hirsch, Ph.D da34bea893 pep8 py37 2019-01-29 22:06:11 +02:00
Nicolas Schneider 3fc8a0dc41 fix non-default option printing
Previously, the default option string was compared to the actual project
option that has been converted to the proper type. This lead to messages
like 'Option x is: true [default: true]'.

Fixes #4806.
2019-01-27 20:52:46 +02:00
Jan Tojnar 33d82201bd run_command: add env kwarg 2019-01-27 19:24:15 +02:00
Xavier Claessens 15cea55f5b Interpreter: Add a location to all mlog.warning() calls
Now that the current node is always available as self.current_node in
both function and method calls, it's easy to pass it to warning
messages.
2019-01-22 16:12:15 -05:00
Xavier Claessens 0d195cefa6 Interpreter: Add current_node to 'state' passed to module methods
The current node is useful to pass as location to mlog.warning().
2019-01-22 15:59:36 -05:00
Daniel Mensinger af38722f89 mintro: Introspection interpreter refactoring (#4733)
* Fixed spelling

* Merged the Buildoptions and Projectinfo interpreter

* Moved detect_compilers to Environment

* Added removed test case

* Split detect_compilers and moved even more code into Environment

* Moved set_default_options to coredata

* Small code simplification in mintro.run

* Move cmd_line_options back to `environment`

We don't actually wish to persist something this unstructured, so we
shouldn't make it a field on `coredata`. It would also be data
denormalization since the information we already store in coredata
depends on the CLI args.
2019-01-16 23:42:54 +02:00
Xavier Claessens 83766b3687 Fix flake8 errors 2019-01-16 11:16:46 -05:00
Xavier Claessens 815f1205a8 do_subproject: Improve log messages and formatting 2019-01-16 11:16:46 -05:00
Xavier Claessens af643d6409 extract_required_kwarg: Fix typo 2019-01-16 11:16:46 -05:00
Xavier Claessens 35f0f7090d dependency: Cleanup code by avoiding nested if blocks 2019-01-16 11:16:46 -05:00
Xavier Claessens 5dac8e51f4 dependency: Not all DependencyException means not-found dep 2019-01-16 11:16:46 -05:00
Xavier Claessens 335b87fcaa dependency: Add has_fallback variable 2019-01-16 11:16:46 -05:00
Xavier Claessens 1cd393c6e2 dependency_fallback: Set 'required' in subproject's kwargs
This makes error clearer because it stops exactly where the error occurs
during the subproject configuration.
2019-01-16 11:16:46 -05:00
Xavier Claessens 2867371f1a dependency_fallback: Pass display_name in arguments 2019-01-16 11:16:46 -05:00
Xavier Claessens bdf301d05b do_subproject: InvalidCode is always an error
Not need to catch exceptions in dependency_fallback(), it's already
handled in do_subproject(). This ensure subproject errors are handled
the same way when doing dependency() fallback and when doing
subproject().
2019-01-16 11:16:46 -05:00
Xavier Claessens f6a34c8aaf dependency_fallback: Simplify useless try block 2019-01-16 11:16:46 -05:00
Xavier Claessens b209a3cd8f dependencies: Avoid duplicated code
The dependency version from a subproject was checked in two different
places. Do it in get_subproject_dep().
2019-01-16 11:16:46 -05:00
Xavier Claessens a92b41fdcd dependencies: Remove version from cache key
We cannot have 2 different versions with all other kwargs being
identical. This simplifies a lot that code.
2019-01-16 11:16:46 -05:00
John Ericson b53c982b58 Build class should not duplicate compiler state
Compilers should be held by coredata, so this is just here for
convenience.
2019-01-14 00:16:36 +02:00
Marco Trevisan (Treviño) 95c1cdf776 interpreter: obey to the install argument in configure_file
If a configure_file has an install_dir set, the supported install
argument is ignored, while this should have actually higher priority
than the install_dir itself.
Also check that correct types are used for `install` and `install_dir`.

Add test to verify this.

Fixes #3983
2019-01-13 19:51:31 +02:00
Jon Turney 680d266591 Fix a typo in an error message 2019-01-11 20:58:43 +02:00
John Ericson 17a602a4ec Remove spurious case in interpreter
`need_cross_compiler = is_cross_build()`, so the condition is always
false.
2019-01-10 22:59:01 +02:00
Nicolas Schneider 3232f780d8 use same code for printing options in mconf and msetup
Also, options are now responsible for providing a suitable printable
representation of their value instead of handling this at the caller.
2019-01-06 19:41:24 -05:00
Xavier Claessens aa840afb3a Always flatten include_directories lists 2019-01-06 19:24:05 +02:00
John Ericson 2b22576fb6 Remove cross_info; cross file is parsed up front and discarded 2019-01-02 16:22:47 -05:00
John Ericson dbf080afe9 Get rid of `need_cross_compiler`
Building a cross compiler (`build == host != target`) is not cross
compiling. As such, it doesn't make sense to handle it under
`is_cross_build`.

(N.B. Building a standard library for a cross compiler would require
cross compiling, but Meson has support to do such a thing as part of a
compiler build currently.)
2019-01-02 16:11:02 -05:00
Jussi Pakkanen 3a6e2aeed9 Can use plain strings for include_directories. 2019-01-02 22:29:08 +02:00
Daniel Mensinger 10ce5deb71
Introspection refactoring 2018-12-29 23:55:45 +01:00
Jussi Pakkanen ab3aeeffe9 Print warning if using "default_options" without a "fallback". 2018-12-30 00:50:45 +02:00
Xavier Claessens b6cede2928 find_library: Add 'has_headers' kwarg
A library without its headers is often useless, so it is common to check
them together.
2018-12-27 23:06:28 -05:00
Xavier Claessens ff2aa5a9ef Add 'required' kwarg in header check functions
Closes: #3940
2018-12-24 11:12:11 -05:00
Jussi Pakkanen 4df9006ca4 Can specify a string to print when dep not found. Closes #2407. 2018-12-22 19:00:40 +02:00
Jussi Pakkanen 7d5660dcbe Reformat long lines. 2018-12-22 19:00:40 +02:00
John Ericson 9b13fb3672 Factor out more option iterating 2018-12-20 23:01:36 +02:00
Daniel Mensinger 9958262cb2 Fixed subprojects build info 2018-12-19 18:04:49 -05:00
Xavier Claessens 47b9c1a564 Allow fallback in nodownload mode
It is possible that the subproject has been downloaded already, in that
case there is no reason to not use it. If the subproject has not been
downlaoded already it will fail do_subproject().
2018-12-19 10:21:31 +02:00
Jussi Pakkanen b0611bdd9a
Merge pull request #3061 from jon-turney/introspect-custom-target-files
Fix 'meson introspect --target-files' for a custom target
2018-11-28 21:58:11 +02:00
Dylan Baker 42ddc30cfe interpreter: allow find_program to use the native file 2018-11-14 15:57:37 -08:00
Dylan Baker 95403cb615 replace ExternalProgram.from_cross_info with from_bin_list
This more generic method will also be used to check a config file for
binary information.
2018-11-14 15:57:37 -08:00
Dylan Baker de175aac00 compilers: Use keyword only arguments for compiler interfaces
Because we need to inherit them in some cases, and python's
keyword-or-positional arguments make this really painful, especially
with inheritance. They do this in two ways:

1) If you want to intercept the arguments you need to check for both a
   keyword and a positional argument, because you could get either. Then
   you need to make sure that you only pass one of those down to the
   next layer.

2) After you do that, if the layer below you decides to do the same
   thing, but uses the other form (you used keyword by the lower level
   uses positional or vice versa), then you'll get a TypeError since two
   layers down got the argument as both a positional and a keyword.

All of this is bad. Fortunately python 3.x provides a mechanism to solve
this, keyword only arguments. These arguments cannot be based
positionally, the interpreter will give us an error in that case.

I have made a best effort to do this correctly, and I've verified it
with GCC, Clang, ICC, and MSVC, but there are other compilers like Arm
and Elbrus that I don't have access to.
2018-11-13 00:40:13 +02:00
Stian Selnes 0821462ce3 Add kwarg is_default to add_test_setup()
is_default may be used to set the name of the test setup that will be
used by default whenever the option --setup is not given.

Fixes #4430
2018-11-12 16:23:59 +05:30
Jon Turney bb31a8c1c7
Only add link arguments when needed in Compiler object methods
Currently, ComplierHolder.determine_args() unconditionally adds the link
arguments to the commmand, even if we aren't linking, because it doesn't
have access to the mode (preprocess, compile, link) that
_get_compiler_check_args() will use.

This leads to command lines like:

'cl testfile.c /nologo /showIncludes /c /Fooutput.obj /Od kernel32.lib
user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib
uuid.lib comdlg32.lib advapi32.lib'

which clang-cl considers invalid; MSVS cl accepts this, ignoring the
unneeded libraries

Change from passing extra_args down to _get_compiler_check_args(), to
passing down a callback to CompilerHolder.determine_args() (with a bound
kwargs argument), so it can consult mode and kwargs to determine the args to
use.
2018-11-04 15:42:06 +00:00
Dylan Baker 63f4f9481e Add new compiler.get_argument_syntax method
Some compilers try very had to pretend they're another compiler (ICC
pretends to be GCC and Linux and MacOS, and MSVC on windows), Clang
behaves much like GCC, but now also has clang-cl, which behaves like MSVC.

This method provides an easy way to determine whether testing for MSVC
like arguments `/w1234` or gcc like arguments `-Wfoo` are likely to
succeed, without having to check for dozens of compilers and the host
operating system, (as you would otherwise have to do with ICC).
2018-11-03 18:10:36 +02:00
Dylan Baker 8cd7f7871b interpreter: Don't warn about clang b_undef and b_sanitizer if sanitizer is none
Since the "none" sanitizer isn't actually a sanitizer at all.
2018-11-02 23:20:40 +02:00
Jussi Pakkanen 23ed0e1857 Make string division do path joining. 2018-11-02 21:02:25 +02:00
Nirbheek Chauhan a52cd31a6c Print dependencies being used for compiler checks
It is a common idiom to look for a function or a specific type or
a header in various locations/libraries, and it can be confusing to
see the (seemingly) identical compiler check being done multiple
times.

Now we print the dependencies being used when a compiler check is run

Before:
Checking for function "fbGetDisplay": NO
Checking for type "GLeglImageOES": YES
Checking for function "asinh": YES

After:
Checking for function "fbGetDisplay" with dependency egl: NO
Checking for type "GLeglImageOES" with dependencies glesv2, gl: YES
Checking for function "asinh" with dependency -lm: YES
2018-10-29 21:44:46 +02:00
Xavier Claessens edccb11f01 Rollback if an optional subproject fails
If a subproject is not required and fails during its configuration, the
parent project continues, but should not include any target or state set
by the failed subproject. This fix ninja still trying to build targets
generated by subprojects before they fail in their configuration.

The 'build' object is now per-interpreter instead of being global. Once
a subproject interpreter succeed, values from its 'build' object are
merged back into its parent 'build' object.
2018-10-29 20:22:33 +02:00
Xavier Claessens 61348da069 Add 'disabler' argument to functions returning not-found objects
When dependency(), find_library(), find_program(), or
python.find_installation() return a not-found object and disabler is
true, they return a Disabler object instead.
2018-10-23 22:09:55 +03:00
Xavier Claessens 3f98ad8eed wrap: Improve error handling and logging 2018-10-18 11:42:17 -04:00
Jon Turney a0a0c244e2 os.path.relpath() can fail on Windows
If builddir and sourcedir have different drive letters, a relative path
doesn't exist, and os.path.relpath fails with a ValueError exception.

This just fixes the places which are hit by test cases in a simple-minded
way.  There are several other uses of os.path.relpath(), which might be
suspect.
2018-10-10 19:43:24 +03:00
Xavier Claessens 38a6582145 configure_file: Support taking values from a dict
Closes #4218
2018-10-08 21:03:32 +03:00
Jussi Pakkanen 4d986563dc Expose wrap_mode as an option. Closes #4266. 2018-10-07 22:52:54 +03:00
Jussi Pakkanen 85efd363cb
Merge pull request #3900 from xclaesse/in-operator
Interpreter: Add "in", "not in", "break", and "continue" operators
2018-10-07 20:02:03 +03:00
Xavier Claessens 091e079354 dependency variable from subproject could be not-found
When using a subproject as fallback for a required dependency, we should
check if the dependency object we get from the subproject is found.
2018-10-07 19:35:11 +03:00
Christoph Behle c0236e10f3 Substitute output file then check for conflict.
Fixes Issue #4323.
The check to see if a call to configure_file() overwrites the output of
a preceding call should perform the substitution for the output file
before doing the check.

Added tests to ensure the proper behaviour.
2018-10-07 19:06:01 +03:00
Xavier Claessens fa2e096aa0 Interpreter: Add "in" and "not in" operators
Closes: #3600
2018-10-04 20:14:37 -04:00
John Ericson 1c6b8b72cb Centralize description of build, host, and target, machines
Instead of just putting these together in the interpreter, put them
together in `environment.py` so Meson's implementation can also better
take advantage of them.
2018-10-05 00:14:44 +03:00
Jan Tojnar c0c075c129 Make custom dist scripts accept arguments.
meson.add_dist_script, introduced in #3906, did not accept any arguments
other than script name. Since all other meson.add_*_script methods
do accept args, this makes the dist script accept them as well.
2018-10-04 21:20:57 +03:00
Xavier Claessens 6112e6a815 Fix version check when passing feature option to find_installation() 2018-09-17 11:37:14 -04:00
Jon Turney e702d754b1
Tolerate custom target sources which can't be converted to Files
For backwards compatibility, tolerate but warn about custom target sources
which can't be converted to Files
2018-09-15 16:23:20 +01:00
Jussi Pakkanen 0a1468f8f3
Convert custom target sources to Files with self.source_strings_to_files. 2018-09-15 15:39:08 +01:00
Dylan Baker 51e9db370a Add method to check for C/C++ function attributes
It's fairly common on Linux and *BSD platforms to check for these
attributes existence, so it makes sense to me to have this checking
build into meson itself. Autotools also has a builtin for handling
these, and by building them in we can short circuit cases that we know
that these don't exist (MSVC).

Additionally this adds support for two common MSVC __declspec
attributes, dllimport and dllexport. This implements the declspec
version (even though GCC has an __attribute__ version that both it and
clang support), since GCC and Clang support the MSVC version as well.
Thus it seems reasonable to assume that most projects will use the
__declspec version over teh __attribute__ version.
2018-09-07 11:52:15 -07:00
Nirbheek Chauhan 68cfe1bb52 Test + fix for not-found dependency fallback version comparison
Fixes:
meson.build:6:0: ERROR:  Uncomparable version string 'unknown'.

This was previously partially fixed in a8694f4b, which only fixed it
for cached fallback dependencies.
2018-09-04 22:50:17 -07:00
Rafael Ávila de Espíndola 07d2d88fa9 Allow override_find_program to use an executable.
With this it is now possible to do

foobar = executable('foobar', ...)
meson.override_find_program('foobar', foobar)

Which is convenient for a project like protobuf which produces both a
dependency and a tool. If protobuf is updated to use
override_find_program, it can be used as

protobuf_dep = dependency('protobuf', version : '>=3.3.1',
                          fallback : ['protobuf', 'protobuf_dep'])
protoc_prog = find_program('protoc')
2018-09-03 21:24:01 +03:00
Alexis Jeandet 73a5b4332d Meson should warn if b_lundef is mixed with any sanitizer with clang
Signed-off-by: Alexis Jeandet <alexis.jeandet@member.fsf.org>
2018-09-02 18:21:44 +03:00
Jussi Pakkanen b86f2fd17f
Merge pull request #4016 from thiblahute/hotdoc
modules: Add an 'hotdoc' module
2018-08-29 21:18:26 +03:00
Jussi Pakkanen fb770e1e3d Add support for custom dist scripts. 2018-08-27 23:35:29 +03:00
Jussi Pakkanen 1ffc8de5e8
Merge pull request #3981 from GoaLitiuM/d-win-fixes
Fix D support on Windows
2018-08-27 22:30:23 +03:00
Thibault Saunier 731906504e Add a `required` argument to `subproject`
Allowing to use the new "feature" option type and allowing not to fail
on subproject if it is not necessary to fail.

By default subprojects are "required" so previous behaviour is not
changed.

Fixes #3880
2018-08-27 21:37:18 +03:00
Jon Turney 0f568cc8d5
Don't use version to check for a not-found fallback
In _find_cached_fallback_dep(), actually check if dependency is not found,
rather than using a specific version as a proxy for that.
2018-08-26 17:23:39 +01:00
Xavier Claessens 3f3ae097d5
Merge pull request #3769 from xclaesse/command-line-step2
Command line step2
2018-08-23 09:12:27 -04:00
Jussi Pakkanen 54aed1a92c Added "native" kwarg to add_XXX_args. Closes #3669. 2018-08-22 23:22:48 +03:00
Xavier Claessens fda99b08a4 interpreter: Simplify get_option_internal() and fix base option fallback
The fallback to compilers.base_options was done after optname is changed
to have subproject prefix. Simplify the code by looping over all
dictionaries and only keep user_options separate because that one is
special.
2018-08-22 15:15:54 -04:00
GoaLitiuM 9d5448ab45 Normalize string constructs of d_import_dirs paths
Fixes skipped deprecation warnings of badly constructed d_import_dirs on Windows.
2018-08-20 22:27:31 +03:00
Thibault Saunier 221ac05c69 interpreter: Also process *TargetHolder returned by modules
The module might need to add extra methods on the returned targets
and thus it can return TargetHolders, we should process the
held targets
2018-08-18 09:04:08 -03:00
Thibault Saunier a95763c715 interpreter: Handle 'bool, str, int' values returned by modules 2018-08-18 09:04:08 -03:00
Nirbheek Chauhan 219dec39c0 Fix yielding when subproject option type is different
Earlier, we would replace the subproject option with the parent
project's option, which is incorrect if the types are not the same.

Now we retain the subproject's option and print a warning. It's not
advisable to issue an error in this case because subproject option
yielding is involuntary for the parent project (option names can match
because of coincidences).
2018-08-14 23:06:55 +03:00
Jussi Pakkanen f91b463bf4
Merge pull request #3831 from mesonbuild/symvisibility
Add gnu_symbol_visibility keyword argument
2018-08-11 19:59:34 +03:00
Nirbheek Chauhan ecede89b5d Fix FeatureNew false positive in vcs_tag
Fixes https://github.com/mesonbuild/meson/issues/3904
2018-08-11 09:15:05 -07:00
Jussi Pakkanen fb2cdd0fe2 Call it gnu_symbol_visibility instead. 2018-08-09 19:46:49 +03:00
Jussi Pakkanen 6a0e674043 Add kwarg for specifying symbol visibility. 2018-08-09 19:46:49 +03:00
Nirbheek Chauhan a8694f4b26 Don't check version for fallback not-found dependency
Otherwise we get an error while checking the subproject version:

  Uncomparable version string 'none'.

If the dependency was found as a not-found dependency in the
subproject and is not required, just take it.
2018-08-08 19:31:13 +03:00
Nirbheek Chauhan 8402a22233 Test that vim syntax highlighting is up-to-date
Needs a `mock` kwarg to Interpreter to not do any parsing of build
files, but only setup the builtins and functions.

Also consolidate the documentation and data tests into one class.
2018-08-07 12:54:56 -07:00
Patrick Griffis e45ab8b24c Fix missing permitted kwarg
get_pkgconfig_variable() takes a 'default' keyword
2018-08-07 06:38:43 -07:00
Nirbheek Chauhan a2dab5439c custom targets: Add a 'console' kwarg for long-running commands
Ninja buffers all commands and prints them only after they are
complete. Because of this, long-running commands such as `cargo
build` show no output at all and it's impossible to know if the
command is merely taking too long or is stuck somewhere.

To cater to such use-cases, Ninja has a 'pool' with depth 1 called
'console', and all processes in this pool have the following
properties:

1. stdout is connected to the program, so output can be seen in
   real-time
2. The output of all other commands is buffered and displayed after
   a command in this pool finishes running
3. Commands in this pool are executed serially (normal commands
   continue to run in the background)

This feature is available since Ninja v1.5

https://ninja-build.org/manual.html#_the_literal_console_literal_pool
2018-07-31 19:38:54 +03:00
Jussi Pakkanen e75f6e4305
Merge pull request #3850 from mesonbuild/nirbheek/exe-wrapper-compiler-fallbacks
Be more permissive about not-found exe_wrapper
2018-07-31 19:33:06 +03:00
Nirbheek Chauhan 0ea21d7aea Add a feature-new entry for UserFeatureOption
Since we can't detect it in meson_options.txt, detect it when the
option is used.
2018-07-25 08:02:49 -07:00
Jussi Pakkanen 306fa07f62
Merge pull request #3893 from FFY00/master
Add dlang module (dub support)
2018-07-21 02:46:11 +03:00
Jussi Pakkanen f390a0a2f3
Merge pull request #3814 from behlec/configure-file-output
Check if calls to configure_file write to the same output file.
2018-07-19 01:17:34 +03:00
Nirbheek Chauhan 416a00308f cross: Use ExternalProgram for cross-file exe_wrapper
We already have code to fetch and find binaries specified in a cross
file, so use the same code for exe_wrapper. This allows us to handle
the same corner-cases that were fixed for other cross binaries.
2018-07-09 04:09:46 +05:30
Nirbheek Chauhan 78f1ef85fd
Add missing method on external library object: type_name() (#3845)
For some reason this was missing, but it should've always existed
since cc.find_library() returns an object that is internally an
ExternalDependency instance.
2018-07-08 10:58:07 -07:00