Commit Graph

142 Commits

Author SHA1 Message Date
Jon Turney 2a64ed855e Verify that failing tests are failing with an error, not a python exception
PR #2527 suggests "making failing tests more strict about failing
gracefully".

To achive this, make meson exit with distinct exit statuses for meson errors
and python exceptions, and check the exit status is as expected for failing
tests.

I can't see how to write a test for this, within the current framework.

You can test this change by reverting the fix (but not the test) from commit
1a159db8 and verifying that 'test cases/failing/66 string as link target'
fails.
2018-02-15 12:51:24 +00:00
Jon Turney c027bb2c42 Ensure any generation error appears in the logfile and thus in CI output
Since c2a5ac39, MesonApp.generate() closes the logfile before returning,
which means that when invoked by mesonmain.run(), any MesonException is not
logged there.

MesonApp.generate() does not appear to have any other users I can find.

This somewhat reduces the diagnostic value of the logfile.

This also interacts badly with running project tests in CI, as _run_tests
chooses to report the logfile contents, rather than stdout, for the
configure step, and it thus doesn't report any configure error which caused
a test failure.
2018-02-14 19:15:30 +02:00
Jon Turney 6a1a56ab57 Report warning/error locations in a format IDEs may already know how to parse
Examples:

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

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

Also:
Don't start 'red' markup until after the \n before an error
Unabsorb full-stop at end of warning with location from mlog.warning()
Update warning_location test
2018-01-30 06:48:22 +11:00
Jussi Pakkanen 3bea6eeae8 Removed duplicate if branch. 2018-01-18 19:39:22 +02:00
Jussi Pakkanen 0538009d30 Bump minimum supported Python from 3.4 to 3.5. 2018-01-04 21:29:02 +02:00
Jussi Pakkanen d2b68d31dd Added init command that creates a sample exe project. 2017-12-31 23:18:08 +02:00
Gabríel Arthúr Pétursson 2fc3fc8d67 Remember which Visual Studio backend was auto-detected
This fixes the REGEN build target since VSINSTALLDIR does not get set by
Visual Studio when building targets.

Fixes #2848.
2017-12-30 14:03:59 +00:00
Dylan Baker e1c9d2f53a mesonmain: Remove useless ternary
This ternary checks the value of a bool, and returns the same value.
2017-12-19 10:10:40 -08:00
Dylan Baker 8a1a866c68 Don't print traceback when options are invalid
Currently passing a bad combo or array option, providing a non-boolean
to a bool arg, or a host of other things can cause an traceback from a
MesonException, don't do that.

Fixes #2683
2017-11-28 21:41:06 +02:00
Jussi Pakkanen 105ea1e597 Make the full test suite runnable with an external command. 2017-11-20 23:14:45 +02:00
Jussi Pakkanen 5d51bc79c7 Replaced sys.executable use with the mesonlib equivalent. 2017-11-20 23:08:17 +02:00
Jussi Pakkanen a437cd1955 Add command to run Python scripts with the current interpreter. 2017-11-20 23:08:17 +02:00
Jussi Pakkanen 69bd87a716
Merge pull request #2511 from jon-turney/prefix-dependent-defaults
Make sysconfdir, localstatedir and sharedstatedir defaults depend on prefix
2017-11-13 21:14:59 +02:00
Eric Engestrom 5f7f5cdb05 Print correct command in help message
Taking mconf for instance:
before:
  $ meson configure --help
  usage: meson [-h] [-D SETS] [--clearcache] [directory [directory ...]]
after:
  $ meson configure --help
  usage: meson configure [-h] [-D SETS] [--clearcache] [directory [directory ...]]
2017-11-09 21:12:34 +02:00
Elliott Sales de Andrade 6715087598 Dump coredata earlier.
Unfortunately, `time.time` and file timestamps are not guaranteed to be
in sync and due to various kernel caches may be different enough to
cause rebuilds to fail [1]. This was masked by older ninja versions that
could not read sub-second timestamps.

[1] https://travis-ci.org/mesonbuild/meson/jobs/296797872
2017-11-06 20:56:53 +02:00
Jon Turney 24549dbed5 Make sysconfdir, localstatedir and sharedstatedir defaults depend on prefix
Rather than requiring a bit of boilerplate in every meson.build, which is
only documented in a comment in mesoncore.py, use sensible defaults for
sysconfdir, localstatedir and sharedstatedir depending on the prefix.

