Commit Graph

62 Commits

Author SHA1 Message Date
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