Commit Graph

459 Commits

Author SHA1 Message Date
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
Emmanuele Bassi 00e5962aaa Add support to integer modulo operator
Having support for the '%' operator makes it easier to implement
even/odd version checks, like:

    enable_debug = get_option('enable-debug')
    if enable_debug == 'auto'
      if minor_version % 2 == 0
        enable_debug = 'minimum'
      else
        enable_debug = 'yes'
      endif
    endif

which would be impossible without resorting to less obvious long-hand
forms like:

  a - (b * (a / b))
2016-09-02 18:52:45 +01:00
Jussi Pakkanen cdf0c4f1a9 Merge branch 'QuLogic-context-managers' 2016-09-01 23:12:06 +03:00
Saunier Thibault e411c0b930 Honor dependency `fallback` argument even if the dependency is not required (#735)
You can potentially have a fallback subproject and if that subproject
fails, you can continue without that dependency
2016-08-29 22:31:10 +03:00
Elliott Sales de Andrade 4c71695e41 Use context manager for file I/O.
There are a few cases where a context manager cannot be used, such as
the logger.
2016-08-27 18:29:55 -04:00
Nirbheek Chauhan 7830cb61c3 Add a new compiler object method: has_members (#723)
* Add a new compiler object method: has_members

Identical to 'cc.has_member', except that this takes multiple members
and all of them must exist else it returns false.

This is useful when you want to verify that a structure has all of
a given set of fields. Individually checking each member is horrifying.

* Fix typo in exceptions for has_member(s)
2016-08-27 17:26:23 +03:00
Elliott Sales de Andrade a2321b24f6 Flatten isinstance calls. (#715)
That is, isinstance(x, y) or isinstance(x, z) can be flattened with a
tuple to isinstance(x, (y, z)).
2016-08-27 15:47:29 +03:00
Matthias Klumpp 309f7a1b4a interpreter: Rename get_unittest_flag() to unittest_args() 2016-08-21 01:41:14 +02:00
Matthias Klumpp 57c54a678c Allow build definitions to retrieve the unittest flag of a D compiler
D allows programmers to define their tests alongside the actual code in
a unittest scope[1].
When compiled with a special flag, the compiler will build a binary
containing the tests instead of the actual application.

This is a strightforward and easy way to run tests and works well with
Mesons test() command.

Since using just one flag name to enable unittest mode would be too
boring, compiler developers invented multiple ones.

Adding this helper method makes it easy for people writing Meson build
descriptions for D projects to enable unittestmode.

[1]: https://dlang.org/spec/unittest.html
2016-08-20 18:48:28 +02:00
Matthias Klumpp 56823272ab Implement D support
This patch adds support for the D programming language[1] to Meson.

The following compilers are supported:
* LDC
* GDC
* DMD

[1]: http://dlang.org/
2016-08-19 03:02:51 +02:00
Nirbheek Chauhan a5e01fa155 Only append compile flags to the link flags when appropriate
We should only append the compiler flags to the link flags when the
compiler is used as a wrapper around the linker during the link process
2016-08-12 15:34:59 +05:30
Jussi Pakkanen 657f357fc6 Merge pull request #605 from mesonbuild/ternary
Added ternary operator support
2016-08-01 21:08:04 +03:00
Jussi Pakkanen d90fcb4048 Created ternary operator. Closes #538. 2016-08-01 20:46:40 +03:00
Nirbheek Chauhan 58ad092ff3 interpreter: Print what subproject dir could not be found
Fixes #655
2016-08-01 09:34:30 +05:30
Jussi Pakkanen 4a92b78e6e A few error message fixes. 2016-07-28 20:45:38 +03:00
Nirbheek Chauhan 1459d18643 dependency: Better errors when fallbacks are not found
Otherwise the message is very cryptic and no one can figure out what Meson
actually wants
2016-07-28 21:45:47 +05:30
Nirbheek Chauhan 88aafd363e Normalize the path of a configured file to avoid dupes (#640) 2016-07-19 20:10:57 +03:00
Nirbheek Chauhan 7217620e23 interpretor: Use the stdout/stderr locale to decode to string (#638)
Fixes a decode error with locales other than en_US on Windows
2016-07-15 20:37:21 +03:00
Jussi Pakkanen c0057da133 Can get arbitrary data from cross file properties. 2016-07-02 00:00:03 +03:00
Jussi Pakkanen 0733c0f9a1 Changed run_target to take command as kwarg and add depends. This makes it behave the same as custom_target. 2016-06-24 23:07:57 +03:00
Jussi Pakkanen ea4fe8e417 Run_target can run binaries obtained with find_program. 2016-06-24 15:02:43 +03:00
Nirbheek Chauhan fe52feb47d dependency: Fix version check for a not-found dependency
The check was wrong, and we were passing 'none' as the 'found' version
to the version compare if the cached dep was a not-found dependency
2016-06-21 08:40:48 +05:30
Nirbheek Chauhan 9e5a2c5e26 Use add_target() for adding targets returned from module functions
Without this, the target isn't added to self.coredata.target_guids and
the VS backends fail to parse the list of targets
2016-06-17 16:46:57 +05:30
Nirbheek Chauhan abf81aab77 Use cross-info c_args, c_link_args, etc for all compiler checks
This allows the user to specify custom arguments to the compiler to be used
while performing cross-compiler checks. For example, passing a GCC specs file as
c_link_args so that a "prefix" filled with libraries that are to be compiled
against can be found with cc.find_library, or an `-mcpu` c_arg that is required
for compilation.

Also ensure that unix_link_flags_to_native() and unix_compile_flags_to_native()
always return a copy of the original arguments and not a reference to the
original arguments. We never want to modify the original arguments.
2016-06-15 13:13:06 +05:30
Martin Hostettler 4979b4c84f compiler: Use cross tools args in sanity check. 2016-06-13 00:41:19 +02:00
Jussi Pakkanen beef7cb291 Added functionality to pick the first supported argument from a list. Closes #583. 2016-06-09 21:36:58 +03:00
Jussi Pakkanen d8d989d9b8 Add a has_arg method to compiler to check whether it supports a given argument. 2016-06-09 21:19:58 +03:00
Jussi Pakkanen bcec44b93b Merge pull request #573 from centricular/dependency-versions
Several fixes to how versioned dependencies are handled + tests
2016-06-05 13:51:03 +03:00
Jussi Pakkanen 177e286b3c Can generate config headers without an input file. Closes #549. 2016-06-01 20:25:14 +03:00
Jussi Pakkanen 144565fabf Added method to get current project name. 2016-05-30 20:29:35 +03:00
Nirbheek Chauhan 8c34ea645d interpreter: Compare the version of a cached dependency() before using it
Without this, checks with incompatible versions but the same library would
return true. Example:

dependency('zlib', version : '>=1.2')
dependency('zlib', version : '<1.0') # this will return the same dep again!

Example: https://github.com/mesonbuild/meson/issues/568
2016-05-30 03:40:30 +05:30
Nirbheek Chauhan 0096c51035 interpretor: Correctly check the version of a fallback dependency
Previously the check was always done with the project version--which is wrong.
It should always check against the version of the dependency requested.
2016-05-30 03:40:18 +05:30
Nirbheek Chauhan acdd4bd523 interpreter: Set declare_dependency version from the project version if missing
This simply sets the default version to be the same as the project version.
Useful for dependency version checks when using fallback subproject internal
dependencies.
2016-05-30 03:40:08 +05:30
Nirbheek Chauhan c33e7a68a1 Also reuse subproject-based fallback dependencies
This allows a project to use the same fallbacks dependency from the same
subproject multiple times in the same way that external dependencies can be.

Also change the format of the dependency identifier to ensure that fallback
checks with different dirname/varname aren't mistakenly reused. We now use
a tuple for this because the format is simpler to construct and it gives us the
same immutability guarantees as a string which is needed for using it as
a dictionary key.
2016-05-30 03:35:02 +05:30
Nirbheek Chauhan f2256ba098 interpreter: Check if subproject version is defined before comparing
Without this Meson gives a cryptic error emitted from inside
mesonlib.version_compare()
2016-05-30 03:35:02 +05:30
Jussi Pakkanen 0b81f5b0ad Merge pull request #569 from mesonbuild/cargs
Renamed compile&link args and made them accessible from get_option.
2016-05-29 23:46:14 +03:00
Nirbheek Chauhan 065dcee7f3 interpreter: Switch to prev_subdir on non-existant subdir (#571) 2016-05-29 13:24:51 +03:00
Jussi Pakkanen cff4e7d299 Can query version strings of dependencies. 2016-05-29 03:15:16 +03:00
Jussi Pakkanen b5013a573a Added semantic versioning comparison method to strings. 2016-05-29 02:59:24 +03:00
Jussi Pakkanen 28b555d2c8 Whitespace fix to test new Docker setup. 2016-05-28 22:17:57 +03:00
Jussi Pakkanen 7694321276 Renamed compile&link args and made them accessible from get_option. 2016-05-28 21:56:41 +03:00
Jussi Pakkanen 4377f773e0 Can set global linker arguments. Closes #536. 2016-05-28 21:31:59 +03:00
Jussi Pakkanen ac152a2282 Every target must have a non-empty name. 2016-05-28 13:59:39 +03:00
Jussi Pakkanen c320b08ffb Merge gettextarg branch. 2016-05-26 21:58:34 +03:00
Jussi Pakkanen 3b3c05f6b1 Can pass extra args to xgettext. Closes #554. 2016-05-26 01:09:37 +03:00
Jussi Pakkanen df03f849a8 Merge pull request #542 from mesonbuild/ownstdlib
Build transparently with a custom standard library
2016-05-25 23:44:24 +03:00
Jussi Pakkanen df90b26533 Merge pull request #548 from centricular/fix_has_exe_wrap
interpreter: Fix typo in has_exe_wrapper
2016-05-25 23:41:38 +03:00
Jussi Pakkanen babdb27570 Merge pull request #479 from mesonbuild/i18n
Moved gettext into i18n module.
2016-05-25 17:53:35 +03:00
Jussi Pakkanen 2a3a1ce8e0 Join() convenience method for strings. Closes #552. 2016-05-24 23:06:20 +03:00
Nirbheek Chauhan 7aad3ff658 interpretor: Fix typo in has_exe_wrapper
The function wasn't working at all because of this
2016-05-24 14:31:39 +05:30
Jussi Pakkanen afe7252476 Can specify a stdlib subproject that is used implicitly on all targets with said language. 2016-05-21 21:46:03 +03:00
Jussi Pakkanen dc148e0702 Remove all special casing for gettext and use elementary operations instead. 2016-05-21 18:21:23 +03:00
Hemmo Nieminen 7da51f3756 Do not append a period to test suite names. 2016-05-10 20:58:39 +03:00
Nirbheek Chauhan 2bdaa1f0c1 Separate out cpu_method to environment.py and add amd64 quirk 2016-04-15 00:25:35 +05:30
Nirbheek Chauhan c0765b0e8d Don't require an exe_wrapper when cross-compiling 32-bit on 64-bit
Almost all 64-bit x86 OSes can run 32-bit x86 binaries natively. Detect
that case and don't require an exe wrapper.
2016-04-15 00:25:34 +05:30
Nirbheek Chauhan 700010e452 New API: cc.has_header_symbol to check if a header defines a specific symbol
Also supports a 'prefix' keyword argument for feature checks such as _GNU_SOURCE
or for headers that need to be included first
2016-04-07 20:53:12 +05:30
Jussi Pakkanen cab5ce4fc0 Merge pull request #438 from trhd/testing_options
New options for controlling test output.
2016-04-06 23:10:20 +03:00
Jussi Pakkanen 737fde65fa Bring back the old manual search to cc.find_library. 2016-04-04 22:18:14 +03:00
Hemmo Nieminen af6f4c9b9c coredata: Centralize builtin option descriptions and definitions. 2016-04-04 02:52:30 +03:00
Hemmo Nieminen 336904b553 Move MesonException from coredata to mesonlib. 2016-04-01 00:52:45 +03:00
Jussi Pakkanen 12a4e7d7e7 Moved gettext into i18n module. 2016-03-28 20:15:16 +03:00
Jussi Pakkanen d87eb7d290 Merge branch 'base_options'. 2016-03-20 22:04:24 +02:00
Jussi Pakkanen 8b619420f9 Open Meson and option files explicitly as utf-8. Closes #467. 2016-03-20 21:21:23 +02:00
Jussi Pakkanen a405f7a499 Grab base options from the command line. 2016-03-20 20:43:32 +02:00
Jussi Pakkanen 4bb665a577 Merge pull request #464 from tp-m/bool-to-string-and-to-int
Add bool to_string() and to_int() methods.
2016-03-20 18:53:01 +02:00
Tim-Philipp Müller 3eea1703ff Add bool to_string() and to_int() methods
bool to_int() will return 0 or 1, useful if one wants to set
a define to 0 or 1 based on a boolean result instead of having
it just defined or undefined.

bool to_string() will return 'true' or 'false' by default same
as when using it to format a string, but with the additional
possibility to specify two extra string arguments to be returned
as true/false values, e.g. to_string('yes', 'no'). This can be
useful when outputting messages to be shown to the user.
2016-03-19 17:57:11 +00:00
Tim-Philipp Müller fcbd60c291 Add += support for strings and integers 2016-03-19 17:11:53 +00:00
Jussi Pakkanen 8b6848ebc3 Add dir support for find_library and remove deprecated standalone version. Closes #450. 2016-03-17 20:55:19 +02:00
Jussi Pakkanen 19046fd854 Added new base options and some sample opts for gcc. 2016-03-16 21:55:03 +02:00
Jussi Pakkanen 6b548a1c75 Added find_library method and deprecated the standalone version. Closes #396. 2016-03-12 17:00:55 +02:00
Tim-Philipp Müller 3c8468cd4d Add string underscorify() function
So we can easily construct the defines for include headers and
struct checks and such.
2016-03-12 14:15:54 +00:00
Tim-Philipp Müller 02e84df010 Add more string functions: contains(), to_upper() and to_lower() 2016-03-12 14:15:31 +00:00
Nicolas Schneider 5e1fdb8b97 use positional instead of keyword args for add_postconf_script 2016-03-02 21:32:50 +01:00
Nicolas Schneider 9f9f73fa52 add args support for add_postconf_script 2016-03-01 14:31:37 +01:00
Nicolas Schneider 92187501ed Can add postconfigure script. 2016-03-01 14:07:38 +01:00