Fixes #1637

v2:
For clarity, give get_builtin_option_default() a noneIfSuppress argument,
rather than overloading prefix '' and None with special meanings.
2017-10-28 23:27:36 +01: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
Nirbheek Chauhan f04d141088 logging: Print location of log file on error
Similar to configure

Closes https://github.com/mesonbuild/meson/issues/2316
2017-09-14 18:29:30 +03:00
Chet Gurevitch e5e060a6b7 Update message for already configured builddir 2017-09-12 20:30:26 +03:00
Nirbheek Chauhan 6cf5cb5842 wrap-mode: Make the error output more useful
Now it errors out while displaying the possible options

See: https://bugs.python.org/issue25061 for native support
2017-09-07 19:05:38 +03:00
Jussi Pakkanen 511a370856 Merge pull request #2163 from chetgurevitch/master
Don't error if build directory is already configured and update instructions
2017-08-20 23:18:39 +03:00
Jussi Pakkanen c2a5ac3981 Ensure log file gets closed. 2017-08-18 12:08:50 +03:00
Chet Gurevitch 2da2c92698 Tell users about ninja rebuild and meson configure 2017-08-18 01:30:11 -07:00
Chet Gurevitch 0ec2e530e1 Don't error if build directory is already configured 2017-08-18 01:22:39 -07:00
Jussi Pakkanen 59a35c4c53 Print deprecation warnings on old style commands. 2017-08-02 22:01:13 +03:00
Jussi Pakkanen fa278f351f Add command multiplexer to main Meson invoker. 2017-08-02 22:00:09 +03:00
Elliott Sales de Andrade b52955ff3d Run postconf scripts after dumping coredata.
MESONINTROSPECT is set when running postconf scripts, which implies that
introspection is possible. But it isn't really possible because coredata
hasn't been written yet. We also still need to make sure to delete
coredata if any postconf scripts fail.
2017-07-15 13:47:17 +02:00
Nirbheek Chauhan 627190faf3 Add an env var to force meson to print a backtrace
This is really useful when debugging test failures. Without a stack
trace, you have to grep the source code for the error message.

Also set this in run_tests.py.
2017-06-09 20:21:01 +05:30
Alistair Thomas a195b78c8d Whitespace tweaks to reduce Flake8 warnings 2017-05-29 19:32:47 +03:00
Jussi Pakkanen 8d2fbf8084 Clarify multiple uses of -D. Closes #1836. 2017-05-26 23:22:56 +03:00
Jussi Pakkanen 111e3df45d Moved coverage commands to a standalone script. 2017-05-13 22:54:08 +03:00
Jussi Pakkanen 255be79e22 Created a dist target. Closes #877. 2017-05-11 19:34:16 +03:00
Jussi Pakkanen 0e3aa5a348 Merge pull request #1587 from mesonbuild/tingping/msgfmt-datadir
i18n: Improve data_dirs support
2017-05-03 18:51:55 +03:00
Jussi Pakkanen 9d69c934d6 Expand input paths so they do not contain symlinks. 2017-05-02 22:05:31 +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
Patrick Griffis 82492f5d76 i18n: Add data_dirs kwarg to merge_file()
For parity with gettext()

Fixes #1565
2017-04-29 04:05:20 -04:00
Jussi Pakkanen b48daeda1a Make it possible to only do unity builds on subprojects. 2017-04-15 18:28:36 +03:00
Jussi Pakkanen e4c224bdc1 Merge pull request #1516 from centricular/git-submodule-subprojects
Add support for using git submodules as subprojects
2017-03-25 18:24:38 +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
Nicolas Schneider 92ed607290 add 'vs' backend that automatically chooses between the vs backends
For newer VS versions, we can simply rely on 'VisualStudioVersion' being
set in the environment.
For VS2010, we fall back to check 'VSINSTALLDIR' for the version string.
If the backend can not be auto detected, we raise an exception to make the
user choose an explicit backend.
We also print the detected backend to the meson log.
2017-03-23 10:34:32 +01:00
Nicolas Schneider 994696e0ad add vs2017 backend
VS2017 requires the 'WindowsTargetPlatformVersion' property to be set.
We gather the version to use from the environment variable
'WindowsSDKVersion' that will be set by the VS developer command prompt.
2017-03-22 11:05:28 +01:00
Nirbheek Chauhan 23f3cec9d0 Force installation dir options to be inside prefix
With the exception of things like sysconfdir (/etc), every other
installation directory option must be inside the prefix.

