Commit Graph

633 Commits

Author SHA1 Message Date
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
Jussi Pakkanen 50fb7d37ab Make all functionality invokable via the main Meson binary,
which can be a Windows .exe file.
2017-08-18 12:08:20 +03:00
Jussi Pakkanen 33c2bbc6e8 Merge pull request #2191 from centricular/fix-ninja-clean-target-dir
Fix ninja clean in some edge cases + a bonus windows fix
2017-08-15 00:39:49 +03:00
Nirbheek Chauhan be4428005d ninja: Fix cleaning in various edge cases
We need to use target aliases for reserved target names and run
targets to workaround a ninja bug:

https://github.com/ninja-build/ninja/issues/828

Closes https://github.com/mesonbuild/meson/issues/1644
2017-08-15 01:38:01 +05:30
Jussi Pakkanen 4a766147fb Printing unknown kwarg error message no longer crashes the parser. 2017-08-14 22:32:29 +03:00
Elliott Sales de Andrade 5cb1d00537 Allow excluding files from `install_subdir`
The install_subdir command now accepts a new `exclude` keyword argument
that allows specified files to be excluded from the installed
subdirectory.
2017-08-06 03:58:35 -04:00
Jussi Pakkanen 61a05f26e3 Add option to disable implicit include directories. Closes #2139. 2017-08-05 00:26:13 +03:00
Jussi Pakkanen d335a84b9e A few more lgtm fixes. 2017-08-04 12:54:31 +03:00
Patrick Griffis ece4ce8872 Fix test() accepting configure files for exe 2017-07-31 18:48:30 -04:00
Jussi Pakkanen a572ebd2a1 Convert man inputs to Files so you can install_man the output of configure_file. Closes #2135. 2017-07-31 18:47:09 -04:00
Jussi Pakkanen bff37a90fc Merged buildrpath branch. 2017-07-21 22:19:07 +03:00
Christoph Reiter ceea746222 configure_file: warn in case a variable to subsitute is not present in the passed configuration. Fixes #2090 2017-07-21 20:11:50 +03:00
Jussi Pakkanen 2269b7f60b Add build_rpath as new property allowing people to specify rpath entries that are used in the build tree but will be removed on install. 2017-07-21 19:40:54 +03:00
Jussi Pakkanen fc23d9d0f2 Turned SIMD into an unstable module. 2017-07-18 21:53:24 +03:00
Jussi Pakkanen f78cf53141 Created merge_from method for ConfigurationData. 2017-07-17 19:20:00 +03:00
Jussi Pakkanen fff3ded297 Removed unreachable code as == never throws. 2017-07-16 12:27:51 +03:00
Jussi Pakkanen b2a90f1838 Removed unnecessary pass statements. 2017-07-16 12:02:48 +03:00
Jussi Pakkanen 76d6fab8ae Simplified control flow. 2017-07-16 12:00:04 +03:00
Gabríel Arthúr Pétursson fd653d070d Make base options accessible via get_option() 2017-07-15 10:21:41 +02:00
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
Philipp Ittershagen dd9f75e188 Refactor function_add_{global,project}_{link_,}arguments common code 2017-04-06 23:30:31 +02:00
Jussi Pakkanen b42adc8a54 Merge pull request #1511 from centricular/get-define
New compiler function: cc.get_define()
2017-04-05 00:02:41 +03:00
Nirbheek Chauhan 41769d0c10 Prohibit ':' in project names
This would make it harder to parse an option to mesonconf such
as -Dfoo:bar:baz:fun=value since it could mean either of these:

* For subproject 'foo:bar:baz', set the option 'fun' to 'value'
* For subproject 'foo:bar', an invalid option 'baz:fun' was set

To differentiate between these two we'd need to create the list of
subprojects first and then parse their options later, which
complicates the parsing quite a bit.
2017-04-05 01:30:34 +05:30
Nirbheek Chauhan 6042e21e25 Use CPPFLAGS for pre-processor compiler checks
Also don't add CFLAGS twice for links() checks

Includes a test for this.
2017-04-04 23:38:36 +05:30
Nirbheek Chauhan de47541e6c New compiler function: cc.get_define()
Runs the pre-processor and fetches the value of the define.

Can find any arbitrary value and returns it as a string.
2017-04-04 22:30:13 +05:30
Nirbheek Chauhan 57cb1f9aad Support multiple install dirs for built/custom targets
You can now pass a list of strings to the install_dir: kwarg to
build_target and custom_target.

