Commit Graph

660 Commits

Author SHA1 Message Date
Xavier Claessens 2d3bfa0778 Interpreter: Fix subdir_done() to exit from inside if/foreach blocks
Closes: #3700.
2018-06-07 12:56:27 +00:00
Xavier Claessens 7c4736d27f Convert args.projectoptions into a dict
This simplifies a lot of code, and centralize "key=value" parsing in a
single place.

Unknown command line options becomes an hard error instead of
merely printing warning message. It has been warning it would become an
hard error for a while now. This has exceptions though, any
unknown option starting with "<lang>_" or "b_" are ignored because they
depend on which languages gets added and which compiler gets selected.
Also any option for unknown subproject are ignored because they depend
on which subproject actually gets built.

Also write more command line parsing tests. "19 bad command line
options" is removed because bad cmd line option became hard error and
it's covered with new tests in "30 command line".
2018-06-06 20:02:37 +00:00
Xavier Claessens 75e501ceb8 coredata: Stop setting default option values as argparse attribute
All options are now the projectoptions list, regardless of how they got
defined in the command line.

This also delays setting builtin option values until the main project()
default options are parsed to simplify the code. This is possible
because we already delayed setting the backend after parsing main
project() in a previous commit.
2018-06-06 20:02:37 +00:00
Xavier Claessens 8fb72510c3 Move to coredata some methods handling options
Those methods only use coredata object, so better just move them as a
coredata method.
2018-06-06 20:02:37 +00:00
Xavier Claessens 5af98d16b9 Delay backend creation until project() is parsed
The project() function could have a different value for the backend
option in its default_options kwargs.

Also set backend options, passing them in command line had no effect
previously.
2018-06-06 20:02:37 +00:00
Xavier Claessens b7d442150d Move <lang>_args to coredata.compiler_options 2018-06-06 20:02:37 +00:00
Xavier Claessens fa72cd7173 Move get_args_from_envvars() from environment to compilers 2018-06-06 20:02:37 +00:00
Nirbheek Chauhan 56a7d8b2b3 Warn when Apple bitcode support is enabled and in-use
We have to disable some options, so tell the user about them and point
to the documentation so they can read more about it.
2018-06-06 07:53:10 +00:00
Jon Turney f31679dedd Fix non-list used with FeatureNewKwargs
The type of this argument needs checking, or single strings need handling correctly.
2018-06-05 15:57:57 +00:00
Nirbheek Chauhan 48d49afe31 FeatureNew: Add decorators for new install_mode kwargs 2018-06-05 15:57:57 +00:00
Nirbheek Chauhan 9b314c9c24 FeatureNew: add two features that were just merged 2018-06-05 15:57:57 +00:00
Aleksey Filippov 9e10628a69 Use mesonlib.version_compare_many() first value only as an indicator of match 2018-06-03 21:10:56 +00:00
mikolajp 2d1d6c3056 Fix meson multiple version contraint error 2018-06-03 21:10:56 +00:00
Jon Turney 7e08e958c0 Allow substitutions in custom_target() depfile:
Allow substitutions in custom_target() depfile: as well as in command:
2018-06-03 21:06:23 +00:00
Filipe Brandenburger 05c43cdcd1 Add 'install_mode' to all installable targets
This makes it possible to customize permissions of all installable
targets, such as executable(), libraries, man pages, header files and
custom or generated targets.