Also move the prefix checks to coredata.py since prefix can also be set
from inside project() with default_options and via mesonconf. Earlier
you could set prefix to a relative path that way.

This also allows us to return consistent values for get_option('xxxdir')
regardless of whether relative paths are passed or absolute paths are
passed while setting options on the command-line, via mesonconf, or via
default_options in project(). Now the returned path will *always* be
relative to the prefix.

Includes a unit test for this, and a failing test.

Closes #1299
2017-01-23 20:34:45 +02:00
Mike Sinkovsky 969be1f679 cleanup: Remove redundant parentheses 2017-01-18 21:22:47 +02:00
Igor Gnatenko dd36847c4b style: fix E202 violations
E202: whitespace before ']'

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2017-01-02 19:09:47 +01:00
Igor Gnatenko c13160034f style: fix E201 violations
E201: whitespace after '['

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2017-01-02 19:08:16 +01:00
Jussi Pakkanen 0a14ad63de Add simple uninstall target. Closes #753. 2016-12-31 13:55:55 +02:00
Nirbheek Chauhan 8e06ab6a95 Use a script to clean-up custom-target output dirs
The script will manually delete all custom_target outputs that are
directories instead of files. This is needed because on platforms other
than Windows, Ninja only deletes directories while cleaning if they are
empty.

Closes #1220
2016-12-19 22:31:26 +05:30
Igor Gnatenko 5bf22c5678 add support for $sharedstatedir
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-12-18 00:08:45 +01:00
Igor Gnatenko 2962d3a66b add support for $infodir
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-12-18 00:01:27 +01:00
Igor Gnatenko 380b362fa4 add support for $sbindir
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-12-18 00:01:23 +01:00
Igor Gnatenko c9818c02ec add builtin support for localstatedir
Reported-by: Richard Hughes <richard@hughsie.com>
Closes: https://github.com/mesonbuild/meson/issues/1142
Signed-off-by: Igor Gnatenko <ignatenko@redhat.com>
2016-12-06 20:27:02 +02:00
Jussi Pakkanen 3ab117fd52 Tell users about mesonconf if they try to run Meson on an existing build dir. 2016-12-03 00:04:34 +02:00
Sam Thursfield ac56f8d8fb Don't show tracebacks for MesonException in helper scripts
I hit an issue when building gtk-doc documentation. The issue is
my fault, but the error output from Meson makes it look like an
internal error:

    [0/1] 'Running external command libtracker-sparql-doc.'
    Building documentation for libtracker-sparql
    Traceback (most recent call last):
      File "/home/sam/meson/meson.py", line 26, in <module>
        sys.exit(main())
      File "/home/sam/meson/meson.py", line 23, in main
        return mesonmain.run(launcher, sys.argv[1:])
      File "/home/sam/meson/mesonbuild/mesonmain.py", line 249, in run
        sys.exit(run_script_command(args[1:]))
      File "/home/sam/meson/mesonbuild/mesonmain.py", line 239, in run_script_command
        return cmdfunc(cmdargs)
      File "/home/sam/meson/mesonbuild/scripts/gtkdochelper.py", line 183, in run
        options.ignore_headers.split('@@') if options.ignore_headers else [])
      File "/home/sam/meson/mesonbuild/scripts/gtkdochelper.py", line 133, in build_gtkdoc
        gtkdoc_run_check(mkhtml_cmd, os.path.join(abs_out, 'html'))
      File "/home/sam/meson/mesonbuild/scripts/gtkdochelper.py", line 55, in gtkdoc_run_check
        raise MesonException('\n'.join(err_msg))
    mesonbuild.mesonlib.MesonException: 'gtkdoc-mkhtml' failed with status 6
    warning: failed to load external entity "../overview.sgml"
    ../libtracker-sparql-docs.sgml:20: element include: XInclude error :
    could not load ../overview.sgml, and no fallback was found
    warning: failed to load external entity "../examples.sgml"
    ../libtracker-sparql-docs.sgml:41: element include: XInclude error :
    could not load ../examples.sgml, and no fallback was found

    FAILED: libtracker-sparql-doc

