Commit Graph

292 Commits

Author SHA1 Message Date
Jussi Pakkanen ad3dc937f1 Fix remaining Interpreter object leaks. 2017-07-01 02:10:02 +03:00
Jussi Pakkanen c11a4cb952 Make Interpreter object unpicklable as it was being pickled by accident in copies of kwargs. 2017-07-01 00:11:27 +03:00
Aaron Plattner ba3871985a add_{project,global}_link_arguments require a 'language' argument
Commit 325a231a added stricter keyword argument checking, but didn't enable
keyword arguments for add_projects_link_arguments() and
add_global_link_arguments(). This makes them fail with this error:

 Meson encountered an error in file meson.build, line 19, column 0:
 Function does not take keyword arguments.

However, the language argument is required. Removing it produces this error
instead:

 Meson encountered an error in file meson.build, line 19, column 0:
 Missing language definition in add_project_link_arguments

Fix this by adding 'language' as a required keyword argument. Also add calls to
these in the "146 C and CPP link" test case.
2017-06-29 11:02:44 -04:00
Jussi Pakkanen 80ebc916f7 Merge pull request #2001 from mesonbuild/kwcheck
Decorator to check for unknown keyword arguments
2017-06-27 04:12:17 -04:00
Jussi Pakkanen 3262be23dc Fixed issues raised in review. 2017-06-26 23:29:42 +03:00
Guillaume Poirier-Morency fab5634916 Add 'Compiler.get_display_language'
Use this when we print language-related information to the console and
via the Ninja backend.
2017-06-26 14:15:44 -04:00
Jussi Pakkanen 50e75baa91 Removed in_builddir from public usage as it is an internal feature that was visible by accident. 2017-06-26 21:10:27 +03:00
Jussi Pakkanen fe74c54079 Alphabetization. 2017-06-26 21:10:27 +03:00
Jussi Pakkanen 97b7a7b10e Moved func_ methods from base class to Interpreter. 2017-06-26 21:10:27 +03:00
Jussi Pakkanen 325a231abe Add a few more. 2017-06-26 21:10:27 +03:00
Jussi Pakkanen f7da8dc84d A few more. 2017-06-26 21:10:27 +03:00
Jussi Pakkanen e08d735105 Added a few more kwarg checks to functions. 2017-06-26 21:10:27 +03:00
Jussi Pakkanen 0eb41a9a08 Checks for all build target functions. 2017-06-26 21:10:27 +03:00
Jussi Pakkanen 92493d4e5e Added kwargs for executable(). 2017-06-26 21:10:27 +03:00
Jussi Pakkanen 46e61971ce Decorator to check for permitted kwargs. 2017-06-26 21:10:27 +03:00
Jussi Pakkanen f792641b34 Merge pull request #1927 from centricular/gir-rpath-link
Work around GNU ld bug with -rpath,$ORIGIN
2017-06-11 14:54:10 +03:00
Nirbheek Chauhan d38f3deaed gnome: Work around GNU ld bug with -rpath,$ORIGIN
g-ir-scanner doesn't understand -rpath, so we use -L instead which
has the same effect.

Closes https://github.com/mesonbuild/meson/issues/1911
2017-06-11 14:32:39 +05:30
Nirbheek Chauhan 0c83f8352d dependencies: Add a new class ExternalDependency
This class now consolidates a lot of the logic that each external
dependency was duplicating in its class definition.

All external dependencies now set:

* self.version
* self.compile_args and self.link_args
* self.is_found (if found)
* self.sources
* etc

And the abstract ExternalDependency class defines the methods that
will fetch those properties. Some classes still override that for
various reasons, but those should also be migrated to properties as
far as possible.

Next step is to consolidate and standardize the way in which we call
'configuration binaries' such as sdl2-config, llvm-config, pkg-config,
etc. Currently each class has to duplicate code involved with that
even though the format is very similar.