This is useful, for instance, to install setuid/setgid binaries, which
was hard to accomplish without access to this attribute.
2018-06-02 04:50:32 +00:00
Jussi Pakkanen bf2e21ec0e
Merge pull request #3486 from Salamandar/salamandar/meson_version_introspection
Add FeatureNew and FeatureDeprecated, to alert the user of bad meson_version
2018-06-01 22:53:06 +03:00
Mathieu Duponchelle 14750b50ea configure_file: Add output_format kwarg (#3636)
* configure_file: Add output_format kwarg

* docs: Reference-manual.md output_format was added in 0.47 [skip ci]
2018-06-01 17:53:07 +00:00
Salamandar c5e85e59cc Add 0.47.0 features 2018-06-01 14:23:24 +02:00
Salamandar 2fb6018763 Add 0.46.0 features 2018-06-01 14:23:24 +02:00
Salamandar 364b8a37b9 Add 0.45.0 features 2018-06-01 14:23:24 +02:00
Salamandar c90885de6d Add 0.44.0 features 2018-06-01 14:23:24 +02:00
Salamandar 2056172595 Add 0.43.0 features 2018-06-01 14:23:24 +02:00
Salamandar 4741f1e243 Add 0.42.0 features 2018-06-01 14:23:24 +02:00
Salamandar d5207e1c4f Add 0.41.0 features 2018-06-01 14:23:24 +02:00
Salamandar fa6550b277 Add 0.40.0 features 2018-06-01 14:23:24 +02:00
Salamandar a1a53e8de1 Add 0.38.0 features 2018-06-01 14:23:24 +02:00
Salamandar accea4889b Add 0.37.0 features 2018-06-01 14:23:24 +02:00
Salamandar 69230ce4ef print features reports after run 2018-06-01 14:23:24 +02:00
Salamandar dd91f96867 Move target_version from coredata to mesonlib 2018-06-01 14:23:24 +02:00
Salamandar ae19fec952 Add version_compare_condition_with_{min,max} for specific comparison utils.
Split FeatureNew and FeatureDeprecated
Implement features report to be printed in some 'dev mode'
2018-06-01 14:23:24 +02:00
Salamandar ee2f8a0416 Add basic code for feature version detection:
* store target version
* Add empty method decorator
2018-06-01 14:23:24 +02:00
Nirbheek Chauhan ff07314a86 New compiler method: check_header
This checks not only for existence, but also for usability of the
header, which means it does a full compilation and not just
pre-processing or __has_include.

Fixes https://github.com/mesonbuild/meson/issues/2246
2018-05-30 15:25:39 +05:30
Jussi Pakkanen cc3e0bc469
Merge pull request #3491 from jeandet/qt_private_headers
Qt private headers
2018-05-27 23:50:30 +03:00
Jussi Pakkanen 320a5865d9 Mark even empty confs used appropriately. 2018-05-25 17:43:06 +03:00
Tim-Philipp Müller 8d040fad6e Print project version 2018-05-23 22:46:29 +03:00
Tim-Philipp Müller d4ee534155 interpreter: fix configure_file() message on empty configuration_data() [skip ci]
The 'copy' kwarg will appear in the upcoming 0.47 release, not 0.46.
2018-05-23 15:02:27 +00:00
Jussi Pakkanen 55a0831bc3
Merge pull request #3383 from mesonbuild/nirbheek/configure-file-nodata
configure_file: Add a new action 'copy'
2018-05-22 21:09:19 +03:00
Jussi Pakkanen 9ecd92c6fe
Merge pull request #3490 from MathieuDuponchelle/dict_builtin
Add new built-in type, dict
2018-05-22 20:46:26 +03:00
Andrei Alexeyev d72f9a3e0f
Add 'check' kwarg for run_command
Closes #3516
2018-05-22 04:45:31 +03:00
Nirbheek Chauhan f5af0f9b5a configure_file: Don't use reserved keyword 'format'
Might lead to weird bugs
2018-05-22 02:37:07 +05:30
Nirbheek Chauhan a00433fdbc configure_file: Add a new action 'copy'
This will copy the file to the build directory without trying to read
it or substitute values into it.

Also do this optimization if the configuration_data() object passed to
the `configuration:` kwarg is empty, and print a warning about it.

See also: https://github.com/mesonbuild/meson/issues/1542
2018-05-22 02:36:55 +05:30
Mathieu Duponchelle ecb8838082 Add new built-in type, dict
For now dicts are immutable, and do not expose any methods,
they however support "native" syntax such as [] lookup,
and foreach iterating, and can be printed.
2018-05-20 21:19:44 +02:00
Jon Turney 13e92223be Generalize message about fallback failure
The fallback might be not used not only because it couldn't be found, but
also because something went wrong trying to use it.

Also, update a test which relies on the specific text
2018-05-17 00:26:58 +03:00
Jon Turney 0e898def93 Improve reporting about falling back to a subproject for a dependency 2018-05-17 00:26:58 +03:00
Mathieu Duponchelle dc91aad420 args flattening: preserve configuration_data.set behaviour
It seems that some projects relied on the previously buggy
behaviour of accepting a 2-element list as the single argument
to configuration_data.set().

Special-case this behaviour, and emit a deprecation message.
2018-05-09 18:00:36 +02:00
Mathieu Duponchelle f1c92d7c9c Interpreter: don't flatten the arguments of various methods
this fixes eg set_variable('foo', ['bar', 'baz']), which
was previously erroring out complaining about the number
of arguments.

Closes #1481
2018-05-04 15:24:21 +00:00
Xavier Claessens 24f1b96dde Fix setting c_args and friends from command line
When passing more than one -Dc_args it should override the value
instead of appending. This is how all other options works.

Value should be split on spaces using shlex just like it does with
CFLAGS environment variable.

Fixes #3473.
2018-05-01 12:09:45 +00:00
Alexis Jeandet 2fc0a11062 [Qt module] Privates headers: Implemented private_headers option
This commit adds private_headers option in dependency method which tells
QtDependency to add private headers include path to build flags.
Since there is no easy way to do this with pkg-config only qmake method
supports this, so with private_headers set qmake will always be used.

Signed-off-by: Alexis Jeandet <alexis.jeandet@member.fsf.org>
2018-04-28 17:14:31 +02:00
Xavier Claessens 10a9bdad96 interpreter: Verify permitted kwargs on all methods 2018-04-26 00:01:48 +03:00
Nirbheek Chauhan fc5e8dfcda Don't fail on not-required not-found deps in forcefallback mode
This involves the creation of a new dummy NotFoundDependency.
2018-04-21 16:10:03 +03:00
Xavier Claessens 9a82b0136a extract_all_objects: Add 'recursive' keyword argument
To maintain backward compatibility we cannot add recursive objects by
default. Print a warning when there are recursive objects to be pulled
and the argument is not set. After a while we'll do pull recursive
objects by default.
2018-04-18 14:54:52 -04:00
Jussi Pakkanen 628f910760
Merge pull request #3314 from sarum9in/test_depends
Add test(depends) keyword parameter
2018-04-18 00:40:52 +03:00
Dylan Baker 92487ea33d Add partial_dependency method to dependencies
This adds a new method, partial_dependency to all dependencies. These
sub dependencies are copies of the original dependency, but with one or
more of the attributes replaced with an empty list. This allows creating
a sub dependency that has only cflags or drops link_arguments, for
example.
2018-04-17 23:33:31 +03:00
Jussi Pakkanen 1952ef5ae1
Merge pull request #3243 from dcbaker/accept-d-setup
Accept -D for meson level options durring initial configuration
2018-04-17 23:29:15 +03:00
Jussi Pakkanen 8ee1e49ae6
Merge pull request #3353 from xclaesse/has-link-argument
Add has_link_argument() and friends
2018-04-17 23:26:53 +03:00
Jussi Pakkanen 3fc1ca8687
Merge pull request #3240 from MathieuDuponchelle/python_module
Implement a generic python module
2018-04-17 23:17:43 +03:00
Dylan Baker 33c5c7e7e9 interpreter: Don't assume default link_args == compile_args
Since we want to make the options passed to `meson` and `meson
configure` equivalent, we need to allows pass -D<lang>_args and
-D<lang>_link_args to `meson`. This path assumes that if one is set then
the other must be, which isn't true.
2018-04-17 11:32:26 -07:00
Xavier Claessens bd37afeeea Add has_link_argument() and friends
Closes: #3335.
2018-04-16 19:14:02 -04:00
Xavier Claessens 521ce883ad has_argument(): reduce code duplication 2018-04-16 19:08:24 -04:00
Nirbheek Chauhan 6cdd14fc4e find_program: Don't spam when called from a module
The user doesn't need to know whether or not the program was found,
especially not when it's spammed for every gnome.foo() function
2018-04-15 14:13:35 +05:30
Nirbheek Chauhan 87c166db95 find_program: Only store successful lookups
Otherwise we can't do the following workflow:

if not find_program('foo', required : false).found()
  subproject('provides-foo')
endif

Where 'provides-foo' has a meson.override_find_program() on
a configure_file() or similar.
2018-04-15 13:32:38 +05:30
Jussi Pakkanen 998892ed29 Updated all modules to work with the new API. 2018-04-15 13:32:38 +05:30
Jussi Pakkanen 4256c0dae2 Can override programs with scripts generated with configure_file. 2018-04-15 13:32:38 +05:30
Jussi Pakkanen bdb57cf62a Convert Gnome module to use find_program from interpreter. 2018-04-15 13:32:38 +05:30
Jussi Pakkanen de65adb8b1 Made it possible to override find_program to return a different program.
Closes https://github.com/mesonbuild/meson/issues/2005
2018-04-15 13:32:38 +05:30
Jon Turney cb597adb01 Indicate subproject depth in console output 2018-04-13 01:05:54 +00:00
David Fort 6dea177774 add support for cmakedefine in configure_file()
The added format argument for configure_file allows to specify the kind of
file that is treated. It defaults to 'meson', but can also have the 'cmake'
or 'cmake@' value to treat config.h.in files in the cmake format with #cmakedefine
statements.
2018-04-08 22:00:45 +03:00
Xavier Claessens 8a70e7cff5 Remove arbitrary [-1024,1024] limit in cross_compute_int()
Copy the algorithm used by autoconf.

It computes the upper and lower limits by starting at [-1,1] and
multiply by 2 at each iteration. This is even faster for small numbers
(the common case), for example it finds value 0 in just 2 compilations
where old algorithm would check for 1024, 512, ..., 0.
2018-04-08 16:56:33 +03:00
Jussi Pakkanen d6e71d0c56
Merge pull request #3312 from MathieuDuponchelle/alwaysfallback
new wrap-mode: forcefallback
2018-04-08 01:08:51 +03:00
Christoph Behle 40715dec21 Move entry in build_funct_dict to correct position.
The entry 'subdir_done' is now at its right place.
2018-04-08 01:04:44 +03:00
Mathieu Duponchelle 31f0242a6f new wrap-mode: forcefallback
This can be useful to make sure that a project builds when
its fallbacks are used on systems where external dependencies
satisfy the version requirements, or to easily hack on the sources
of a dependency for which a fallback exists.
2018-04-06 23:48:48 +02:00
Mathieu Duponchelle e1b138a21b Implement a generic python module
With contributions from Håvard Graff
2018-04-06 22:43:35 +02:00
Xavier Claessens 68f9846b7c Add both_libraries() to build both shared and static libraries
Also support default_library='both' to make library() build both shared
and static libraries.

Closes #484
2018-04-03 15:38:01 -04:00
Xavier Claessens 5eef325ab6 pkgconfig generator: Only skip dependencies when using shared_library()
It is weird and inconsistent to have different pc file depending on
default_library value when using library() or build_target(). We should
skip dependencies only when user explicitly want shared library only.
2018-04-03 15:20:19 -04:00
Xavier Claessens cf0e997167 Remove duplicated list of known kwargs for build targets 2018-04-03 15:20:19 -04:00
Alexis Jeandet 16c4a3b4f8 Added link to documentation and examples for find_library replacement (#3346) 2018-03-31 11:38:09 +03:00
behlec 37d379ebe5 Allow meson build file to exit early. (#2808) 2018-03-29 21:29:45 +03:00
Víctor Manuel Jáquez Leal 6f7f7c69a2 dependency's wanted version might be a list
A dependency declared in a subproject should be able to behave as
a pkgconfig dependency, thus it should process the wanted version
as a list.
2018-03-25 18:27:13 +03:00
Aleksey Filippov c18ceac040 Add depends keyword to test() function 2018-03-25 01:33:33 +00:00
Aleksey Filippov 642df0505a Use unholder=True instead of checking held_object attribute presence 2018-03-25 01:33:33 +00:00
Jussi Pakkanen 30827b5644 Do not install configure_file output if install_dir is empty. Closes #3270. 2018-03-21 21:25:47 +02:00
Jussi Pakkanen 657836b555
Merge pull request #3223 from sarum9in/rename
Add install_data() rename parameter
2018-03-20 00:15:01 +02:00
Nirbheek Chauhan d012b5b997 Create a helper for checking if a string has a path component
This is used in a number of places, and in some places it is incomplete.
Use a helper to ensure it's used properly.
2018-03-19 23:45:43 +02:00
Aleksey Filippov f720efa2f4 Add rename parameter to install_data() 2018-03-17 20:40:50 +00:00
Jussi Pakkanen 9ecb75670f
Merge pull request #3127 from bluetech/method-permitted-kwargs 2018-03-13 21:16:30 +02:00
Jussi Pakkanen 407b6dfc29
Merge pull request #3203 from jukkalaurila/bug3185
Fix bug 3185, "Setting -Dc_args=... option and some others during initial run fails silently'
2018-03-10 18:25:03 +02:00
Jon Turney 8ca2cf03a5 Show info about possible subproject promotion when appropriate
Move call to print_nested_info down into do_subproject()

So we don't print info about possible subproject promotion unless subproject
failure is due to directory non-existence

And we do do that for subproject('foo'), as well as for dependency(fallback:
['foo', ...])
2018-03-10 18:07:32 +02:00
Niklas Claesson 7074bcb88a Exclude subprojects when doing coverage 2018-03-10 18:05:35 +02:00
Jukka Laurila 8789278e5e Fixed bug 3185. 2018-03-09 01:32:32 +01:00
Jussi Pakkanen e98ae58d0e
Merge pull request #3086 from sarum9in/declare-link-whole
Add declare_dependency() link_whole parameter
2018-03-06 21:08:54 +02:00
Evgenii Shatokhin 19718a8d9c Allow passing a compiler object to run_command()
Sometimes it is needed to run the current compiler with specific options
not to compile a file but rather to obtain additional info. For example,
GCC has several -print-* options to query it about the paths to
different libraries and development files. One use case is to get the
location of development files for GCC plugins, which is not easily
obtainable by other means:

  gcc -print-file-name=plugin

For this purpose, it would be convenient if the compiler object returned
by meson.get_compiler(lang) could be used in run_command() directly.
This commit implements it.

Signed-off-by: Evgenii Shatokhin <eshatokhin@virtuozzo.com>
2018-03-06 21:07:16 +02:00
Aleksey Filippov 077d59daa4 Add link_whole argument to declare_dependency() 2018-03-06 01:44:26 +00:00
Jon Turney b8b23f4c50 Fix various flake8 whitespace reports
$ flake8 | grep -E '(E203|E221|E226|E303|W291|W293)'
./run_unittests.py:1503:5: E303 too many blank lines (2)
./mesonbuild/interpreter.py:2342:64: E226 missing whitespace around arithmetic operator
./mesonbuild/minit.py:110:17: E221 multiple spaces before operator
./mesonbuild/minit.py:131:1: W293 blank line contains whitespace
./mesonbuild/minit.py:135:19: E221 multiple spaces before operator
./mesonbuild/minit.py:155:1: W293 blank line contains whitespace
./mesonbuild/minit.py:181:1: W293 blank line contains whitespace
./mesonbuild/minit.py:183:1: W293 blank line contains whitespace
./mesonbuild/minit.py:294:47: W291 trailing whitespace
./mesonbuild/minit.py:331:47: W291 trailing whitespace
./mesonbuild/modules/unstable_icestorm.py:49:1: W293 blank line contains whitespace
./mesonbuild/modules/unstable_icestorm.py:76:31: E203 whitespace before ':'
./mesonbuild/modules/unstable_icestorm.py:82:22: E203 whitespace before ':'
2018-03-03 21:06:45 +00:00
Hemmo Nieminen 4611097654 Include project name in a test object. 2018-02-25 21:44:59 +02:00
Hemmo Nieminen abcaf7c222 Namespace test setups.
Use $project_name:$test_setup namespace scheme for test setups. This
allows one to choose from which (sub)project a test setup is taken from
should there be several sharing the same name. Defaults to the main
project. E.g. "meson test --setup subproj:valgrind".
2018-02-25 21:44:59 +02:00
Hemmo Nieminen ec286d4970 Change an error message when find_program() fails.
Mention all the sought programs in the error message.
2018-02-25 21:44:59 +02:00
Jussi Pakkanen ea3b54d402 Use include_directories for D impdirs.
Change the code to store D properties as plain data. Only convert them
to compiler flags in the backend. This also means we can fully parse D
arguments without needing to know the compiler being used.
2018-02-25 19:42:15 +02:00
Ran Benita 4d8e4654cb Warn if non-permitted keyword arguments are given to compiler methods
This can help future generations avoid mistakes like this:
edb1c66239

To avoid breaking builds, this is currently just an error. After
sufficient time has passed this can hopefully become a hard error,
similarly to the already-existing `permittedKwargs` warnings.
2018-02-23 04:35:15 +02:00
Jussi Pakkanen 55a7c265c1
Merge pull request #2863 from jon-turney/exit-status-on-exception
Verify that failing tests are failing with an error, not a python exception
2018-02-18 13:54:50 +02:00
Jussi Pakkanen 1841d53a84
Merge pull request #2943 from ximion/master
Don't fail loading subprojects if subprojects_dir is in a subdirectory
2018-02-18 13:50:57 +02:00
Matthias Klumpp a64a237d72 Don't mention "error" in error messages
Starting with VS 2017 if the output of any command run by VS contains
the word Error it will interpret that as a fatal error, even if the exit
error code is zero.
This messes up the unit tests on VS 2017, because we sometimes want to
deliberately ignore error messages.
Change "Error" to "Problem" to mitigate this issue until a more
permanent solution is found.
2018-02-17 23:20:26 +01:00
Jon Turney 9e6d3f903c Only expose exception() test function during unit tests 2018-02-15 12:51:25 +00:00
Jon Turney b78a01bced Add a test case for python exception exit status 2018-02-15 12:51:25 +00:00
Jussi Pakkanen 9dc995b3e9 Permit path separators in subproject names but with a warning. Closes #2794. 2018-02-14 23:59:20 +02:00
Jussi Pakkanen e2b5ac29d6 Only add reconfigure deps on files, not dirs. Closes #2919. 2018-02-14 19:14:30 +02:00
Hemmo Nieminen d0f620364f Fix a stack trace caused by subproject.get_variable('non-existing'). 2018-02-13 21:29:32 +02:00
Jussi Pakkanen ca4cbab004 Use absolute path if relative can not be evaluated. Closes #2784. 2018-02-13 21:28:42 +02:00
Matthias Klumpp 3274f951d2 Don't fail loading subprojects if subprojects_dir is in a subdirectory 2018-02-12 19:12:44 +01:00
Matthias Klumpp f35606f61e Show a better error message if subproject can not be configured
Previously, Meson was showing a subproject being downloaded after later
claiming it doesn't exist.
This patch shows the actual error to clarify why the given subproject
can not be used.
2018-02-12 19:12:44 +01:00
Jussi Pakkanen 54d7817087 User options can "yield to" a user option of the same name in superproject. Closes ##2853. 2018-02-08 00:33:44 +02:00
Aleksey Filippov 549f9a41e5 Rename install_subdir() option elide_directory to strip_directory 2018-02-05 01:28:07 +00:00
Aleksey Filippov 8ca3cc0c3d Add elide_directory keyword for install_subdir() function
If elide_directory=true install_subdir() installs directory contents
instead of directory itself, eliding name of the source directory.

Closes #2869.
2018-02-05 01:28:07 +00:00
Jussi Pakkanen bfa6c8d074
Merge pull request #2938 from acfoltzer/rust-cross-merge
Add cross-compilation support for `rustc`
2018-02-04 00:44:09 +02:00
Aleksey Filippov 8fe8161014 Refactor and simplify install_subdir()
- Pass exclude_files and exclude_directories relative to src_dir,
  same as specified by user and documented in public install_subdir().
- Make do_copydir() interface similar to do_copyfile():
  install src_dir contents to dst_dir.
- Remove src_prefix/src_dir code, it adds confusion and duplicates arguments.
  Use single src_dir parameter instead.
- Make callers specify that src_dir contents should be installed
  under dst_dir/basename(src_dir) if necessary.
- Use os.path.relpath() instead of string manipulations on paths.
- Add documentation to do_copydir(): specify types and add usage example.
2018-02-04 00:43:00 +02:00
Jussi Pakkanen 2601cbe8a8 Created an unstable module for IceStorm projects. 2018-02-02 20:05:31 +02:00
Martin Kelly 36aca4cd3c add meson.project_license() builtin
This Fixes #2941.
2018-01-31 23:54:28 +02:00
Jussi Pakkanen af2067b670 Make checks a bit more robust against empty entries. 2018-01-31 21:01:28 +02:00
Adam C. Foltzer 1d81efb03d Add cross-compilation support for `rustc`
This patch is largely modeled on the relatively-straightforward code
for Fortran cross-compilation, so there might be some intricacies
missing.
2018-01-29 15:47:05 -08:00
Aleksey Filippov 2cf85ae16f Use os.path: basename() and dirname() instead of split()
According to Python documentation[1] dirname and basename
are defined as follows:
    os.path.dirname() = os.path.split()[0]
    os.path.basename() = os.path.split()[1]
For the purpose of better readability split() is replaced
by appropriate function if only one part of returned tuple
is used.

[1]: https://docs.python.org/3/library/os.path.html#os.path.split
2018-01-30 07:08:22 +11:00
Jon Turney 6a1a56ab57 Report warning/error locations in a format IDEs may already know how to parse
Examples:

meson.build:2:0: ERROR: Dependency is both required and not-found
meson.build:4: WARNING: Keyword argument "link_with" defined multiple times.

These are already matched by the default compilation-error-regexp-alist in
emacs.

Also:
Don't start 'red' markup until after the \n before an error
Unabsorb full-stop at end of warning with location from mlog.warning()
Update warning_location test
2018-01-30 06:48:22 +11:00
Jussi Pakkanen 59d0434039 Removed two deprecations from 2016. 2018-01-17 22:12:43 +02:00
Raphael Salamon 4cae553cb1 Add `main` argument to `dependency` (#2828)
`GTest` uses this keyword for conditional linking of it's main().

Fixes issue #2828
2018-01-17 21:00:45 +02:00
Jussi Pakkanen d6bed2a77d
Merge pull request #2764 from mesonbuild/generatorpath
Generator outputs can have path segments
2018-01-13 19:00:38 +02:00
Christophe Gouiran 81100f0695 Change handling of not found external programs 2018-01-11 00:34:19 +02:00
Nikita Churaev de8018a17d Add `export_dynamic` argument to `executable`. (#2662) 2018-01-09 21:36:13 +02:00
Matthias Klumpp 894ff1e629 Ensure subproject_dir is a string and doesn't contain ".." segments
This is important so people can not trick Meson to select a
subproject_dir that is not in the project's source directory.
It also ensures a string is used for the path.
2018-01-07 19:28:22 +01:00
Matthias Klumpp 0da6d891ac Allow subproject dirs in subdirectories in the source tree again
The previous change disallowed any subdirectories for subproject dirs,
and therefore broke a couple of projects making use of that.
This change still prevents people from setting subproject dirs that are
not in the project's source tree, while allowing to specify any path
within the project's directory again.

Resolves: #2719
2018-01-07 18:23:56 +01:00
Jussi Pakkanen 65f78a722a
Merge pull request #2856 from jon-turney/warning-location
Consolidate warning location formatting
2018-01-03 22:32:40 +02:00
Jussi Pakkanen ad54bc3726
Merge pull request #2838 from mesonbuild/nirbheek/consolidate-subproject-dep-checking
intrp: Consolidate subproject dep checking and logging
2018-01-02 20:35:19 +02:00
Jon Turney f85fde743a Wire up locations in a couple more warnings
These are the remaining warnings in the parser, where we have the location
to hand.
2018-01-01 13:21:00 +00:00
Jon Turney 2ed875e1b4 Consolidate warning location formatting in mlog.warning()
Also use .format() rather than %
Also use build.environment rather than hardcoding 'meson.build'
2018-01-01 13:20:55 +00:00
Nirbheek Chauhan 851475db9b intrp: Consolidate subproject dep checking and logging
If a dep is not found on the system and a fallback is specified, we
have two cases:

1. Look for the dependency in a pre-initialized subproject
2. Initialize the subproject and look for the dependency

Both these require version comparing, ensuring the fetched variable
is a dependency, and printing a success message, erroring out, etc.

Now we share the relevant code instead of duplicating it. It already
diverged, so this is a good thing.

As a side-effect, we now log fallback dependencies in the same format
as system dependencies:

    Dependency libva found: YES
    Dependency libva found: YES (cached)

    Dependency glib-2.0 from subproject subprojects/glib found: YES
    Dependency glib-2.0 from subproject subprojects/glib found: YES (cached)
2018-01-01 01:14:03 +05:30
Jon Turney ad5cc2ce55 Append warning location to warning output by warning() 2017-12-30 20:10:15 +00:00
Karol Szuster 8fb7d9261a Add missing space 2017-12-27 00:41:09 +02:00
Jussi Pakkanen ac8d6087bf
Merge pull request #2334 from mesonbuild/promotedep
Add functionality to promote nested dependencies to top level.
2017-12-26 13:24:30 +02:00
Jussi Pakkanen 1806aac376
Merge pull request #2817 from jon-turney/master
Update prefix-dependent defaults when project(default_options:) changes prefix
2017-12-26 13:22:03 +02:00
Niklas Claesson 7f4f082d69 Print 'cached' if dependency is found in cache 2017-12-22 01:44:56 +01:00
Niklas Claesson ba161d42ee subproject handling: add fix 2017-12-22 00:59:19 +01:00
Jon Turney 861cbc2e73 Update prefix-dependent defaults when project(default_options:) changes prefix
Fixes #2811
2017-12-21 19:21:49 +00:00
Jussi Pakkanen b6dd50db31
Merge pull request #2791 from behlec/compiler-version
Add more version information to compiler
2017-12-20 20:42:01 +02:00
Jussi Pakkanen b949c4792d Preserve_path_from should be a kwarg of process(), not generator(). 2017-12-17 22:42:20 +02:00
Jussi Pakkanen 5b9d79b902 Print instructions on how to promote subsubprojects. 2017-12-17 21:19:22 +02:00
Christoph Behle 7bd30c522b Fix flake8 issues. 2017-12-16 16:12:46 +01:00
Christoph Behle c6acf75617 More version information for compilers.
See issue #2762
Adds full_version to class Compiler. If set full_version will be printed
additionally.
Added support for CCompiler and CPPCompiler
Added support for gcc/g++, clang/clang++, icc.
2017-12-16 14:52:08 +01:00
Jussi Pakkanen 88756bfe95 Print UTF-8 warning only when actually encountering non-ascii filenames. 2017-12-14 23:49:12 +02:00
Jussi Pakkanen 4af4145d09 Files created with generator can have path segments.
This is OK, because they are written in the private directory
of each target and its layout can be anything.
2017-12-12 00:02:37 +02:00
Jussi Pakkanen bc83c58d37
Merge pull request #2731 from mesonbuild/disabler
Created disabler object type
2017-12-05 01:10:50 +02:00
Jon Turney 87e6201214 Document and improve not-found dependency objects
Document dependency('', required:false) usage.
Avoid emitting 'Dependency  found: NO'.
2017-12-05 01:04:57 +02:00
Jussi Pakkanen 678daad6cc Created a new disabler type. 2017-12-04 23:53:23 +02:00
Jussi Pakkanen 018deb48fe
Merge pull request #2663 from inigomartinez/pkg-config-define-variable
dependencies: Allow pkg-config to define variables
2017-12-03 22:53:44 +02:00
Joergen Ibsen 312bc2ca81 Fix string format recursive replace
Also error on placeholder index out of range.
2017-12-03 22:51:58 +02:00
Dylan Baker f260a42216 Don't warn for optional_modules
LLVM can have optional modules, modules that will make the code faster
but are not required.
2017-11-28 17:12:45 -08:00
Jussi Pakkanen 746e70c0da
Merge pull request #2512 from dcbaker/wip/config-tool-variables
Add method to get values from config tool based dependency
2017-11-28 22:01:00 +02:00
Jussi Pakkanen 5bc1009109 Add if_found kwarg to subdir(). 2017-11-27 23:22:47 +02:00
Dylan Baker f818e9df58 Add a configtool_variable method to dependency
This mirrors the get_pkgconfig_variable but for config tool based
dependencies.
2017-11-23 20:06:23 -08:00
Iñigo Martínez 935ca12822 dependencies: Allow pkg-config to define variables
pkg-config enables to define variables by using the define-variable
option. This allows some packages to redefine relative paths, so
files can be installed in the same relative paths but under prefix.
2017-11-20 22:00:25 +01:00
Christoph Behle 05ee756ba0 Check keyword arguments for dependency
Check if the keyword arguments given to dependency are permitted, as is
done with other functions already.
The list of permitted keyword arguments is taken from the documentation.
2017-11-19 18:27:27 +02:00
Jussi Pakkanen 49eb33ff55
Merge pull request #2000 from t-chaik/tchaik/wip/get-unquoted
config data: add .get_unquoted() convenience method to get quoted string unquoted
2017-11-13 22:54:39 +02:00
Dylan Baker 5331073188 Interpreter: ensure build_def_files defined before parse_project()
Mesa has 4 build systems currently, set our version in a file called
VERSION, and read that in to each build system to simplify the release
process. For meson this is accomplished by using run_command within the
project() function declaration itself, and with meson <= 0.43.0 this
works fine. Commit 1b0048a702 makes
scripts that are run through run_command a rebuild dependency, but the
attribute used to store that information is set after the project()
command is processed. This breaks mesa.

The solution is to set that list before calling parse_project.

Fixes #2597
2017-11-10 18:23:33 +02:00
Philipp Ittershagen a176588151 fix include_directories handling in subprojects for compiler tests. 2017-11-08 21:18:48 +02:00
Paulo Antonio Alvarez 1540e615f1 interpreter: Add warning function 2017-10-31 22:17:01 +02:00
Jussi Pakkanen 3faf35ac64
Merge pull request #2551 from mesonbuild/fix2481
Evaluate subproject directory name correctly
2017-10-31 01:06:15 +02:00
Martin Kelly 02bea7d5bf namespace run_targets by subproject
Currently, run_target does not get namespaced for each subproject,
unlike executable and others. This means that two subprojects sharing
the same run_target name cause meson to crash.

Fix this by moving the subproject namespacing logic from the BuildTarget
class to the Target class.
2017-10-31 01:04:38 +02:00
Scott D Phillips 1b0048a702 run_command: add command and files as build dependencies 2017-10-29 18:43:17 +02:00
Jussi Pakkanen 53c1afffaf Evaluate subproject path correctly. Closes #2481. 2017-10-29 18:05:03 +02:00
Jussi Pakkanen 12df9c46f5 Check that link_with arguments in declare_dependency are not external dependencies. 2017-10-29 02:00:26 +03:00
Jussi Pakkanen c178a5766b Because people are very creative in working around limitations based on good faith. 2017-10-24 23:01:57 +03:00
Narendra Vardi 6083eb29d0 Do not allow escaping the subprojects directory.
Fixes #2306
2017-10-19 20:17:52 +03:00
liugang 36d85db5d4 fix all subproject using wrap-file broken
subproject using wrap-file is broken since commit (68bd64c Prevent
projects from directly grabbing files from other subprojects. )

subproject with wrap-file usually have version number after name

- **sproj_name** is `zlib-1.2.8` according to `directory = zlib-1.2.8`
of zlib.wrap
- but **self.subproject** `zlib`
2017-10-14 18:09:13 +03:00
Jussi Pakkanen 68bd64cd38 Prevent projects from directly grabbing files from other subprojects. 2017-10-08 13:52:10 +03:00
Nirbheek Chauhan bb0e18b738 Use listify and extract_as_list everywhere
They now flatten by default and unhold objects if required

Includes unit tests.
2017-10-01 22:27:48 +05:30
Nirbheek Chauhan 3a63f0d63c interpreter: Add a new ObjectHolder class
Sets the held_object property and also implements a readable repr()
2017-10-01 12:07:04 +05:30
Jussi Pakkanen 1b442d11b4 Prevent projects from grabbing other projects' options. 2017-10-01 01:22:05 +03:00
Niklas Claesson 68275b32e8 Implement capture for generators 2017-09-29 23:29:44 +03:00
Dylan Baker dda5e8cadb Allow CustomTarget's to be indexed
This allows a CustomTarget to be indexed, and the resulting indexed
value (a CustomTargetIndex type), to be used as a source in other
targets. This will confer a dependency on the original target, but only
inserts the source file returning by index the original target's
outputs. This can allow a CustomTarget that creates both a header and a
code file to have it's outputs split, for example.

Fixes #1470
2017-09-27 22:01:24 +03:00
Jussi Pakkanen dfc2b75ee2 Merge pull request #2348 from centricular/configure-file-infinite-loop
configure_file: Fix infinite loop in some cases
2017-09-26 21:46:55 +03:00
Nirbheek Chauhan 87327d414a configure_file: Fix infinite loop in some cases
We were adding built files to the list of source files to check for
regen. We were also not adding sources files to regen when `command:`
was used.

Fixes #1865
2017-09-26 18:47:00 +05:30
Jussi Pakkanen bea6b1a6f6 Merge pull request #2187 from centricular/fix-pcap-dependency
Fix pcap dependency, str.strip() now takes an argument, add cc.get_return_value()
2017-09-22 22:04:18 +03:00
Jussi Pakkanen be0aa7fd74 Merge pull request #2357 from LukeShu/flake8
Bring into compliance with flake8
2017-09-22 21:33:34 +03:00
Jussi Pakkanen 2cbd917cf6 Merge pull request #2326 from dcbaker/use-link-compilers
Consider compilers used in static_library parents
2017-09-21 19:53:45 +03:00
Luke Shumaker bb25260f00 flake8: Perform suggested whitespace/formatting changes
This only touches newlines, spaces, and (occaisionally) commas.  Anything
else is left for another commit.
2017-09-21 11:59:03 -04:00
Thibault Saunier 96e24a50f9 Add cs_args as known args for csharp 2017-09-20 18:54:15 +03:00
Dylan Baker 59a90309ab Fix error message for find_program if program cannot be found
Currently this raises an exception because exename is undefined.
2017-09-20 08:42:33 -07:00
Nirbheek Chauhan 59473e9ed7 Add a new compiler method: get_return_value()
This method accepts a single function that takes no arguments and
returns a single value which can be a value that can be cast to
a 64-bit signed integer, or a string, and returns that value.

Mostly useful for running foolib_version() functions that return the
currently-available version of libraries.
2017-09-20 13:36:42 +05:30
Alexis Jeandet e553d0807b Last round with listify function refactoring.
Signed-off-by: Alexis Jeandet <alexis.jeandet@member.fsf.org>
2017-09-18 22:25:34 +02:00
Jussi Pakkanen 9c834a4ecd Merge pull request #2310 from hvenev/reconfigure-get_option
Fix get_option() for base options on reconfigure.
2017-09-18 20:42:38 +03:00
Matthias Klumpp 61db415d7f d: Make feature names less verbose 2017-09-17 21:36:13 +02:00
Hristo Venev 56c566a38e Fix get_option() for base options on reconfigure. 2017-09-15 21:56:46 +01:00
Martin Blanchard 71deffab18 get-unquoted: Fix indentation and remove useless arithmetic 2017-09-15 22:05:44 +02:00
Martin Blanchard fa1fee5686 get-unquoted: Implement a get_unquoted() method for ConfigurationData 2017-09-15 22:05:44 +02:00
Matthias Klumpp 75fdf413e4 Drop feature_args call in favor of letting pkgconfig do this directly 2017-09-12 17:33:22 +02:00
Matthias Klumpp 6cd3f066b4 d: Implement specific properties for D features 2017-09-12 17:32:03 +02:00
Matthias Klumpp d83c289442 d: Add easy way to use D-specific features
Of course D compilers have different flags to set some important
D-specific settings. This adds a simple method to change these flags in
a compiler-agnostic way in Meson.

This replaces the previous `unittest_args` method with a more generic
variant.
2017-09-12 17:32:03 +02:00
Nirbheek Chauhan aff981a6b0 Fix regression in test definitions
Caused by #2236. Also add a test for this.
2017-09-10 17:41:37 +05:30
Jussi Pakkanen 9361666bd8 Merge pull request #2236 from trhd/env
Fix a stack trace caused by environment variables in test setups.
2017-09-06 23:13:55 +03:00
Jussi Pakkanen 72a6683c6f Permit overriding find_program from the cross file. 2017-09-04 22:47:12 +03:00
Hemmo Nieminen fa57295623 Fix a stack trace caused by environment variables in test setups.
An example trace:

[snip]
>   File "/usr/lib/python3.6/concurrent/futures/thread.py", line 55, in run
>     result = self.fn(*self.args, **self.kwargs)
>   File "/home/trhd/Projects/meson/mesonbuild/mtest.py", line 221, in run_single_test
>     child_env.update(self.options.global_env.get_env(child_env))
> AttributeError: 'dict' object has no attribute 'get_env'
2017-09-01 01:07:20 +03:00
Daniel Stone e1ffae0580 Add Compiler.get_supported_arguments()
Add a helper for the common pattern of:
  args_to_use = []
  foreach arg : candidate_args
    if cc.has_argument(arg)
      args_to_use += arg
    endif
  endforeach

Replaced with:
  args_to_use = cc.get_supported_arguments(candidate_args)
2017-08-31 20:24:20 +01:00
Thibault Saunier 596c7106f7 interpreter: Make cs_args a known argument
Avoiding warning about it when it is a well known one.
2017-08-24 15:30:20 -03:00
Jon Turney 9607abbe0d Fix warning when executable(implib:) is used
PR #1955 added implib to known_exe_kwargs, but since PR #2001 it needs to be
in exe_kwargs as well, to avoid 'WARNING: Passed invalid keyword argument
"implib"' when it is used.
2017-08-18 12:09:40 +03:00