After this patch, the output is much clearer:

    [0/1] 'Running external command libtracker-sparql-doc.'
    Building documentation for libtracker-sparql

    Error in gtkdoc helper script:
    'gtkdoc-mkhtml' failed with status 6
    warning: failed to load external entity "../overview.sgml"
    ../libtracker-sparql-docs.sgml:20: element include: XInclude error :
    could not load ../overview.sgml, and no fallback was found
    warning: failed to load external entity "../examples.sgml"
    ../libtracker-sparql-docs.sgml:41: element include: XInclude error :
    could not load ../examples.sgml, and no fallback was found

Note the actual errors from xsltproc are swallowed by gtkdoc-mkhtml
1.25.1, they're only displayed in the example above because I made a
patch: <https://bugzilla.gnome.org/show_bug.cgi?id=774812>
2016-11-26 12:11:59 -05:00
Jussi Pakkanen c7ddce163f All testing is now in mesontest.py, which simplifies a lot of stuff. 2016-11-18 22:10:22 +02:00
Jussi Pakkanen 4d8e3be08f Create target directory if it does not exist. Closes #935. 2016-11-09 11:26:04 -05:00
Nirbheek Chauhan a2262103fb Implement mlog.warning and use it everywhere for warnings
Prepends the string with 'WARNING:' in ANSI yellow.

Closes https://github.com/mesonbuild/meson/issues/961
2016-11-08 17:43:24 -05:00
Patrick Griffis 1781129740 gnome: Add yelp() function
Fixes #881
Mentioned in #295
2016-10-19 18:44:19 -04:00
Igor Gnatenko a513bcfde6 allow libdir/includedir/etc. be absolute paths
In Fedora we don't care about prefix, we want to ensure that libdir
is /usr/lib64, localedir is /usr/share/locale, and cetera.

Additionally, we don't need to ensure that prefix is absolute as we
check it in main.

Fixes: cc19bf0f45 ("Move option validation in objects rather than doing it only in the conf script.")
Closes: https://github.com/mesonbuild/meson/issues/869
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-10-11 00:57:01 +03:00
Jussi Pakkanen e2b3752f87 Show error log options in help. 2016-10-10 19:51:48 +03:00
Emanuele Aina 6c50253645 Use argv[0] to internally relaunch meson.py
When installing Meson, distutils may choose to put shim scripts in the
`PATH` that only set up the egg requirements before launching the real
`meson.py` contained in the egg.

This means that `__file__` points to the real `meson.py` file, but
launching it directly is doomed to fail as it's missing the metadata
contained in the shim to set up the path egg, resulting in errors when
trying to import the `mesonbuild` module.

A similar issue affects Meson when installed as a zipapp, with the
current code going great lengths to figure out how to relaunch itself.

Using `argv[0]` avoids these issues as it gives us the way the current
executable has been launched, so we are pretty much guaranteed that
using it will create another instance of the same executable. We only
need to resolve relative paths as the current working directory may
get changed before re-launching the script, and using `realpath()` for
that saves us the trouble of manually resolving links and getting caught
in endless loops.

This also mean that `meson_script_file` no longer necessarily point to a
absolute file, so rename it to `_launcher` which hopefully would be less
prone to inducing false assumptions.
2016-10-08 15:41:31 +02:00
Jussi Pakkanen 1f4cce86ad Remove shebangs on files that are not runnable and add execute bits to those that are. 2016-10-07 21:10:33 +03:00
Jussi Pakkanen cdf0c4f1a9 Merge branch 'QuLogic-context-managers' 2016-09-01 23:12:06 +03:00
Elliott Sales de Andrade 0cf065e12b Use argparse's builtin version printer. 2016-08-30 01:59:55 -04: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
Jussi Pakkanen c4ade56150 Added sysconfdir option. Closes #694. 2016-08-21 15:57:38 +03:00
Nirbheek Chauhan 018fa4b90f vs: Fix regen_checker by using the correct coredata mtime
After c01b183e5, the mtime of coredata.dat is always newer than all the
other build files, which made regen_checker think that they always had
to be regenerated. Now we set the mtime of the file to a value before
the build files are generated and that makes everything behave as it did
earlier.
2016-07-29 08:18:59 +05:30
Jussi Pakkanen 9e37c8a308 Warn if PKG_CONFIG_PATH has changed because it may cause dependency detection to fail. Closes #626. 2016-07-15 20:52:27 +03:00
Nirbheek Chauhan c01b183e54 mesonmain: Dump the coredata last
Otherwise we'll mark the build directory as successfully configured even
if there's an error while doing the actual generation.