Custom Targets:
===============
Allows you to specify the installation directory for each
corresponding output. For example:

    custom_target('different-install-dirs',
      output : ['first.file', 'second.file'],
      ...
      install : true,
      install_dir : ['somedir', 'otherdir])

This would install first.file to somedir and second.file to otherdir.

If only one install_dir is provided, all outputs are installed there
(same behaviour as before).

To only install some outputs, pass `false` for the outputs that you
don't want installed. For example:

    custom_target('only-install-second',
      output : ['first.file', 'second.file'],
      ...
      install : true,
      install_dir : [false, 'otherdir])

This would install second.file to otherdir and not install first.file.

Build Targets:
==============
With build_target() (which includes executable(), library(), etc),
usually there is only one primary output. However some types of
targets have multiple outputs.

For example, while generating Vala libraries, valac also generates
a header and a .vapi file both of which often need to be installed.
This allows you to specify installation directories for those too.

    # This will only install the library (same as before)
    shared_library('somevalalib', 'somesource.vala',
      ...
      install : true)

    # This will install the library, the header, and the vapi into the
    # respective directories
    shared_library('somevalalib', 'somesource.vala',
      ...
      install : true,
      install_dir : ['libdir', 'incdir', 'vapidir'])

    # This will install the library into the default libdir and
    # everything else into the specified directories
    shared_library('somevalalib', 'somesource.vala',
      ...
      install : true,
      install_dir : [true, 'incdir', 'vapidir'])

    # This will NOT install the library, and will install everything
    # else into the specified directories
    shared_library('somevalalib', 'somesource.vala',
      ...
      install : true,
      install_dir : [false, 'incdir', 'vapidir'])

true/false can also be used for secondary outputs in the same way.

Valac can also generate a GIR file for libraries when the `vala_gir:`
keyword argument is passed to library(). In that case, `install_dir:`
must be given a list with four elements, one for each output.

Includes tests for all these.

Closes https://github.com/mesonbuild/meson/issues/705
Closes https://github.com/mesonbuild/meson/issues/891
Closes https://github.com/mesonbuild/meson/issues/892
Closes https://github.com/mesonbuild/meson/issues/1178
Closes https://github.com/mesonbuild/meson/issues/1193
2017-04-04 14:59:13 +05:30
Philipp Ittershagen adebed8ec8 Enable File() objects as an input parameter to configure_file
The configure_file command raised an exception when an input was specified as a
File, because os.path.join does not take File objects directly.  This patch
converts a File object to a string and adjusts the subsequent os.path.join
calls.
2017-04-03 21:09:31 +02:00
Jussi Pakkanen c7f66c3a9e Merge pull request #1505 from centricular/dont-use-c++-for-assembly
Try harder to use the C compiler for compiling asm
2017-04-02 00:15:22 +03:00
Tim-Philipp Müller 8cc89e468d configure_file: make input arg optional if command is used
Fixes #1476
2017-03-29 21:24:06 +03:00
Nirbheek Chauhan 27f5f0a963 Export MESONINTROSPECT to postconf/install/run_command scripts
Points to the `mesonintrospect.py` script corresponding to the
currently-running version of Meson.

Includes a test for all three methods of running scripts/commands.

Closes https://github.com/mesonbuild/meson/issues/1385
2017-03-28 00:55:01 +05:30
Nirbheek Chauhan 98e71e1e65 Allow not-required not-found dependencies in subprojects
Closes https://github.com/mesonbuild/meson/issues/1474
2017-03-27 22:02:06 +03:00
Nirbheek Chauhan 1ff0fccc29 Fix typo in dependency invalid arguments error 2017-03-27 18:35:24 +05:30
Nirbheek Chauhan 001cf52c3a Try even harder to use the C compiler for assembly
Now as long as you have a C compiler available in the project, it will
be used to compile assembly even if the target contains a C++ compiler
and even if the target contains only assembly and C++ sources.

Earlier, the order in which sources appeared in a target would decide
which compiler would be used.

However, if the project only provides a C++ compiler, that will be
used for compiling assembly sources.

If this breaks your use-case, please tell us.

Includes a test that ensures that all of the above is adhered to.
2017-03-27 14:40:34 +05:30
Nirbheek Chauhan ee3010e767 Don't require a language/compiler for configuring
Not really needed for projects that don't compile anything.

Closes https://github.com/mesonbuild/meson/issues/1208
2017-03-27 11:25:22 +05:30
Nirbheek Chauhan 14d0f38158 Try harder to use the C compiler for compiling asm
Use an ordered dict for the compiler dictionary and sort it according
to a priority order: fortran, c, c++, etc.

This also ensures that builds are reproducible because it would be
a toss-up whether a C or a C++ compiler would be used based on the
order in which compilers.items() would return items.

Closes https://github.com/mesonbuild/meson/issues/1370
2017-03-27 11:25:22 +05:30
Tim-Philipp Müller 3bb3c9ce52 declare_dependency: flatten dependencies kwargs allowing [] as no-op dep
An empty / no-op dependency can be expressed as []. This works with
the dependencies kwarg in executable targets such as shared_library,
but now with declare_dependency, where it would error out with
"error: Dependencies must be external deps" because the deps are
not flattened in this case. This patch fixes that.

Fixes #1500
2017-03-25 20:30:15 +02:00
Nirbheek Chauhan d5975cc683 wrap: Implement special wrap modes for use by packagers
Special wrap modes:
  nofallback: Don't download wraps for dependency() fallbacks
  nodownload: Don't download wraps for all subproject() calls

Subprojects are used for two purposes:
1. To download and build dependencies by using .wrap files if they
   are not provided by the system. This is usually expressed via
   dependency(..., fallback: ...).
2. To download and build 'copylibs' which are meant to be used by
   copying into your project. This is always done with an explicit
   subproject() call.

--wrap-mode=nofallback will never do (1)
--wrap-mode=nodownload will do neither (1) nor (2)

If you are building from a release tarball, you should be able to
safely use 'nodownload' since upstream is expected to ship all
required sources with the tarball.

If you are building from a git repository, you will want to use
'nofallback' so that any 'copylib' wraps will be download as
subprojects.

Note that these options do not affect subprojects that are git
submodules since those are only usable in git repositories, and you
almost always want to download them.
2017-03-25 06:57:30 +05:30
Nirbheek Chauhan a60d688973 wrap: Initialize subprojects that are git submodules
This will benefit projects such as GNOME Recipes that prefer using
submodules over wraps because it's easier to maintain since git is
aware of it, and because it integrates with their existing
workflow. Without this, these projects have to manually initialize
the submodules which is completely unnecessary.

Closes https://github.com/mesonbuild/meson/issues/1449
2017-03-25 06:47:04 +05:30
Jussi Pakkanen df1480fe11 Merge pull request #1456 from ieei/compute_int
Add compute_int, fixes #435
2017-03-23 16:02:40 -04:00
Thibault Saunier 4739d8763c interpretter: Use a namedtuple for the ModuleState 2017-03-20 18:47:46 -04:00
Haakon Sporsheim c9fe3a3ad4 compiler: Ensure prefix and dependencies are used for alignment.
This is now similar to how prefix and dependencies are used in all
the other similar checks performed by the compiler.
2017-03-10 12:33:21 +01:00
Haakon Sporsheim 1e2c914b3c compiler: Fix compute_int and sizeof for cross compilation.
sizeof now uses compute_int which again binary searches for correct value.
2017-03-10 12:33:21 +01:00
Haakon Sporsheim 52f23f8c34 compiler: Add compute_int functionality.
Fixes #435
2017-03-09 14:31:38 +01:00
Jussi Pakkanen d6614ba811 Merge pull request #1402 from centricular/test-setup-fixes
Various fixes to how mesontest handles test setups.
2017-02-20 14:56:45 -05:00
Jussi Pakkanen 98af711ca6 Merge pull request #1403 from centricular/compile_resources
Make configure_file() great again
2017-02-20 14:27:06 -05:00
Nirbheek Chauhan cb0aa6a83a configure_file: Substitute @INPUT@/@OUTPUT@/etc in command
The same substitutions and rules as custom_target().

Also generally fix it to actually work when run in a subdir and with
anything other than absolute paths for input and output files.

We now also log a message when configuring files.

Includes tests for all this.
2017-02-20 23:32:04 +05:30
Nirbheek Chauhan af1b898cc5 configure_file: Don't allow both command and configuration kwargs 2017-02-20 23:32:03 +05:30
Nirbheek Chauhan d1bc5c3404 add_test_setup: Treat no env as empty env
Otherwise env is {} and we get a traceback trying to use the setup:

$ /home/cassidy/dev/meson/mesontest.py -C build --setup valgrind
ninja: Entering directory `/home/cassidy/dev/gst/master/gst-build/build'
ninja: no work to do.
Traceback (most recent call last):
  File "/home/cassidy/dev/meson/mesontest.py", line 579, in <module>
    sys.exit(run(sys.argv[1:]))
  File "/home/cassidy/dev/meson/mesontest.py", line 575, in run
    return th.doit()
  File "/home/cassidy/dev/meson/mesontest.py", line 337, in doit
    self.run_tests(tests)
  File "/home/cassidy/dev/meson/mesontest.py", line 485, in run_tests
    self.drain_futures(futures, logfile, jsonlogfile)
  File "/home/cassidy/dev/meson/mesontest.py", line 504, in drain_futures
    self.print_stats(numlen, tests, name, result.result(), i, logfile, jsonlogfile)
  File "/usr/lib64/python3.5/concurrent/futures/_base.py", line 398, in result
    return self.__get_result()
  File "/usr/lib64/python3.5/concurrent/futures/_base.py", line 357, in __get_result
    raise self._exception
  File "/usr/lib64/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/cassidy/dev/meson/mesontest.py", line 216, in run_single_test
    child_env.update(self.options.global_env.get_env(child_env))
AttributeError: 'dict' object has no attribute 'get_env'

There is no harm in doing this, and this is the simplest fix for this.

Closes https://github.com/mesonbuild/meson/issues/1371
2017-02-19 23:13:32 +05:30
Nirbheek Chauhan f1fe823763 Add repr() for EnvironmentVariables{,Holder}
Makes it easier to debug issues with it
2017-02-19 23:13:32 +05:30
Nirbheek Chauhan f23a4a8b27 run_command: Fix error message on incorrect argument
Be more descriptive so people know what they can do.
2017-02-19 03:53:21 +05:30
Nirbheek Chauhan 2478bb144d rpm: We no longer provide the full path to a library
Ever since we changed how we do library searching, the full path to the
library has not been available under `.fullpath`. This has been broken
for at least a year...
2017-02-19 03:50:43 +05:30
Nirbheek Chauhan 7e805a019a find_program: Fix implementation of .path()
And actually test that prog.path() works. The earlier test was just
running the command without checking if it succeeded.

Also make everything use prog.get_command() or get_path() instead of
accessing the internal member prog.fullpath directly.
2017-02-19 03:49:31 +05:30
Nirbheek Chauhan 280346da3a find_program: Support passing mesonlib.File objects
This means you can pass files() and the return value of configure_file()
to find_program() now.
2017-02-19 03:01:24 +05:30
Jussi Pakkanen 5ee92d5bb0 Prohibit absolute paths in subdir(). 2017-02-17 15:45:38 -05:00
Jussi Pakkanen 28353e10e1 Prohibit manually built paths that point in srcdir in include_directories and give information on what to use instead. 2017-02-17 15:42:53 -05:00
Jussi Pakkanen 87632fa51e Merge pull request #1368 from dimkr/subproject_defaults
Bug fix - KeyError on subproject without default options
2017-02-09 23:02:47 +02:00
Nirbheek Chauhan 781e69094a dependencies: Distinguish native/cross while caching
Closes https://github.com/mesonbuild/meson/issues/1366
2017-02-07 20:55:24 +02:00
Dima Krasner 65029f4114 Bug fix - KeyError on subproject without default options 2017-02-07 09:42:55 +02:00
Nirbheek Chauhan 7d6f628ed4 Support file perms for install_data and install_subdir
With the 'install_mode' kwarg, you can now specify the file and
directory permissions and the owner and the group to be used while
installing. You can pass either:

* A single string specifying just the permissions
* A list of strings with:
  - The first argument a string of permissions
  - The second argument a string specifying the owner or
    an int specifying the uid
  - The third argument a string specifying the group or
    an int specifying the gid

Specifying `false` as any of the arguments skips setting that one.

The format of the permissions kwarg is the same as the symbolic
notation used by ls -l with the first character that specifies 'd',
'-', 'c', etc for the file type omitted since that is always obvious
from the context.

Includes unit tests for the same. Sadly these only run on Linux right
now, but we want them to run on all platforms. We do set the mode in the
integration tests for all platforms but we don't check if they were
actually set correctly.
2017-01-24 00:20:51 +05:30
Mike Sinkovsky 969be1f679 cleanup: Remove redundant parentheses 2017-01-18 21:22:47 +02:00
Mike Sinkovsky 1d177fb127 cleanup: Unused local variables 2017-01-18 21:22:47 +02:00
Jussi Pakkanen 11f9425a5e Can use targets directly in test arguments. 2017-01-15 21:54:26 +02:00
Hemmo Nieminen b90956c2f2 mesontest: Improve test suite selection.
Suite option can now be given to specify in more detail which tests should
be run.
2017-01-12 22:17:12 +02:00
Mike Sinkovsky 5b626ab4cb style: [E1**] Indentation 2017-01-11 12:33:27 -05:00
Mike Sinkovsky 77515ee541 style: [E303] too many blank lines (2) 2017-01-11 12:33:27 -05:00
Mike Sinkovsky c8981bdd1b style: [E711] comparison to None should be 'if cond is None:' 2017-01-11 12:33:27 -05:00
Mike Sinkovsky e9a891fe25 style: [E502] the backslash is redundant between brackets 2017-01-11 12:33:27 -05:00
Jussi Pakkanen 6ac9a8e738 Add .find_python() method. Supersedes #777. 2017-01-09 21:23:18 +02:00
Jussi Pakkanen fbabe8ad85 There are two different kinds of extensions: modules that create new
objects directly and snippets that just call into interpreter methods.
2017-01-09 21:11:48 +02:00
Jussi Pakkanen 24221d71cc Created a Python 3 module for simpler building of Python extension modules. 2017-01-09 21:07:23 +02:00
Jussi Pakkanen 9cf0991a1d Merge pull request #1278 from mesonbuild/newmodules
Bring some order to modules
2017-01-09 14:03:15 -05:00
Jussi Pakkanen 340781c515 Fix Gnome module. 2017-01-09 20:04:52 +02:00
Jussi Pakkanen 00f62d0755 Can get values in ConfigurationData objects. 2017-01-06 14:01:45 -05:00
Jussi Pakkanen 570c9b150b Fix a few more modules. 2017-01-06 19:22:56 +02:00
Jussi Pakkanen de24fddbd1 Create a module return value object. 2017-01-04 21:01:06 +02:00
Jussi Pakkanen 55cdba635e Merge pull request #1260 from mesonbuild/subproj_defaults
Can set subproject option defaults from command line and master project
2017-01-03 16:03:18 -05:00
Mike Sinkovsky 079e43f70b fix 'unreachable code' warnings 2017-01-03 13:34:39 -05:00
Jussi Pakkanen b3d51abff2 Can put external programs to test suite exe wrappers directly. 2017-01-02 23:52:50 +02:00
Jussi Pakkanen 74f15263b6 Can set envvars in test setups. 2017-01-02 23:52:50 +02:00
Jussi Pakkanen ee8a6e6fc5 Can specify test setups and run them with mesontest. 2017-01-02 23:52:50 +02:00
Jussi Pakkanen d94f64ded1 Support default_options in dependency() fallbacks. 2017-01-02 18:58:05 +02:00
Igor Gnatenko 969dc7e995 style: fix E124 violations
E124: closing bracket does not match visual indentation

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2017-01-01 12:02:05 -05:00
Igor Gnatenko 116da33cdd style: fix E128 violations
E128: continuation line under-indented for visual indent

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2017-01-01 12:02:05 -05:00
Jussi Pakkanen b55235dfbd Fix space before :. 2016-12-31 16:28:15 +02:00
Jussi Pakkanen d716d53b32 Can override project option default values in subproject(). 2016-12-29 20:34:13 +02:00
Jussi Pakkanen 73042c7912 Can set project options (but not global options) in subproject default options. 2016-12-29 19:30:58 +02:00
Jussi Pakkanen f85c348b94 Move option file parsing to after the project() inputs have been decoded to access default options. 2016-12-29 18:36:34 +02:00
Jussi Pakkanen 775729eb59 Can specify include directories to compiler tests. 2016-12-23 20:47:39 +02:00
Elliott Sales de Andrade 18c38df875 Add Generator.process_files to reduce code duplication. 2016-12-22 17:08:32 +02:00
Jussi Pakkanen a2528a8816 Merge pull request #1233 from mesonbuild/wip/ignatenko/code-style
Trivial cleanups in code
2016-12-21 00:09:44 +02:00
Nirbheek Chauhan 589a56e78f Cache the scripts used for postconf and install phases
Cache the absolute dir that the script is searched in and the name of
the script. These are the only two things that change.

Update the test to test for both #1235 and the case when a script of the
same name is in a different directory (which also covers the subproject
case).

Closes #1235
2016-12-20 00:09:02 +02:00
Nirbheek Chauhan 9bc07a0941 Fix several more lint errors
Found by Igor Gnatenko

************* Module mesonbuild.interpreter
E:1232,33: No value for argument 'interp' in constructor call (no-value-for-parameter)
************* Module mesonbuild.dependencies
E: 68, 4: An attribute defined in mesonbuild.dependencies line 39 hides this method (method-hidden)
************* Module mesonbuild.environment
E: 26, 0: class already defined line 19 (function-redefined)
E: 68,18: Undefined variable 'InterpreterException' (undefined-variable)
E:641,39: Undefined variable 'want_cross' (undefined-variable)
E:850,94: Undefined variable 'varname' (undefined-variable)
E:854,94: Undefined variable 'varname' (undefined-variable)
E:860,102: Undefined variable 'varname' (undefined-variable)
E:863,94: Undefined variable 'varname' (undefined-variable)
************* Module mesonbuild.modules.gnome
E:438,26: Undefined variable 'compilers' (undefined-variable)
2016-12-20 00:07:00 +02:00
Igor Gnatenko 139e020ede tree-wide: use proper 'not in' notation
Let's be more pythonic and 'not is' seems really weird.

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-12-19 21:48:35 +01:00
Igor Gnatenko 28d4d57756 interpreter: remove duplicated dictionary key
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-12-19 18:33:52 +01:00
Igor Gnatenko 8268eb4959 tree-wide: remove unused imports
./setup.py:17:1: F401 'os' imported but unused
import os
^
./setup.py:37:1: F401 'stat.ST_MODE' imported but unused
from stat import ST_MODE
^
./run_tests.py:17:1: F401 'os' imported but unused
import subprocess, sys, os
^
./run_tests.py:18:1: F401 'shutil' imported but unused
import shutil
^
./run_unittests.py:23:1: F401 'mesonbuild.dependencies.Qt5Dependency' imported but unused
from mesonbuild.dependencies import PkgConfigDependency, Qt5Dependency
^
./mesonbuild/build.py:15:1: F401 '.coredata' imported but unused
from . import coredata
^
./mesonbuild/interpreter.py:32:1: F401 'subprocess' imported but unused
import os, sys, subprocess, shutil, uuid, re
^
./mesonbuild/interpreter.py:32:1: F401 're' imported but unused
import os, sys, subprocess, shutil, uuid, re
^
./mesonbuild/dependencies.py:23:1: F401 'subprocess' imported but unused
import os, stat, glob, subprocess, shutil
^
./mesonbuild/mesonlib.py:17:1: F401 'sys' imported but unused
import platform, subprocess, operator, os, shutil, re, sys
^
./mesonbuild/modules/qt5.py:15:1: F401 'subprocess' imported but unused
import os, subprocess
^
./mesonbuild/modules/pkgconfig.py:15:1: F401 '..coredata' imported but unused
from .. import coredata, build
^
./mesonbuild/scripts/scanbuild.py:15:1: F401 'sys' imported but unused
import sys, os
^
./mesonbuild/scripts/meson_exe.py:20:1: F401 'subprocess' imported but unused
import subprocess
^
./mesonbuild/scripts/meson_exe.py:22:1: F401 '..mesonlib.MesonException' imported but unused
from ..mesonlib import MesonException, Popen_safe
^
./mesonbuild/scripts/symbolextractor.py:23:1: F401 'subprocess' imported but unused
import os, sys, subprocess
^
./mesonbuild/scripts/symbolextractor.py:25:1: F401 '..mesonlib.MesonException' imported but unused
from ..mesonlib import MesonException, Popen_safe
^
./mesonbuild/scripts/meson_install.py:19:1: F401 '..mesonlib.MesonException' imported but unused
from ..mesonlib import MesonException, Popen_safe
^
./mesonbuild/scripts/yelphelper.py:15:1: F401 'sys' imported but unused
import sys, os
^
./mesonbuild/scripts/yelphelper.py:20:1: F401 '..mesonlib.MesonException' imported but unused
from ..mesonlib import MesonException
^
./mesonbuild/backend/vs2010backend.py:17:1: F401 're' imported but unused
import re
^
./test cases/vala/8 generated sources/src/copy_file.py:3:1: F401 'os' imported but unused
import os
^
./test cases/common/107 postconf/postconf.py:3:1: F401 'sys' imported but unused
import sys, os
^
./test cases/common/129 object only target/obj_generator.py:5:1: F401 'shutil' imported but unused
import sys, shutil, subprocess
^
./test cases/common/57 custom target chain/usetarget/subcomp.py:3:1: F401 'os' imported but unused
import sys, os
^
./test cases/common/95 dep fallback/subprojects/boblib/genbob.py:3:1: F401 'os' imported but unused
import os
^
./test cases/common/98 gen extra/srcgen.py:4:1: F401 'os' imported but unused
import os
^
./test cases/common/113 generatorcustom/gen.py:3:1: F401 'os' imported but unused
import sys, os
^
./test cases/common/113 generatorcustom/catter.py:3:1: F401 'os' imported but unused
import sys, os
^
./test cases/common/59 object generator/obj_generator.py:5:1: F401 'shutil' imported but unused
import sys, shutil, subprocess
^

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-12-19 18:19:35 +01:00
Igor Gnatenko 3b55f6de8c s/Nonexistant/Nonexistent/g
There is basically no such word in english, "nonexistant".
American people use "nonexistent" and British people used
to have "non-existent", but some time ago they did away with
the hyphens, so there is only one option really: "nonexistent".

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-12-18 18:32:17 +02:00
Nirbheek Chauhan c693bd9bb4 Allow passing arguments to install scripts
Closes #1213
2016-12-18 18:30:47 +02:00
Jussi Pakkanen b389f43060 Revert "Merge pull request #1145 from AlexandreFoley/wrap-fix"
This reverts commit 541dd92ef7, reversing
changes made to 155617e539.
2016-12-15 22:33:25 +02:00
Jussi Pakkanen de83e94b5a Merge pull request #1171 from centricular/fix-extracted-generated-prebuilt-object-targets-linking
Several fixes to how we handle objects in build targets
2016-12-13 12:22:11 +02:00
Jussi Pakkanen 07679f0330 Merge pull request #1184 from centricular/cc.prefixes_underscore
Add a new compiler function 'symbols_have_underscore_prefix'
2016-12-13 12:21:50 +02:00
Nirbheek Chauhan 7b3d00fee4 Use dict for self.build.compilers instead of list
Everywhere we use this object, we end up iterating over it and comparing
compiler.get_language() with something. Using a dict is the obvious
choice and simplifies a lot of code.
2016-12-13 09:20:34 +05:30
Nirbheek Chauhan 09f65b7a3c New compiler function 'symbols_have_underscore_prefix'
Check if the compiler prefixes an underscore to global symbols. This is
useful when linking to compiled assembly code, or other code that does
not have its C symbol mangling handled transparently by the compiler.

C symbol mangling is platform and architecture dependent, and a helper
function is needed to detect it. Eg: Windows 32-bit prefixes underscore,
but 64-bit does not. Linux does not prefix an underscore but OS X does.
2016-12-13 09:17:06 +05:30
Elliott Sales de Andrade ec47db6c0c Add Compiler.has_multi_arguments method.
It allows checking if a compiler supports a multi-argument option.
2016-12-12 23:34:03 +02:00
Nirbheek Chauhan 60716fcd6d Use universal_newlines=True for all Popen calls
Instead of adding it everywhere manually, create a wrapper called
mesonlib.Popen_safe and use that everywhere that we call an executable
and extract its output.

This will also allow us to tweak it to do more/different things if
needed for some locales and/or systems.

Closes #1079
2016-12-11 01:59:58 +02:00
Jussi Pakkanen f62f730821 Merge pull request #1126 from mesonbuild/sharedmodule
Support for shared modules
2016-12-07 21:49:16 +02:00
Jussi Pakkanen dc1f537fb3 Skip shared module test on VS because it fails for some reason nobody understands. 2016-12-07 00:30:28 +02:00
Nirbheek Chauhan b9a7c0cf39 misc: Use relative imports everywhere
Using 'mesonbuild' as the module can cause it to use the
system-installed module and can also break if we rename the directory,
so avoid that by always using relative imports.
2016-12-07 00:24:17 +05:30
Nirbheek Chauhan 7b8f41ce31 Compiler checks can only accept external dependencies
This is already how it should've been, but:

a) The test for this was wrong since Dependency is a base class for all
dependencies and isinstance on an InternalDependency will also be true
b) Internal dependencies can't ever be used here anyway because compiler
checks are always run at configure time and internal dependencies are
only built after that.
2016-12-07 00:08:16 +05:30
Jussi Pakkanen 541dd92ef7 Merge pull request #1145 from AlexandreFoley/wrap-fix
build regeneration can update wrap-git and wrap-hg in some cases.
2016-12-06 20:31:24 +02:00
Jussi Pakkanen b28da68faf Expose project information with mesonintrospect. Closes #1118. 2016-12-06 20:27:59 +02:00
Nirbheek Chauhan c7a2664cb7 Better error when passing invalid objects to install_header
This will print the object type when you pass a generated file to
install_header instead of printing an assert.
2016-12-06 20:27:33 +02:00
Jussi Pakkanen 228a9035af Merge pull request #1103 from mesonbuild/rewriter
Beginnings of a rewriter
2016-12-06 20:22:04 +02:00
Alexandre Foley 228adaa287 Wrap.py: Made it so using an already downloaded subproject is only for the wrap-file case. Git and Mercurial can update the repository if it the wrap is one.
Also did a bit of cleanup.
interpreter.py: There’s a catch all except clause at the line 1928, it didn’t give the user any information whatsoever about the exception it caught. Now it at least print it to the log as a warning.
2016-12-05 17:25:36 -05:00
Jussi Pakkanen 14ca7d602c Store subdir information for each node so we can remove files set in other subdirectories. 2016-12-04 18:28:25 +02:00
Nirbheek Chauhan e1c9d94708 Allow many version conditions for pkg-config deps
Sometimes we want to restrict the acceptable versions to a list of
versions, or a smallest-version + largest-version, or both. For
instance, GStreamer's opencv plugin is only compatible with
3.1.0 >= opencv >= 2.3.0
2016-12-03 21:46:20 +02:00
Jussi Pakkanen 6d84b9b646 Created new shared module build target type, and make sure -Wl,--no-undefined is not used when linking it. 2016-12-02 21:55:56 +02:00
Jussi Pakkanen 7e1b674704 Add both native and cross compiler options to option list. 2016-11-26 11:24:20 -05:00
Jussi Pakkanen 0250b2cce6 Can give many alternative names to find_program to simplify searching. 2016-11-20 16:54:19 -05:00
Jussi Pakkanen 8f41154827 Can specify headers to install with Files. 2016-11-20 16:52:45 -05:00
Jussi Pakkanen aa9668a2fc Merge pull request #730 from mesonbuild/newtest
New testing tool
2016-11-20 16:07:32 -05:00
Jussi Pakkanen c41805f012 Moved more stuff, can now parse all of common tests. 2016-11-19 22:11:20 +02:00
Jussi Pakkanen 7e8872236d Implement a bunch of functions. 2016-11-19 21:25:28 +02:00
Jussi Pakkanen 5b00c9b9c0 Dead code removal. 2016-11-19 19:34:49 +01:00
Jussi Pakkanen 7ed7219d9d Moved functions to base enough to get the base sample project parsed. 2016-11-19 20:18:30 +02:00
Jussi Pakkanen 0a31afd672 Embark on a journey to create a rewrite tool. 2016-11-19 19:48:12 +02:00
Jussi Pakkanen a01919976e Always specify installed data with a File object. Closes #858. 2016-11-18 17:37:35 -05:00
Jussi Pakkanen 951262d759 Removed Valgrind from core. 2016-11-18 22:04:29 +02:00
Jussi Pakkanen 621219ccb0 Removed duplicate log message for command running. Closes #1056. 2016-11-17 00:20:36 +02:00
Thibault Saunier 85a0cd7635 Add new add_project_[link]_args functions
Fixes 979
2016-11-12 17:34:06 -05:00
Nirbheek Chauhan 085650a1e3 vala: Implement valac.find_library
Move CCompiler.compile to Compiler.compile so that ValaCompiler can use
it. Also rewrite ValaCompiler.sanity_check to use it since it does
a simple compile check.

At the same time, it enhances ExternalLibrary to support arguments for
languages other than C-like.

Includes a test for this that links against zlib through Vala.

Closes #983
2016-11-12 13:56:17 -05:00
Jussi Pakkanen 1d9c40c9c3 Merge pull request #1027 from centricular/has-header-prefix
cc.has_header: Allow specifying a prefix for headers
2016-11-12 12:16:16 -05:00
Jussi Pakkanen 434bb03743 Merge pull request #997 from tp-m/copy-mutable-variables-on-assignment
Copy mutable variables on assignment (configuration_data and environment)
2016-11-12 11:35:57 -05:00
Nirbheek Chauhan aa5afba00b cc.has_header: Allow specifying a prefix for headers
Fixes #1026
2016-11-11 10:25:34 +05:30
alvarez86 87f07cdf3d Minor adjusts (#1001)
* contributing: Use should instead of thould

* interpreter: Use exist_ok parameter in subdir function

We explicitly depend on python 3.4 or newer, which means the exist_ok
parameter is available. Use it instead of a try with a pass on except.

* authors: Add my name at the end of authors file
2016-11-07 11:26:46 -08:00
Jussi Pakkanen 335d263315 Merge pull request #942 from mesonbuild/tingping/private-methods
Don't expose private module methods
2016-11-06 09:13:39 -08:00
Jussi Pakkanen f8bf37979b Merge pull request #993 from centricular/cached-dep-required-attr
dependency: Check that cached_dep has the 'required' attribute
2016-11-06 09:11:42 -08:00
Patrick Griffis 1811f83e2a Don't expose module functions prefixed with _
This is the common Python convention for private methods
so lets not expose these to build files as they are
implementation details and their behavior is undefined.
2016-11-06 00:01:36 -04:00
Tim-Philipp Müller 627d859809 interpreter: copy mutable variables on assignment
All assignments in meson should be by value, so mutable objects
(i.e. environment() and configuration_data()) should be copied
automatically on assignment.

Fixes #831.
2016-11-05 16:56:02 +00:00
Tim-Philipp Müller 5898fb094c Revert "interpreter: Add a way to copy and environment object"
This reverts commit fcaf319e49.

This should be done automatically on assignment, see #831
2016-11-05 12:10:25 +00:00
Nirbheek Chauhan fd260eac81 Don't ignore invalid code related to subproject calls
We should only silently return from a dependency() call if the error is
transient (old version, wrap failed to download etc), not if the
subproject invocation or dependency name are incorrect.

For instance, if you use a dependency(..., fallback : ...) call in
a meson.build not in the root directory, we would always ignore the
call instead of erroring out due to invalid usage.

We should consider categorising our exceptions in this manner elsewhere
too.
2016-11-05 03:17:27 +05:30
Nirbheek Chauhan 268f737612 dependency: Check that cached_dep has the 'required' attribute
Closes https://github.com/mesonbuild/meson/issues/992
2016-11-04 14:21:52 +05:30
Scott D Phillips 3650669874 Allow subproject declarations in subdirectories 2016-11-02 13:52:04 -07:00
Tim-Philipp Müller aeaccdc418 Fix dependency() ignoring required attribute when checked second or third time
If first checking for a dependency as not-required, and then later
checking for the same dependency again as required, we would not
error out saying the dependency is missing, but just silently
re-use the cached dependency object from the first check and then
likely fail at build time if the dependency is not actually there.

With test case.

Fixes #964.
2016-11-02 13:49:57 -07:00
Jussi Pakkanen 36a0d162cb Merge pull request #895 from mesonbuild/wip/tingping/gnome-vapi
gnome: Add generate_vapi function
2016-11-02 11:41:58 -07:00
Nirbheek Chauhan 3df75d696d Directly pass the compiler to get_args_from_envvars
Seems better to do this since the behaviour is compiler-specific. Would
be easier to extend this later too in case we want to do more
compiler-specific things.
2016-10-26 23:16:05 +05:30
Nirbheek Chauhan 70265c3782 Improve error when using the dependencies kwarg
The error message is misleading (talks about external dependencies), and
doesn't tell you what you need to do (use the output of
declare_dependency, dependency, or find_library). At the same time
rename add_external_deps to add_deps since it adds internal deps too.

Plus many more error message improvements all over the place.
2016-10-23 18:02:19 +05:30
Patrick Griffis bae7d7b3d7 gnome: Add generate_vapi() function
This allows C projects to generate vapi bindings from
gir files and returns a dependency that can be used by
Vala.
2016-10-21 02:23:54 -04:00
Nirbheek Chauhan 57ce7d4618 Add support for extracting objects in unity builds
Not only does extract_all_objects() now work properly again,
extract_objects() also works if you specify a subset of sources all of
which have been compiled into a single unified object.

So, for instance, this allows you to extract all the objects
corresponding to the C sources compiled into a target consisting of
C and C++ sources.
2016-10-21 08:00:39 +05:30
Jussi Pakkanen e908910187 Can query pkg-config variables from the system. Closes #726. 2016-10-19 22:36:34 +03:00
Jussi Pakkanen 24552819b4 Force dep versions into the version kwarg. 2016-10-19 01:03:29 +03:00
Scott D Phillips 08aeac22a9 Don't raise exception when a fallback dependency is not found
If a fallback dependency is not found just return None.  The
caller can then raise the exception it already has if
required=True, or just continue on if required=False.
2016-10-17 19:32:09 +03:00
Thibault Saunier 77b379f5cf Try using already setup fallback subprojects before using native dependency
In the case the main project set a subproject for a dependency another
subprojects uses, that other subproject should rather use the first
subproject rather that using native dependency.

For example in gst-all we set all GStreamer modules as subprojects
and, gst-plugins-base is set after gstreamer core, and
we want gst-plugins-base to always use GStreamer core from the subproject
and not the possibly avalaible native one.
2016-10-14 11:25:16 +02:00
Thibault Saunier fcaf319e49 interpreter: Add a way to copy and environment object
It is really usefull when you have common variables defined
for all tests and then need to set some extra ones for each test
2016-10-14 11:25:16 +02:00
Thibault Saunier 7e2390f355 interpreter: Add a type_name method to DependencyHolder
And remove the InternalDependencyHolder class.

In some cases we need to know the type of dependency we are
dealing with. For example in GStreamer if the dependency
is not an internal one, then we need to get some env var
from pkg-config to know where to find some plugins necessary
to run some tests.
2016-10-14 11:25:15 +02:00
Jussi Pakkanen 1efcea9617 Renamed path_join to join_paths. 2016-10-13 20:53:45 +03:00
Nirbheek Chauhan c3db008d82 custom_target: Clarify error message 2016-10-13 00:21:33 +03:00
Jussi Pakkanen 95a99682b0 Merge branch 'QuLogic-compiler-file-checks' 2016-10-12 23:26:30 +03:00
Jussi Pakkanen 60119753d6 Check contents of arguments inside project(). Closes #857. 2016-10-10 23:26:40 +03:00
Jussi Pakkanen 28df8b800e Add an option to select if static libraries are built with -fPIC. 2016-10-10 21:28:28 +03:00
Jussi Pakkanen c2b852c9b3 Created path_join function. 2016-10-10 19:44:28 +03:00
Nirbheek Chauhan 411d6c8bc4 intrp: Don't do custom AST parsing for project()
Reuse the standard evaluate_codeblock() parsing since it does proper
error handling, and also handles, for instance, lists in string
arguments (flatten), etc. properly.

We need to declare more variables in advance now, but that should be ok.
2016-10-07 23:32:46 +05:30
Jussi Pakkanen 295b67df51 Merge pull request #814 from centricular/heavy-cleanup-compilers-buildtargets
Heavy cleanup in compilers and BuildTarget
2016-09-30 15:30:57 -04:00
Elliott Sales de Andrade f2fed5052d Allow passing files to compile/link/run queries. 2016-09-29 04:44:01 -04:00
Matthew Waters 13e91ab499 Add dependency support to the checks using the compiler
It is extremely common to need to know within a given dependency if
a given header, symbol, member, function, etc exists that cannot be
determined from the version number alone.

Without passing dependency objects to the various compiler/linker
checks and with many libraries headers/libraries being located in
their own subdirs of the standard prefix, the check for the library
would not find the header/function/symbol/etc.

This commit allows passing dependency objects to the compiler checks so
that the test program can be compiled/linked/run with the necessary
compilation and/or linking flags for that library.
2016-09-26 20:25:17 +03:00
Nirbheek Chauhan ac8c8c2ba8 Treat 32-bit compiles on 64-bit Windows as native
It's a terrible user experience to force people building 32-bit
applications on 64-bit Windows to use a cross-info file when every other
tool treats it as a 'native' compilation -- it satisfies all the
requirements for a native compile.

This commit also fixes the platform detection on Windows which would
cause the 'native cpu' to be detected as 32-bit if you installed 32-bit
Python on 64-bit Windows, or if you were building with a 32-bit
toolchain on 64-bit Windows.

Doesn't support MinGW yet -- the next commits will add that since the
changes required for that are more involved.
2016-09-26 19:48:46 +05:30
Nirbheek Chauhan 6590b7221e intrp: Parse project() before the rest of the AST
We need the compiler and language information stored in it for
populating the BuildMachine() properties accurately. The next commits
add this.
2016-09-26 19:48:46 +05:30
Nirbheek Chauhan 9c6369c759 interpreter: Print an error if the fallback dependency variable is not found (#804) 2016-09-25 19:03:18 +03:00
Tim-Philipp Müller 3aebdb717a configuration_data: can pass descriptions to setters (#783)
Add support for passing a description to configuration data
setter methods via a 'description' kwarg. The description
string will be used when meson generates the entire configure
file without a template, autoconf-style.
2016-09-25 18:56:49 +03:00
Sam Thursfield 8784c35dde Give a helpful exception when target has no name (#816) 2016-09-25 18:50:55 +03:00
Thibault Saunier 89d3a18f65 Add a meson.version() method returning the version of meson in use (#792)
So user can activate/deactivate features based on it.
2016-09-25 18:49:36 +03:00
Thibault Saunier a2e7ebc575 Add a new 'environment' object to be used to build test environment (#781)
Allowing user to fine tune tests environment variables
2016-09-14 23:11:27 +03:00
Tim-Philipp Müller 09fdc7f815 configuration_data: add .set_quoted() convenience method to set quoted string
Quotes in the string will be escaped C-string style with \", but
nothing else will be escaped.
2016-09-13 23:44:33 +01:00
Jussi Pakkanen c970d656b1 All_args should always be a list. Closes #778. 2016-09-11 15:02:48 +03:00
Jussi Pakkanen 6f2b29e0f7 Can use files() in run_command. 2016-09-08 21:51:48 +03:00
Jussi Pakkanen 9235fd4ec1 Permit use of file objects in run targets. 2016-09-07 23:04:11 +03:00
Elliott Sales de Andrade b6ee5725c2 Fix option initialization for win32 cross-compile. (#762) 2016-09-07 21:42:16 +03:00
Jussi Pakkanen 165f8a913d Better error message when trying to use subprojects as dependencies. 2016-09-07 21:25:34 +03:00
Elliott Sales de Andrade a7cf241334 Fix validation of man page extension. (#749)
If the extension does not exist or is not a number, the error message is
not raised because the assumptions cause a different exception.
2016-09-03 00:00:58 +03:00
Emmanuele Bassi 2dd1ec6f8c Add is_even() and is_odd() integer methods
Convenience methods for modulo operations involving even and odd
numbers.
2016-09-02 18:52:45 +01:00