Currently only pkg-config supports multiple version requirements, and
some classes don't even properly check the version requirement. That
will also become easier now.
2017-06-09 20:21:01 +05:30
Jan Chren (rindeal) bd52a5c5aa add `capture: true` ability to configure_file()
Closes: https://github.com/mesonbuild/meson/issues/1863
2017-06-07 23:46:34 +02:00
Bálint Aradi e79b602298 Enable variables for output in configure_file 2017-06-03 16:50:09 +02:00
Jussi Pakkanen 506fbafed5 Revert slashes in filenames being a hard error to give downstream projects time to transition. 2017-06-02 11:56:27 +03:00
Guillaume Poirier-Morency 93a1cff174 interpreter: Prevent top-level subdirectories from using 'meson-' prefix
These are reserved for internal usages like 'meson-private' or
'meson-logs'.
2017-05-29 19:42:03 +03:00
Jussi Pakkanen 7882549f86 Target file name must not contain a path separator as that breaks things. 2017-05-26 23:27:49 +03:00
Elliott Sales de Andrade 30645ed54b Remove extra casts on InterpreterBase.evaluate_statement.
The result of this method is always a "native" object, and code coverage
(plus a manual inspection) shows that this conversion is never done.
2017-05-17 19:43:39 -04:00
Elliott Sales de Andrade 1846eb3c77 Add super call in RunTargetHolder. 2017-05-17 19:43:23 -04:00
Elliott Sales de Andrade 34e4d32ac7 Remove dead code paths. 2017-05-17 19:43:23 -04:00
Elliott Sales de Andrade 00f89b0f6e Fix undefined variables/methods. 2017-05-17 19:43:14 -04:00
Nirbheek Chauhan 830b44867c dependencies: Only store found deps in the cache
This simplifies everything since it means we will always search for the
dependency again on the system if it wasn't found. This is particularly
important when running `ninja reconfigure` with an edited
PKG_CONFIG_PATH to point to a path that contains more pkg-config files.
2017-05-09 14:24:48 +05:30
Nirbheek Chauhan 66f0ccb39b dependencies: Fix two more edge-cases in dependency searching
Includes tests for both of them.
2017-05-09 14:24:48 +05:30
Nirbheek Chauhan 8cf29bd288 Completely overhaul caching of external dependencies
The old caching was a mess of spaghetti code layered over pasta code.

The new code is well-commented, is clear about what it's trying to do,
and uses a blacklist of keyword arguments instead of a whitelist while
generating identifiers for dep caching which makes it much more robust
for future changes.

The only side-effect of forgetting about a new keyword argument would
be that the dependency would not be cached unless the values of that
keyword arguments were the same in the cached and new dependency.

There are also more tests which identify scenarios that were broken
earlier.
2017-05-09 14:24:48 +05:30
Nirbheek Chauhan c650ba8928 interpreter: Typo in error message
'Non-existent' is the grammatically correct version. Also call it
a 'build file' since that's what everyone calls it nowadays.
2017-05-09 14:23:15 +05:30
Nirbheek Chauhan c7d71c7943 dependencies: Fix caching of native/cross dependencies
All our cached_dep magic was totally useless since we ended up using
the same identifier for native and cross deps. Just nuke all this
cached_dep code since it is very error-prone and improve the
identifier generation instead.

For instance, this is broken *right now* with the `type_name` kwarg.

Add a bunch of tests to ensure that all this actually works...

Closes https://github.com/mesonbuild/meson/issues/1736
2017-05-09 14:23:15 +05:30
Jussi Pakkanen e0cf45edf0 Merge pull request #1747 from centricular/run-command-configure-file
Some fixes to run_command()
2017-05-08 20:08:28 +02:00
Jussi Pakkanen 87666d105a Prevent going into the same directory twice via symlinks. Closes #1749. 2017-05-08 20:58:10 +03:00
Nirbheek Chauhan 333085160d run_command: Refactor + improve errors and test
Refactor to use ExternalProgram for the command instead of duplicating
that code (badly). Also improve messages to say "or not executable"
when a script/command is not found.