Reported on IRC by 'sdgsgad'
2016-07-15 18:12:33 +05:30
Nicolas Schneider fba749fcb7 extract vs2015backend into own file 2016-05-30 22:00:20 +02:00
Nicolas Schneider 3bedca0257 add vs2015 backend 2016-05-30 21:49:35 +02: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 1a0938cc25 Automagic scan-build support. 2016-05-22 19:24:59 +03:00
Jussi Pakkanen dc148e0702 Remove all special casing for gettext and use elementary operations instead. 2016-05-21 18:21:23 +03:00
Nirbheek Chauhan e3bc2e5c68 ninja: Set PATH for CustomTargets with built EXEs on Windows
When a CustomTarget is run with a command that is an executable built
by the project which also has a DLL built in the same project as a
dependency, the EXE can't run on Windows because the DLL can't be found.
On UNIX-like systems, we set the RPATH using the linker so these
dependencies can be found, but on Windows the only way is to set the
PATH environment variable.

The same problem exists for tests, so we reuse that infrastructure by
creating a new meson_exe.py script that can be used as a wrapper to run
CustomTarget commands on Windows. This can later also be extended to add
support for setting an environment while calling the command needed to
generate a CustomTarget: https://github.com/mesonbuild/meson/issues/266
2016-04-15 05:49:42 +05:30
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 d87eb7d290 Merge branch 'base_options'. 2016-03-20 22:04:24 +02:00
Jussi Pakkanen 79de463993 Converted precompiled headers into a base option. 2016-03-20 19:35:42 +02:00
Jussi Pakkanen 0c63f75aaf Converted coverage into a base option. 2016-03-20 19:16:49 +02:00
Nirbheek Chauhan 11f63105d0 New builtin option: libexecdir for installation of helper executables 2016-03-17 16:17:06 +05:30
Nicolas Schneider 92187501ed Can add postconfigure script. 2016-03-01 14:07:38 +01:00
Nicolas Schneider ac5ee0c414 dump coredata to file before calling backend.generate()
This ensures that all build files always have a later timestamp than
coredata.dat, which is used to check if the build files must be
regenerated.
2016-02-25 23:13:29 +01:00
Jussi Pakkanen 6f907dd4ab Merge pull request #358 from tp-m/no-args
Try harder to infer build and source directories if called without arguments.
2016-02-24 22:45:14 +02:00
Jussi Pakkanen d88223bd61 Do delayed argument setting properly this time. 2016-02-22 21:28:34 +02:00
Jussi Pakkanen 0469128f46 Preserve 'C:\' as an absolute path in prefix. 2016-02-21 13:14:25 +02:00
Nirbheek Chauhan a901024d33 When erroring out due to invalid prefix, print the value
Helps with debugging what's going wrong
2016-02-17 15:03:54 +05:30
Jussi Pakkanen 755d22afbd Strip trailing slash from prefix. Closes #366. 2016-01-25 21:55:56 +02:00
Jussi Pakkanen 7435df8399 Moved backends to their own module. 2016-01-23 20:02:52 +02:00
Tim-Philipp Müller f5d63cd47e meson: try harder to infer build and source directories if called without arguments
If there's no meson.build file in the current directory
and there is one in the parent directory, assume that
we are in the build directory.
2016-01-19 00:02:28 +00:00
Jussi Pakkanen eda57f887a Improve command line arg behaviour. 2016-01-16 23:04:41 +02:00
Jussi Pakkanen d6e176f455 Made gtkdoc and run targets work. 2016-01-16 18:04:59 +02:00
Jussi Pakkanen 23b98cd6e6 Renamed meson package to mesonbuild so that we can have a script named meson in the same toplevel dir. 2016-01-16 17:35:29 +02:00