Also allow ExternalPrograms to be passed as arguments to
run_command(). The only thing we're doing by preventing that is
forcing people to use prog.path()
2017-05-07 01:56:47 +05:30
Nirbheek Chauhan b1df1a2bec run_command: accept built File objects too
The file will always exist by the time run_command() is invoked, so
there is no reason why we should forbid it. Also allow using File
objects as the command to run since strings are also allowed.
2017-05-07 00:20:29 +05:30
Peter Hutterer 7a3be163cb Default to project_version() in vcs_tag fallback 2017-05-05 08:11:28 +10:00
Peter Hutterer 4413122676 Check for input and output to exist in vcs_tag
Provide a proper error message, rather than the current
"Command cannot have '@INPUT0@', since no input files were specified"
which doesn't actually tell us where things are going wrong.
2017-05-05 08:11:04 +10:00
Jussi Pakkanen 108dac5c16 Store extra_files as file objects. Helps with #1686. 2017-05-04 00:17:33 +03:00
Dylan Baker a8173630ea Don't use len() to test emptiness vs not emptiness
Meson has a common pattern of using 'if len(foo) == 0:' or
'if len(foo) != 0:', however, this is a common anti-pattern in python.
Instead tests for emptiness/non-emptiness should be done with a simple
'if foo:' or 'if not foo:'

Consider the following:
>>> import timeit
>>> timeit.timeit('if len([]) == 0: pass')
0.10730923599840025
>>> timeit.timeit('if not []: pass')
0.030033907998586074
>>> timeit.timeit('if len(['a', 'b', 'c', 'd']) == 0: pass')
0.1154778649979562
>>> timeit.timeit("if not ['a', 'b', 'c', 'd']: pass")
0.08259823200205574
>>> timeit.timeit('if len("") == 0: pass')
0.089759664999292
>>> timeit.timeit('if not "": pass')
0.02340641999762738
>>> timeit.timeit('if len("foo") == 0: pass')
0.08848102600313723
>>> timeit.timeit('if not "foo": pass')
0.04032287199879647

And for the one additional case of 'if len(foo.strip()) == 0', which can
be replaced with 'if not foo.isspace()'
>>> timeit.timeit('if len("   ".strip()) == 0: pass')
0.15294511600222904
>>> timeit.timeit('if "   ".isspace(): pass')
0.09413968399894657
>>> timeit.timeit('if len("   abc".strip()) == 0: pass')
0.2023209120015963
>>> timeit.timeit('if "   abc".isspace(): pass')
0.09571301700270851

In other words, it's always a win to not use len(), when you don't
actually want to check the length.
2017-05-02 21:57:26 +03:00
Nirbheek Chauhan 0ebf79ec8b configure_file: Accept output of configure_file as input 2017-04-22 00:21:25 +05:30
Nirbheek Chauhan 723884a369 Expose the implementation language for external libraries
Ideally, all dependency objects should support this, but it's a lot of
work and isn't supported by all dependency types (like frameworks and
pkg-config), so for now just enable it for external libraries.
2017-04-21 10:15:18 -07:00
Matthias Klumpp 407130a1d2 Don't fail include_directories if the dir is only in the build path 2017-04-20 18:45:33 +03:00
Elliott Sales de Andrade a57f441b37 Raise clear error if module name doesn't exist.
Don't raise a full backtrace.
2017-04-17 12:43:57 +03:00
Jussi Pakkanen b48daeda1a Make it possible to only do unity builds on subprojects. 2017-04-15 18:28:36 +03:00
Nirbheek Chauhan 371e3d3e87 install scripts: Actually check if it was found
Closes https://github.com/mesonbuild/meson/issues/1600
2017-04-11 16:39:24 +03:00
Jussi Pakkanen 1652dccea2 Merge pull request #1469 from centricular/install-secondary-outputs
Support multiple install dirs for built/custom targets
2017-04-09 21:57:46 +03:00
Jussi Pakkanen 761b28371a Merge pull request #1518 from centricular/mesonintrospect-evar
Export MESONINTROSPECT to postconf/install/run_command scripts
2017-04-08 21:25:25 +03:00
Philipp Ittershagen a00ab548eb add_project_arguments: allow call after subproject()
This commit fixes #1554 by removing the restriction of add_project_arguments()
to be called before any subproject() statement.
2017-04-07 21:07:57 +02:00
Philipp Ittershagen 69d07fe75a add_{project,global}_arguments: support language list
This patch adds support for specifying a list of languages when calling
add_project_arguments and add_global_arguments.
2017-04-06 23:49:26 +02:00