diff options
56 files changed, 276 insertions, 134 deletions
diff --git a/docs/markdown/Adding-arguments.md b/docs/markdown/Adding-arguments.md index 80f02d9..6067377 100644 --- a/docs/markdown/Adding-arguments.md +++ b/docs/markdown/Adding-arguments.md @@ -1,3 +1,7 @@ +--- +short-description: Adding compiler arguments +... + # Adding arguments Often you need to specify extra compiler arguments. Meson provides two different ways to achieve this: global arguments and per-target arguments. diff --git a/docs/markdown/Build-options.md b/docs/markdown/Build-options.md index 64e2d38..6029a2c 100644 --- a/docs/markdown/Build-options.md +++ b/docs/markdown/Build-options.md @@ -1,3 +1,7 @@ +--- +short-description: Build options to configure project properties +... + # Build options Most non-trivial builds require user-settable options. As an example a program may have two different data backends that are selectable at build time. Meson provides for this by having a option definition file. Its name is `meson_options.txt` and it is placed at the root of your source tree. diff --git a/docs/markdown/Build-system-converters.md b/docs/markdown/Build-system-converters.md index f4ee501..6c81658 100644 --- a/docs/markdown/Build-system-converters.md +++ b/docs/markdown/Build-system-converters.md @@ -1,3 +1,7 @@ +--- +short-description: Converting other build systems to Meson +... + # Build system converters Moving from one build system into another includes a fair bit of work. To make things easier, Meson provides scripts to convert other build systems into Meson. At the time of writing, scripts for CMake and autotools exist. It can be found in the `tools` subdirectory in Meson's source tree. diff --git a/docs/markdown/Configuration.md b/docs/markdown/Configuration.md index 037bcbd..70649d7 100644 --- a/docs/markdown/Configuration.md +++ b/docs/markdown/Configuration.md @@ -1,3 +1,7 @@ +--- +short-description: Build-time configuration options +... + # Configuration If there are multiple configuration options, passing them through compiler flags becomes very burdensome. It also makes the configuration settings hard to inspect. To make things easier, Meson supports the generation of configure files. This feature is similar to one found in other build systems such as CMake. diff --git a/docs/markdown/Configuring-a-build-directory.md b/docs/markdown/Configuring-a-build-directory.md index e887e9e..c7aa913 100644 --- a/docs/markdown/Configuring-a-build-directory.md +++ b/docs/markdown/Configuring-a-build-directory.md @@ -1,3 +1,7 @@ +--- +short-description: Configuring a pre-generated build directory +... + # Configuring a build directory Often you want to change the settings of your build after it has been generated. For example you might want to change from a debug build into a release build, set custom compiler flags, change the build options provided in your `meson_options.txt` file and so on. diff --git a/docs/markdown/Continuous-Integration.md b/docs/markdown/Continuous-Integration.md index 1dff200..e57ea78 100644 --- a/docs/markdown/Continuous-Integration.md +++ b/docs/markdown/Continuous-Integration.md @@ -33,8 +33,8 @@ script: - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then echo FROM YOUR/REPO:yakkety > Dockerfile; fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then echo ADD . /root >> Dockerfile; fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then docker build -t withgit .; fi - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then docker run withgit /bin/sh -c "cd /root && TRAVIS=true CC=$CC CXX=$CXX meson build && ninja -C build test"; fi - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then SDKROOT=$(xcodebuild -version -sdk macosx Path) meson build && ninja -C build test; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then docker run withgit /bin/sh -c "cd /root && TRAVIS=true CC=$CC CXX=$CXX meson builddir && ninja -C builddir test"; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then SDKROOT=$(xcodebuild -version -sdk macosx Path) meson builddir && ninja -C builddir test; fi ``` ## AppVeyor for Windows @@ -67,11 +67,11 @@ install: build_script: - cmd: echo Building on %arch% with %compiler% - - cmd: PATH=%cd%;%MESON_PYTHON_PATH%;%PATH%; && python meson.py --backend=ninja build - - cmd: PATH=%cd%;%MESON_PYTHON_PATH%;%PATH%; && ninja -C build + - cmd: PATH=%cd%;%MESON_PYTHON_PATH%;%PATH%; && python meson.py --backend=ninja builddir + - cmd: PATH=%cd%;%MESON_PYTHON_PATH%;%PATH%; && ninja -C builddir test_script: - - cmd: PATH=%cd%;%MESON_PYTHON_PATH%;%PATH%; && ninja -C build test + - cmd: PATH=%cd%;%MESON_PYTHON_PATH%;%PATH%; && ninja -C builddir test ``` ## Travis without Docker @@ -96,7 +96,7 @@ install: - pip3 install meson script: - - meson build - - ninja -C build - - ninja -C build test + - meson builddir + - ninja -C builddir + - ninja -C builddir test ``` diff --git a/docs/markdown/Creating-Linux-binaries.md b/docs/markdown/Creating-Linux-binaries.md index 29d68ec..8e9fb60 100644 --- a/docs/markdown/Creating-Linux-binaries.md +++ b/docs/markdown/Creating-Linux-binaries.md @@ -1,3 +1,7 @@ +--- +short-description: Creating universal Linux binaries +... + # Creating Linux binaries Creating Linux binaries that can be downloaded and run on any distro (like .dmg packages for OSX or .exe installers for Windows) has traditionally been difficult. This is even more tricky if you want to use modern compilers and features, which is especially desired in game development. There is still no simple turn key solution for this problem but with a bit of setup it can be relatively straightforward. diff --git a/docs/markdown/Creating-OSX-packages.md b/docs/markdown/Creating-OSX-packages.md index 8faf568..4a4612e 100644 --- a/docs/markdown/Creating-OSX-packages.md +++ b/docs/markdown/Creating-OSX-packages.md @@ -1,3 +1,7 @@ +--- +short-description: Tools to create OS X packages +... + # Creating OSX packages Meson does not have native support for building OSX packages but it does provide all the tools you need to create one yourself. The reason for this is that it is a very hard task to write a system that provides for all the different ways to do that but it is very easy to write simple scripts for each application. diff --git a/docs/markdown/Cross-compilation.md b/docs/markdown/Cross-compilation.md index b5df8b3..21f418b 100644 --- a/docs/markdown/Cross-compilation.md +++ b/docs/markdown/Cross-compilation.md @@ -1,3 +1,7 @@ +--- +short-description: Setting up cross-compilation +... + # Cross compilation Meson has full support for cross compilation. Since cross compiling is more complicated than native building, diff --git a/docs/markdown/Custom-build-targets.md b/docs/markdown/Custom-build-targets.md index 0c34b1f..a425f8c 100644 --- a/docs/markdown/Custom-build-targets.md +++ b/docs/markdown/Custom-build-targets.md @@ -1,3 +1,7 @@ +--- +short-description: Build targets for custom languages or corner-cases +... + # Custom build targets While Meson tries to support as many languages and tools as possible, there is no possible way for it to cover all corner cases. For these cases it permits you to define custom build targets. Here is how one would use it. diff --git a/docs/markdown/Dependencies.md b/docs/markdown/Dependencies.md index c57b9d4..3c07de9 100644 --- a/docs/markdown/Dependencies.md +++ b/docs/markdown/Dependencies.md @@ -1,3 +1,7 @@ +--- +short-description: Dependencies for external libraries and frameworks +... + # Dependencies Very few applications are fully self-contained, but rather they use external libraries and frameworks to do their work. Meson makes it very easy to find and use external dependencies. Here is how one would use the Zlib compression library. diff --git a/docs/markdown/External-commands.md b/docs/markdown/External-commands.md index af19794..f597b0c 100644 --- a/docs/markdown/External-commands.md +++ b/docs/markdown/External-commands.md @@ -1,3 +1,7 @@ +--- +short-description: Running external commands +... + # External commands As a part of the software configuration, you may want to get extra data by running external commands. The basic syntax is the following. diff --git a/docs/markdown/Feature-autodetection.md b/docs/markdown/Feature-autodetection.md index b6a4f41..8de4086 100644 --- a/docs/markdown/Feature-autodetection.md +++ b/docs/markdown/Feature-autodetection.md @@ -1,3 +1,7 @@ +--- +short-description: Auto-detection of features like ccache and code coverage +... + # Feature autodetection Meson is designed for high productivity. It tries to do as many things automatically as it possibly can. diff --git a/docs/markdown/Generating-sources.md b/docs/markdown/Generating-sources.md index 82b043d..630b7e9 100644 --- a/docs/markdown/Generating-sources.md +++ b/docs/markdown/Generating-sources.md @@ -1,3 +1,7 @@ +--- +short-description: Generation of source files before compilation +... + # Generating sources Sometimes source files need to be preprocessed before they are passed to the actual compiler. As an example you might want build an IDL compiler and then run some files through that to generate actual source files. In Meson this is done with [`generator()`](https://github.com/mesonbuild/meson/wiki/Reference-manual#generator) or [`custom_target()`](https://github.com/mesonbuild/meson/wiki/Reference-manual#custom_target). diff --git a/docs/markdown/Getting-meson.md b/docs/markdown/Getting-meson.md index f28a7e2..1dabe95 100644 --- a/docs/markdown/Getting-meson.md +++ b/docs/markdown/Getting-meson.md @@ -20,9 +20,9 @@ Depending on your platform and backend you wish to use, you might need the [Ninja executable]. Again, use your distro-provided version if possible. Otherwise download it from Ninja project's web site. - [Github release page]: https://github.com/jpakkane/meson/releases + [Github release page]: https://github.com/mesonbuild/meson/releases [Python Package Index]: https://pypi.python.org/pypi/meson/ - [Git]: https://github.com/jpakkane/meson + [Git]: https://github.com/mesonbuild/meson [Python's home page]: https://www.python.org/downloads/ [Ninja executable]: https://ninja-build.org/ diff --git a/docs/markdown/Gnome-module.md b/docs/markdown/Gnome-module.md index af1e059..827568a 100644 --- a/docs/markdown/Gnome-module.md +++ b/docs/markdown/Gnome-module.md @@ -12,13 +12,19 @@ To use this module, just do: **`gnome = import('gnome')`**. The following functi ### gnome.compile_resources() -This function compiles resources specified in an XML file into code that can be embedded inside the main binary. Similar a build target it takes two positional arguments. The first one is the name of the resource and the second is the xml file containing the resource definitions. If the name is `foobar`, Meson will generate a header file called `foobar.h`, which you can then include in your sources. There are two keyword arguments. +This function compiles resources specified in an XML file into code that can be embedded inside the main binary. Similar a build target it takes two positional arguments. The first one is the name of the resource and the second is the xml file containing the resource definitions. If the name is `foobar`, Meson will generate a header file called `foobar.h`, which you can then include in your sources. * `source_dir`: a list of subdirectories where the resource compiler should look up the files, relative to the location of the xml file * `c_name`: passed to the resource compiler as an argument after `--c-name` +* `dependencies`: extra targets to depend upon for building +* `export`: (*Added 0.37.0*) if true, export the symbols of the generated sources +* `gresource_bundle`: (*Added 0.37.0*) if true, output a `.gresource` file instead of source +* `install_header`: (*Added 0.37.0*) if true, install the header file +* `install`: (*Added 0.37.0*) if true, install the gresource file +* `install_dir`: (*Added 0.37.0*) location to install the header or bundle depending on previous options * `extra_args`: extra command line arguments to pass to the resource compiler -Returns an array of two elements which are: `[c_source, header_file]` +Returns an array containing: `[c_source, header_file]` or `[gresource_bundle]` ### gnome.generate_gir() diff --git a/docs/markdown/IDE-integration.md b/docs/markdown/IDE-integration.md index 7e046c6..7258f56 100644 --- a/docs/markdown/IDE-integration.md +++ b/docs/markdown/IDE-integration.md @@ -1,3 +1,7 @@ +--- +short-description: Meson's API to integrate Meson support into an IDE +... + # IDE integration Meson has exporters for Visual Studio and XCode, but writing a custom backend for every IDE out there is not a scalable approach. To solve this problem, Meson provides an API that makes it easy for any IDE or build tool to integrate Meson builds and provide an experience comparable to a solution native to the IDE. @@ -6,7 +10,7 @@ The basic tool for this is a script called `mesonintrospect.py`. Some distro pac The first thing to do when setting up a Meson project in an IDE is to select the source and build directories. For this example we assume that the source resides in an Eclipse-like directory called `workspace/project` and the build tree is nested inside it as `workspace/project/build`. First we initialise Meson by running the following command in the source directory. - meson build + meson builddir For the remainder of the document we assume that all commands are executed inside the build directory unless otherwise specified. @@ -32,7 +36,7 @@ The next thing to display is the list of options that can be set. These include To set the options, use the `mesonconf.py` binary. -Compilation and unit tests are done as usual by running the `ninja` and `ninja test` commands. A JSON formatted result log can be found in `workspace/project/build/meson-logs/testlog.json`. +Compilation and unit tests are done as usual by running the `ninja` and `ninja test` commands. A JSON formatted result log can be found in `workspace/project/builddir/meson-logs/testlog.json`. When these tests fail, the user probably wants to run the failing test in a debugger. To make this as integrated as possible, extract the test test setups with this command. diff --git a/docs/markdown/Include-directories.md b/docs/markdown/Include-directories.md index 949bf2c..c1d4ac1 100644 --- a/docs/markdown/Include-directories.md +++ b/docs/markdown/Include-directories.md @@ -1,3 +1,7 @@ +--- +short-description: Instructions on handling include directories +... + # Include directories Most `C`/`C++` projects have headers in different directories than sources. Thus you need to specify include directories. Let's assume that we are at some subdirectory and wish to add its `include` subdirectory to some target's search path. To create a include directory object we do this: diff --git a/docs/markdown/IndepthTutorial.md b/docs/markdown/IndepthTutorial.md index d67adf7..dd93f82 100644 --- a/docs/markdown/IndepthTutorial.md +++ b/docs/markdown/IndepthTutorial.md @@ -78,7 +78,7 @@ At this point we can return to the pkg-config generator line. All shared librari With these four files we are done. To configure, build and run the test suite, we just need to execute the following commands (starting at source tree root directory). ```console -$ meson build && cd build +$ meson builddir && cd builddir $ ninja $ ninja test ``` diff --git a/docs/markdown/Installing.md b/docs/markdown/Installing.md index 40dcd8d..f186889 100644 --- a/docs/markdown/Installing.md +++ b/docs/markdown/Installing.md @@ -1,3 +1,7 @@ +--- +short-description: Installing targets +... + # Installing By default Meson will not install anything. Build targets can be installed by tagging them as installable in the definition. diff --git a/docs/markdown/Java.md b/docs/markdown/Java.md index 8501bdf..9b89304 100644 --- a/docs/markdown/Java.md +++ b/docs/markdown/Java.md @@ -1,5 +1,6 @@ --- title: Java +short-description: Compiling Java programs ... # Compiling Java applications diff --git a/docs/markdown/Localisation.md b/docs/markdown/Localisation.md index 9fde970..f342ecc 100644 --- a/docs/markdown/Localisation.md +++ b/docs/markdown/Localisation.md @@ -1,3 +1,7 @@ +--- +short-description: Localization with GNU Gettext +... + # Localisation Localising your application with GNU Gettext takes a little effort but is quite straightforward. This documentation assumes that you have a `po` subdirectory at your project root directory that contains all the localisation info. diff --git a/docs/markdown/Modules.md b/docs/markdown/Modules.md index e594383..c354169 100644 --- a/docs/markdown/Modules.md +++ b/docs/markdown/Modules.md @@ -1,3 +1,7 @@ +--- +short-description: Meson modules for common build operations +... + # Modules In addition to core language features, Meson also provides a module system aimed at providing helper methods for common build operations. Using modules is simple, first you import them: diff --git a/docs/markdown/Precompiled-headers.md b/docs/markdown/Precompiled-headers.md index a7bcbf8..cae0bd1 100644 --- a/docs/markdown/Precompiled-headers.md +++ b/docs/markdown/Precompiled-headers.md @@ -1,3 +1,7 @@ +--- +short-description: Using precompiled headers to reduce compilation time +... + # Precompiled headers Parsing header files of system libraries is surprisingly expensive. A typical source file has less than one thousand lines of code. In contrast the headers of large libraries can be tens of thousands of lines. This is especially problematic with C++, where header-only libraries are common and they may contain extremely complex code. This makes them slow to compile. diff --git a/docs/markdown/Quick-guide.md b/docs/markdown/Quick-guide.md index 3966084..600120e 100644 --- a/docs/markdown/Quick-guide.md +++ b/docs/markdown/Quick-guide.md @@ -40,7 +40,7 @@ The most common use case of Meson is compiling code on a code base you are worki ```console $ cd /path/to/source/root -$ meson build && cd build +$ meson builddir && cd builddir $ ninja $ ninja test ``` @@ -58,10 +58,10 @@ Distro packagers usually want total control on the build flags used. Meson suppo ```console $ cd /path/to/source/root -$ CFLAGS=... CXXFLAGS=... LDFLAGS=.. meson --prefix /usr --buildtype=plain build -$ ninja -v -C build -$ ninja -C build test -$ DESTDIR=/path/to/staging/root ninja -C build install +$ CFLAGS=... CXXFLAGS=... LDFLAGS=.. meson --prefix /usr --buildtype=plain builddir +$ ninja -v -C builddir +$ ninja -C builddir test +$ DESTDIR=/path/to/staging/root ninja -C builddir install ```` The command line switch `--buildtype=plain` tells Meson not to add its own flags to the command line. This gives the packager total control on used flags. diff --git a/docs/markdown/Reference-manual.md b/docs/markdown/Reference-manual.md index dd99bde..6265ea1 100644 --- a/docs/markdown/Reference-manual.md +++ b/docs/markdown/Reference-manual.md @@ -696,7 +696,7 @@ Provides information about the build machine — the machine that is doing the a - `system()` returns the operating system name, such as `windows` (all versions of Windows), `linux` (all Linux distros), `darwin` (all versions of OS X), etc. - `endian()` returns `big` on big-endian systems and `little` on little-endian systems. -Currently, these values are populated using the [`platform.system()`](https://docs.python.org/3.4/library/platform.html#platform.system) and [`platform.machine()`](https://docs.python.org/3.4/library/platform.html#platform.machine). If you think the returned values for any of these are incorrect for your system or CPU, please file [a bug report](/mesonbuild/meson/issues/new). +Currently, these values are populated using the [`platform.system()`](https://docs.python.org/3.4/library/platform.html#platform.system) and [`platform.machine()`](https://docs.python.org/3.4/library/platform.html#platform.machine). If you think the returned values for any of these are incorrect for your system or CPU, please file [a bug report](https://github.com/mesonbuild/meson/issues/new). ### `host_machine` object diff --git a/docs/markdown/Run-targets.md b/docs/markdown/Run-targets.md index 86639ab..38129a6 100644 --- a/docs/markdown/Run-targets.md +++ b/docs/markdown/Run-targets.md @@ -1,3 +1,7 @@ +--- +short-description: Targets to run external commands +... + # Run targets Sometimes you need to have a target that just runs an external command. As an example you might have a build target that reformats your source code, runs `cppcheck` or something similar. In Meson this is accomplished with a so called *run target*. diff --git a/docs/markdown/Running-Meson.md b/docs/markdown/Running-Meson.md index 5ae407e..d9847ac 100644 --- a/docs/markdown/Running-Meson.md +++ b/docs/markdown/Running-Meson.md @@ -15,8 +15,8 @@ Let us assume that we have a source tree that has a Meson build system. This mea cd /path/to/source/root - mkdir build - cd build + mkdir builddir + cd builddir meson .. First we create a directory to hold all files generated during the build. Then we go into it and invoke Meson, giving it the location of the source root. diff --git a/docs/markdown/Subprojects.md b/docs/markdown/Subprojects.md index 0318e79..b4e0925 100644 --- a/docs/markdown/Subprojects.md +++ b/docs/markdown/Subprojects.md @@ -1,3 +1,7 @@ +--- +short-description: Using meson projects as subprojects within other meson projects +... + # Subprojects Some platforms do not provide a native packaging system. In these cases it is common to bundle all third party libraries in your source tree. This is usually frowned upon because it makes it hard to add these kinds of projects into e.g. those Linux distributions that forbid bundled libraries. diff --git a/docs/markdown/Threads.md b/docs/markdown/Threads.md index d4f1bca..1bf9f83 100644 --- a/docs/markdown/Threads.md +++ b/docs/markdown/Threads.md @@ -1,3 +1,7 @@ +--- +short-description: Enabling thread support +... + # Threads Meson has a very simple notational shorthand for enabling thread support on your build targets. First you obtain the thread dependency object like this: diff --git a/docs/markdown/Tutorial.md b/docs/markdown/Tutorial.md index 524861d..ae2e381 100644 --- a/docs/markdown/Tutorial.md +++ b/docs/markdown/Tutorial.md @@ -30,7 +30,7 @@ executable('demo', 'main.c') That is all. We are now ready to build our application. First we need to initialise the build by going into the source directory and issuing the following commands. ```console -$ meson build +$ meson builddir ``` We create a separate build directory to hold all of the compiler output. Meson is different from some other build systems in that it does not permit in-source builds. You must always create a separate build directory. Common convention is to put the default build directory in a subdirectory of your toplevel source directory. @@ -40,7 +40,7 @@ When Meson is run it prints the following output. The Meson build system version: 0.13.0-research Source dir: /home/jpakkane/mesontutorial - Build dir: /home/jpakkane/mesontutorial/build + Build dir: /home/jpakkane/mesontutorial/builddir Build type: native build Project name is "tutorial". Using native c compiler "ccache cc". (gcc 4.8.2) @@ -49,7 +49,7 @@ When Meson is run it prints the following output. Now we are ready to build our code. ``` -$ cd build +$ cd builddir $ ninja ``` @@ -102,7 +102,7 @@ Once you have set up your build directory the first time, you don't ever need to The Meson build system version: 0.13.0-research Source dir: /home/jpakkane/mesontutorial - Build dir: /home/jpakkane/mesontutorial/build + Build dir: /home/jpakkane/mesontutorial/builddir Build type: native build Project name is "tutorial". Using native c compiler "ccache cc". (gcc 4.8.2) diff --git a/docs/markdown/Unit-tests.md b/docs/markdown/Unit-tests.md index d5ef77e..83c3712 100644 --- a/docs/markdown/Unit-tests.md +++ b/docs/markdown/Unit-tests.md @@ -1,3 +1,7 @@ +--- +short-description: Meson's own unit-test system +... + # Unit tests Meson comes with a fully functional unit test system. To use it simply build an executable and then use it in a test. diff --git a/docs/markdown/Unity-builds.md b/docs/markdown/Unity-builds.md index f1f718e..9f939f5 100644 --- a/docs/markdown/Unity-builds.md +++ b/docs/markdown/Unity-builds.md @@ -1,3 +1,7 @@ +--- +short-description: Unity builds are a technique for reducing build times +... + # Unity builds Unity builds are a technique for cutting down build times. The way it works is relatively straightforward. Suppose we have source files `src1.c`, `src2.c` and `src3.c`. Normally we would run the compiler three times, once for each file. In a unity build we instead compile all these sources in a single unit. The simplest approach is to create a new source file that looks like this. diff --git a/docs/markdown/Using-multiple-build-directories.md b/docs/markdown/Using-multiple-build-directories.md index cabd64f..ac67f84 100644 --- a/docs/markdown/Using-multiple-build-directories.md +++ b/docs/markdown/Using-multiple-build-directories.md @@ -14,13 +14,13 @@ Since a build directory is fully self contained and treats the source tree as a The first thing to do is to set up the default build, that is, the one we are going to use over 90% of the time. In this we use the system compiler and build with debug enabled and no optimizations so it builds as fast as possible. This is the default project type for Meson, so setting it up is simple. - mkdir build - meson build + mkdir builddir + meson builddir Another common setup is to build with debug and optimizations to, for example, run performance tests. Setting this up is just as simple. mkdir buildopt - meson --buildtype=debugoptimized + meson --buildtype=debugoptimized buildopt For systems where the default compiler is GCC, we would like to compile with Clang, too. So let's do that. diff --git a/docs/markdown/Using-with-Visual-Studio.md b/docs/markdown/Using-with-Visual-Studio.md index 2768ea4..339fda3 100644 --- a/docs/markdown/Using-with-Visual-Studio.md +++ b/docs/markdown/Using-with-Visual-Studio.md @@ -8,8 +8,8 @@ In order to generate Visual Studio projects, Meson needs to know the settings of 1. Click on start menu and select "Visual Studio 2015 Command Prompt" 1. cd into your source directory -1. mkdir build -1. python3 path/to/meson.py build --backend vs2015 +1. mkdir builddir +1. python3 path/to/meson.py builddir --backend vs2015 If you wish to use the Ninja backend instead of vs2015, pass `--backend ninja`. At the time of writing the Ninja backend is more mature than the VS backend so you might want to use it for serious work. diff --git a/docs/markdown/Vala.md b/docs/markdown/Vala.md index 0a6bc81..259ebd1 100644 --- a/docs/markdown/Vala.md +++ b/docs/markdown/Vala.md @@ -1,5 +1,6 @@ --- title: Vala +short-description: Compiling Vala programs ... # Compiling Vala applications diff --git a/docs/markdown/i18n-module.md b/docs/markdown/i18n-module.md index b4e40d7..9388be8 100644 --- a/docs/markdown/i18n-module.md +++ b/docs/markdown/i18n-module.md @@ -25,6 +25,7 @@ This function also defines targets for maintainers to use: This merges translations into a text file using `msgfmt`. See [custom_target](https://github.com/mesonbuild/meson/wiki/Reference%20manual#custom_target) for normal keywords. In addition it accepts these keywords: * `po_dir`: directory containing translations, relative to current directory +* `data_dirs`: (*Added 0.41.0*) list of directories for its files (See also `i18n.gettext()`) * `type`: type of file, valid options are `'xml'` (default) and `'desktop'` *Added 0.37.0* @@ -85,7 +85,7 @@ def install(sproj): return unpack(sproj, branch, sproj_dir) def run(args): - if len(args) == 0 or args[0] == '-h' or args[0] == '--help': + if not args or args[0] == '-h' or args[0] == '--help': print(sys.argv[0], 'list/install', 'package_name') return 1 command = args[0] diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index 389e759..65e1162 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -313,7 +313,9 @@ class Backend: # anyone both enables unity builds and has a file called foo-unity.cpp. osrc = self.get_unity_source_filename(extobj.target, comp.get_default_suffix()) + osrc = os.path.join(self.get_target_private_dir(extobj.target), osrc) objname = self.object_filename_from_source(extobj.target, osrc, True) + objname = objname.replace('/', '_').replace('\\', '_') objpath = os.path.join(proj_dir_to_build_root, targetdir, objname) return [objpath] for osrc in extobj.srclist: @@ -328,7 +330,7 @@ class Backend: includeargs = compiler.get_include_args(pchpath, False) for lang in ['c', 'cpp']: p = target.get_pch(lang) - if len(p) == 0: + if not p: continue if compiler.can_compile(p[-1]): header = p[0] diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 436b1fe..fd6489c 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -40,25 +40,6 @@ else: def ninja_quote(text): return text.replace(' ', '$ ').replace(':', '$:') -class RawFilename: - """ - Used when a filename is already relative to the root build directory, so - that we know not to add the target's private build directory to it. - """ - def __init__(self, fname): - self.fname = fname - - def __str__(self): - return self.fname - - def __repr__(self): - return '<RawFilename: {0}>'.format(self.fname) - - def split(self, c): - return self.fname.split(c) - - def startswith(self, s): - return self.fname.startswith(s) class NinjaBuildElement: def __init__(self, all_outputs, outfilenames, rule, infilenames): @@ -377,7 +358,8 @@ int dummy; # same time, also deal with generated sources that need to be compiled. generated_source_files = [] for rel_src, gensrc in generated_sources.items(): - raw_src = RawFilename(rel_src) + dirpart, fnamepart = os.path.split(rel_src) + raw_src = File(True, dirpart, fnamepart) if self.environment.is_source(rel_src) and not self.environment.is_header(rel_src): if is_unity and self.get_target_source_can_unity(target, rel_src): unity_deps.append(raw_src) @@ -410,7 +392,8 @@ int dummy; # necessary. This needs to be separate for at least Vala vala_generated_source_files = [] for src in vala_generated_sources: - raw_src = RawFilename(src) + dirpart, fnamepart = os.path.split(src) + raw_src = File(True, dirpart, fnamepart) if is_unity: unity_src.append(os.path.join(self.environment.get_build_dir(), src)) header_deps.append(raw_src) @@ -1049,7 +1032,7 @@ int dummy; """Vala is compiled into C. Set up all necessary build steps here.""" (vala_src, vapi_src, other_src) = self.split_vala_sources(target) extra_dep_files = [] - if len(vala_src) == 0: + if not vala_src: msg = 'Vala library {!r} has no Vala source files.' raise InvalidArguments(msg.format(target.name)) @@ -1847,8 +1830,11 @@ rule FORTRAN_DEP_HACK # Compiler args for compiling this target commands += compilers.get_base_compile_args(self.environment.coredata.base_options, compiler) - if isinstance(src, (RawFilename, File)): - src_filename = src.fname + if isinstance(src, File): + if src.is_built: + src_filename = os.path.join(src.subdir, src.fname) + else: + src_filename = src.fname elif os.path.isabs(src): src_filename = os.path.basename(src) else: @@ -1857,7 +1843,7 @@ rule FORTRAN_DEP_HACK rel_obj = os.path.join(self.get_target_private_dir(target), obj_basename) rel_obj += '.' + self.environment.get_object_suffix() commands += self.get_compile_debugfile_args(compiler, target, rel_obj) - if isinstance(src, RawFilename): + if isinstance(src, File) and src.is_built: rel_src = src.fname elif isinstance(src, File): rel_src = src.rel_to_builddir(self.build_to_src) @@ -1979,13 +1965,7 @@ rule FORTRAN_DEP_HACK """ if isinstance(src, str) and src.endswith('.h'): raise AssertionError('BUG: sources should not contain headers {!r}'.format(src)) - if isinstance(src, RawFilename) and src.fname.endswith('.h'): - raise AssertionError('BUG: sources should not contain headers {!r}'.format(src.fname)) - if isinstance(src, str) and src.endswith('.h'): - raise AssertionError('BUG: sources should not contain headers {!r}'.format(src)) - if isinstance(src, RawFilename) and src.fname.endswith('.h'): - raise AssertionError('BUG: sources should not contain headers {!r}'.format(src.fname)) compiler = get_compiler_for_source(target.compilers.values(), src) key = (target, compiler, is_generated) if key in self.target_arg_cache: @@ -1995,14 +1975,12 @@ rule FORTRAN_DEP_HACK self.target_arg_cache[key] = commands commands = CompilerArgs(commands.compiler, commands) - # FIXME: This file handling is atrocious and broken. We need to - # replace it with File objects used consistently everywhere. - if isinstance(src, RawFilename): - rel_src = src.fname - if os.path.isabs(src.fname): - abs_src = src.fname - else: - abs_src = os.path.join(self.environment.get_build_dir(), src.fname) + if isinstance(src, mesonlib.File) and src.is_built: + rel_src = os.path.join(src.subdir, src.fname) + if os.path.isabs(rel_src): + assert(rel_src.startswith(self.environment.get_build_dir())) + rel_src = rel_src[len(self.environment.get_build_dir())+1:] + abs_src = os.path.join(self.environment.get_build_dir(), rel_src) elif isinstance(src, mesonlib.File): rel_src = src.rel_to_builddir(self.build_to_src) abs_src = src.absolute_path(self.environment.get_source_dir(), @@ -2015,8 +1993,14 @@ rule FORTRAN_DEP_HACK else: raise InvalidArguments('Invalid source type: {!r}'.format(src)) abs_src = os.path.join(self.environment.get_build_dir(), rel_src) - if isinstance(src, (RawFilename, File)): - src_filename = src.fname + if isinstance(src, File): + if src.is_built: + src_filename = os.path.join(src.subdir, src.fname) + if os.path.isabs(src_filename): + assert(src_filename.startswith(self.environment.get_build_dir())) + src_filename = src_filename[len(self.environment.get_build_dir())+1:] + else: + src_filename = src.fname elif os.path.isabs(src): src_filename = os.path.basename(src) else: @@ -2035,7 +2019,7 @@ rule FORTRAN_DEP_HACK pchlist = target.get_pch(compiler.language) else: pchlist = [] - if len(pchlist) == 0: + if not pchlist: pch_dep = [] elif compiler.id == 'intel': pch_dep = [] @@ -2069,16 +2053,16 @@ rule FORTRAN_DEP_HACK element = NinjaBuildElement(self.all_outputs, rel_obj, compiler_name, rel_src) for d in header_deps: - if isinstance(d, RawFilename): - d = d.fname + if isinstance(d, File): + d = d.rel_to_builddir(self.build_to_src) elif not self.has_dir_part(d): d = os.path.join(self.get_target_private_dir(target), d) element.add_dep(d) for d in extra_deps: element.add_dep(d) for d in order_deps: - if isinstance(d, RawFilename): - d = d.fname + if isinstance(d, File): + d = d.rel_to_builddir(self.build_to_src) elif not self.has_dir_part(d): d = os.path.join(self.get_target_private_dir(target), d) element.add_orderdep(d) @@ -2095,6 +2079,8 @@ rule FORTRAN_DEP_HACK def has_dir_part(self, fname): # FIXME FIXME: The usage of this is a terrible and unreliable hack + if isinstance(fname, File): + return fname.subdir != '' return '/' in fname or '\\' in fname # Fortran is a bit weird (again). When you link against a library, just compiling a source file @@ -2140,7 +2126,7 @@ rule FORTRAN_DEP_HACK cstr = '_CROSS' for lang in ['c', 'cpp']: pch = target.get_pch(lang) - if len(pch) == 0: + if not pch: continue if '/' not in pch[0] or '/' not in pch[-1]: msg = 'Precompiled header of {!r} must not be in the same ' \ diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py index 432bdd0..16e96c9 100644 --- a/mesonbuild/backend/vs2010backend.py +++ b/mesonbuild/backend/vs2010backend.py @@ -865,7 +865,7 @@ class Vs2010Backend(backends.Backend): pch_sources = {} for lang in ['c', 'cpp']: pch = target.get_pch(lang) - if len(pch) == 0: + if not pch: continue pch_node.text = 'Use' pch_sources[lang] = [pch[0], pch[1], lang] diff --git a/mesonbuild/build.py b/mesonbuild/build.py index a5ebc34..c8d692e 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -115,7 +115,7 @@ class Build: self.compilers[lang] = compiler def add_cross_compiler(self, compiler): - if len(self.cross_compilers) == 0: + if not self.cross_compilers: self.static_cross_linker = self.environment.detect_static_linker(compiler) lang = compiler.get_language() if lang not in self.cross_compilers: @@ -340,9 +340,7 @@ class BuildTarget(Target): self.process_objectlist(objects) self.process_kwargs(kwargs, environment) self.check_unknown_kwargs(kwargs) - if len(self.sources) == 0 \ - and len(self.generated) == 0 \ - and len(self.objects) == 0: + if not self.sources and not self.generated and not self.objects: raise InvalidArguments('Build target %s has no sources.' % name) self.process_compilers() self.validate_sources() @@ -433,7 +431,7 @@ class BuildTarget(Target): We also add compilers that were used by extracted objects to simplify dynamic linker determination. ''' - if len(self.sources) + len(self.generated) + len(self.objects) == 0: + if not self.sources and not self.generated and not self.objects: return # Populate list of compilers if self.is_cross: @@ -488,7 +486,7 @@ class BuildTarget(Target): self.compilers['c'] = compilers['c'] def validate_sources(self): - if len(self.sources) == 0: + if not self.sources: return for lang in ('cs', 'java'): if lang in self.compilers: @@ -675,7 +673,7 @@ class BuildTarget(Target): if 'name_prefix' in kwargs: name_prefix = kwargs['name_prefix'] if isinstance(name_prefix, list): - if len(name_prefix) != 0: + if name_prefix: raise InvalidArguments('name_prefix array must be empty to signify null.') elif not isinstance(name_prefix, str): raise InvalidArguments('name_prefix must be a string.') @@ -684,7 +682,7 @@ class BuildTarget(Target): if 'name_suffix' in kwargs: name_suffix = kwargs['name_suffix'] if isinstance(name_suffix, list): - if len(name_suffix) != 0: + if name_suffix: raise InvalidArguments('name_suffix array must be empty to signify null.') else: if not isinstance(name_suffix, str): @@ -825,7 +823,7 @@ You probably should put it in link_with instead.''') self.link_whole_targets.append(t) def add_pch(self, language, pchlist): - if len(pchlist) == 0: + if not pchlist: return elif len(pchlist) == 1: if not environment.is_header(pchlist[0]): diff --git a/mesonbuild/compilers.py b/mesonbuild/compilers.py index 188bd8f..ba0fb4e 100644 --- a/mesonbuild/compilers.py +++ b/mesonbuild/compilers.py @@ -317,12 +317,12 @@ def get_base_link_args(options, linker, is_shared_module): return args def build_unix_rpath_args(build_dir, rpath_paths, install_rpath): - if len(rpath_paths) == 0 and len(install_rpath) == 0: + if not rpath_paths and not install_rpath: return [] paths = ':'.join([os.path.join(build_dir, p) for p in rpath_paths]) if len(paths) < len(install_rpath): padding = 'X' * (len(install_rpath) - len(paths)) - if len(paths) == 0: + if not paths: paths = padding else: paths = paths + ':' + padding @@ -388,7 +388,7 @@ class CompilerArgs(list): if len(args) > 2: raise TypeError("CompilerArgs() only accepts at most 2 arguments: " "The compiler, and optionally an initial list") - elif len(args) == 0: + elif not args: return cargs elif len(args) == 1: if isinstance(args[0], (Compiler, StaticLinker)): @@ -708,7 +708,7 @@ class Compiler: return self.get_std_shared_lib_link_args() def get_link_whole_for(self, args): - if isinstance(args, list) and len(args) == 0: + if isinstance(args, list) and not args: return [] raise EnvironmentException('Language %s does not support linking whole archives.' % self.language) @@ -1360,7 +1360,7 @@ class CCompiler(Compiler): extra_dirs = [extra_dirs] # Gcc + co seem to prefer builtin lib dirs to -L dirs. # Only try to find std libs if no extra dirs specified. - if len(extra_dirs) == 0: + if not extra_dirs: args = ['-l' + libname] if self.links(code, env, extra_args=args): return args @@ -1700,7 +1700,7 @@ class ValaCompiler(Compiler): extra_dirs = [extra_dirs] # Valac always looks in the default vapi dir, so only search there if # no extra dirs are specified. - if len(extra_dirs) == 0: + if not extra_dirs: code = 'class MesonFindLibrary : Object { }' vapi_args = ['--pkg', libname] args = self.get_cross_extra_flags(env, link=False) @@ -1892,12 +1892,12 @@ class DCompiler(Compiler): def build_rpath_args(self, build_dir, rpath_paths, install_rpath): # This method is to be used by LDC and DMD. # GDC can deal with the verbatim flags. - if len(rpath_paths) == 0 and len(install_rpath) == 0: + if not rpath_paths and not install_rpath: return [] paths = ':'.join([os.path.join(build_dir, p) for p in rpath_paths]) if len(paths) < len(install_rpath): padding = 'X' * (len(install_rpath) - len(paths)) - if len(paths) == 0: + if not paths: paths = padding else: paths = paths + ':' + padding diff --git a/mesonbuild/dependencies.py b/mesonbuild/dependencies.py index eb7a5e4..c512bf3 100644 --- a/mesonbuild/dependencies.py +++ b/mesonbuild/dependencies.py @@ -777,7 +777,7 @@ class BoostDependency(Dependency): else: libdir = [] # Can't find libdir, bail - if len(libdir) == 0: + if not libdir: return libdir = libdir[0] self.libdir = libdir @@ -1021,7 +1021,7 @@ class QtBaseDependency(Dependency): self.is_found = False if isinstance(mods, str): mods = [mods] - if len(mods) == 0: + if not mods: raise DependencyException('No ' + self.qtname + ' modules specified.') type_text = 'cross' if env.is_cross_build() else 'native' found_msg = '{} {} {{}} dependency (modules: {}) found:' \ @@ -1332,7 +1332,7 @@ class AppleFrameworks(Dependency): modules = kwargs.get('modules', []) if isinstance(modules, str): modules = [modules] - if len(modules) == 0: + if not modules: raise DependencyException("AppleFrameworks dependency requires at least one module.") self.frameworks = modules diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index eaaea73..979cdcc 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -1581,7 +1581,7 @@ class Interpreter(InterpreterBase): @noKwargs def func_configuration_data(self, node, args, kwargs): - if len(args) != 0: + if args: raise InterpreterException('configuration_data takes no arguments') return ConfigurationDataHolder() @@ -1818,7 +1818,7 @@ class Interpreter(InterpreterBase): self.coredata.base_options[optname] = oobj def func_find_program(self, node, args, kwargs): - if len(args) == 0: + if not args: raise InterpreterException('No program name specified.') required = kwargs.get('required', True) if not isinstance(required, bool): @@ -2533,7 +2533,7 @@ different subdirectory. self.coredata.target_guids[idname] = str(uuid.uuid4()).upper() def build_target(self, node, args, kwargs, targetholder): - if len(args) == 0: + if not args: raise InterpreterException('Target does not have a name.') name = args[0] sources = args[1:] diff --git a/mesonbuild/interpreterbase.py b/mesonbuild/interpreterbase.py index e59557a..86a6b47 100644 --- a/mesonbuild/interpreterbase.py +++ b/mesonbuild/interpreterbase.py @@ -34,7 +34,7 @@ def check_stringlist(a, msg='Arguments must be strings.'): def noPosargs(f): @wraps(f) def wrapped(self, node, args, kwargs): - if len(args) != 0: + if args: raise InvalidArguments('Function does not take positional arguments.') return f(self, node, args, kwargs) return wrapped @@ -42,7 +42,7 @@ def noPosargs(f): def noKwargs(f): @wraps(f) def wrapped(self, node, args, kwargs): - if len(kwargs) != 0: + if kwargs: raise InvalidArguments('Function does not take keyword arguments.') return f(self, node, args, kwargs) return wrapped @@ -94,7 +94,7 @@ class InterpreterBase: raise InvalidArguments('Missing Meson file in %s' % mesonfile) with open(mesonfile, encoding='utf8') as mf: code = mf.read() - if len(code.strip()) == 0: + if code.isspace(): raise InvalidCode('Builder file is empty.') assert(isinstance(code, str)) try: @@ -113,7 +113,7 @@ class InterpreterBase: def sanity_check_ast(self): if not isinstance(self.ast, mparser.CodeBlockNode): raise InvalidCode('AST is of invalid type. Possibly a bug in the parser.') - if len(self.ast.lines) == 0: + if not self.ast.lines: raise InvalidCode('No statements in code.') first = self.ast.lines[0] if not isinstance(first, mparser.FunctionNode) or first.func_name != 'project': @@ -405,7 +405,7 @@ class InterpreterBase: obj = self.to_native(obj) (posargs, _) = self.reduce_arguments(args) if method_name == 'to_string': - if len(posargs) == 0: + if not posargs: if obj: return 'true' else: @@ -429,12 +429,12 @@ class InterpreterBase: obj = self.to_native(obj) (posargs, _) = self.reduce_arguments(args) if method_name == 'is_even': - if len(posargs) == 0: + if not posargs: return obj % 2 == 0 else: raise InterpreterException('int.is_even() must have no arguments.') elif method_name == 'is_odd': - if len(posargs) == 0: + if not posargs: return obj % 2 != 0 else: raise InterpreterException('int.is_odd() must have no arguments.') diff --git a/mesonbuild/mconf.py b/mesonbuild/mconf.py index 2ab5f92..b4add65 100644 --- a/mesonbuild/mconf.py +++ b/mesonbuild/mconf.py @@ -56,7 +56,7 @@ class Conf: # Ninja is run. def print_aligned(self, arr): - if len(arr) == 0: + if not arr: return titles = ['Option', 'Description', 'Current Value', ''] longest_name = len(titles[0]) @@ -139,7 +139,7 @@ class Conf: print('') print('Base options:') okeys = sorted(self.coredata.base_options.keys()) - if len(okeys) == 0: + if not okeys: print(' No base options\n') else: coarr = [] @@ -158,7 +158,7 @@ class Conf: print('') print('Compiler options:') okeys = sorted(self.coredata.compiler_options.keys()) - if len(okeys) == 0: + if not okeys: print(' No compiler options\n') else: coarr = [] @@ -188,7 +188,7 @@ class Conf: self.print_aligned(parr) print('') print('Project options:') - if len(self.coredata.user_options) == 0: + if not self.coredata.user_options: print(' This project does not have any options') else: options = self.coredata.user_options @@ -197,7 +197,7 @@ class Conf: optarr = [] for key in keys: opt = options[key] - if (opt.choices is None) or (len(opt.choices) == 0): + if (opt.choices is None) or (not opt.choices): # Zero length list or string choices = '' else: @@ -222,7 +222,7 @@ def run(args): print('%s <build directory>' % args[0]) print('If you omit the build directory, the current directory is substituted.') return 1 - if len(options.directory) == 0: + if not options.directory: builddir = os.getcwd() else: builddir = options.directory[0] diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py index 7e4be7f..bce0965 100644 --- a/mesonbuild/mesonmain.py +++ b/mesonbuild/mesonmain.py @@ -87,8 +87,8 @@ class MesonApp: return os.path.exists(fname) def validate_core_dirs(self, dir1, dir2): - ndir1 = os.path.abspath(dir1) - ndir2 = os.path.abspath(dir2) + ndir1 = os.path.abspath(os.path.realpath(dir1)) + ndir2 = os.path.abspath(os.path.realpath(dir2)) if not os.path.exists(ndir1): os.makedirs(ndir1) if not os.path.exists(ndir2): @@ -222,6 +222,9 @@ def run_script_command(args): elif cmdname == 'gtkdoc': import mesonbuild.scripts.gtkdochelper as abc cmdfunc = abc.run + elif cmdname == 'msgfmthelper': + import mesonbuild.scripts.msgfmthelper as abc + cmdfunc = abc.run elif cmdname == 'regencheck': import mesonbuild.scripts.regen_checker as abc cmdfunc = abc.run @@ -269,10 +272,10 @@ def run(mainfile, args): args = mesonlib.expand_arguments(args) options = parser.parse_args(args) args = options.directories - if len(args) == 0 or len(args) > 2: + if not args or len(args) > 2: # if there's a meson.build in the dir above, and not in the current # directory, assume we're in the build directory - if len(args) == 0 and not os.path.exists('meson.build') and os.path.exists('../meson.build'): + if not args and not os.path.exists('meson.build') and os.path.exists('../meson.build'): dir1 = '..' dir2 = '.' else: diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py index b4dfd12..134060f 100644 --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py @@ -566,7 +566,7 @@ class GnomeModule(ExtensionModule): return ModuleReturnValue(rv, rv) def compile_schemas(self, state, args, kwargs): - if len(args) != 0: + if args: raise MesonException('Compile_schemas does not take positional arguments.') srcdir = os.path.join(state.build_to_src, state.subdir) outdir = state.subdir diff --git a/mesonbuild/modules/i18n.py b/mesonbuild/modules/i18n.py index 5738cb3..c4e29cf 100644 --- a/mesonbuild/modules/i18n.py +++ b/mesonbuild/modules/i18n.py @@ -49,6 +49,12 @@ PRESET_ARGS = { class I18nModule(ExtensionModule): + @staticmethod + def _get_data_dirs(state, dirs): + """Returns source directories of relative paths""" + src_dir = path.join(state.environment.get_source_dir(), state.subdir) + return [path.join(src_dir, d) for d in dirs] + def merge_file(self, state, args, kwargs): podir = kwargs.pop('po_dir', None) if not podir: @@ -60,8 +66,15 @@ class I18nModule(ExtensionModule): if file_type not in VALID_TYPES: raise MesonException('i18n: "{}" is not a valid type {}'.format(file_type, VALID_TYPES)) - kwargs['command'] = ['msgfmt', '--' + file_type, - '--template', '@INPUT@', '-d', podir, '-o', '@OUTPUT@'] + datadirs = self._get_data_dirs(state, mesonlib.stringlistify(kwargs.pop('data_dirs', []))) + datadirs = '--datadirs=' + ':'.join(datadirs) if datadirs else None + + command = [state.environment.get_build_command(), '--internal', 'msgfmthelper', + '@INPUT@', '@OUTPUT@', file_type, podir] + if datadirs: + command.append(datadirs) + + kwargs['command'] = command ct = build.CustomTarget(kwargs['output'] + '_merge', state.subdir, kwargs) return ModuleReturnValue(ct, [ct]) @@ -72,7 +85,7 @@ class I18nModule(ExtensionModule): raise coredata.MesonException('Can not do gettext because xgettext is not installed.') packagename = args[0] languages = mesonlib.stringlistify(kwargs.get('languages', [])) - datadirs = mesonlib.stringlistify(kwargs.get('data_dirs', [])) + datadirs = self._get_data_dirs(state, mesonlib.stringlistify(kwargs.get('data_dirs', []))) extra_args = mesonlib.stringlistify(kwargs.get('args', [])) preset = kwargs.pop('preset', None) diff --git a/mesonbuild/scripts/depfixer.py b/mesonbuild/scripts/depfixer.py index 16050d7..fa76a95 100644 --- a/mesonbuild/scripts/depfixer.py +++ b/mesonbuild/scripts/depfixer.py @@ -305,7 +305,7 @@ class Elf(DataSizes): # the chance of obliterating other strings. It might still happen # but our behaviour is identical to what chrpath does and it has # been in use for ages so based on that this should be rare. - if len(new_rpath) == 0: + if not new_rpath: self.remove_rpath_entry(entrynum) else: self.bf.seek(rp_off) diff --git a/mesonbuild/scripts/msgfmthelper.py b/mesonbuild/scripts/msgfmthelper.py new file mode 100644 index 0000000..d4deb00 --- /dev/null +++ b/mesonbuild/scripts/msgfmthelper.py @@ -0,0 +1,35 @@ +# Copyright 2016 The Meson development team + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import argparse +import subprocess +import os + +parser = argparse.ArgumentParser() +parser.add_argument('input') +parser.add_argument('output') +parser.add_argument('type') +parser.add_argument('podir') +parser.add_argument('--datadirs', default='') + + +def run(args): + options = parser.parse_args(args) + env = None + if options.datadirs: + env = os.environ.copy() + env.update({'GETTEXTDATADIRS': options.datadirs}) + return subprocess.call(['msgfmt', '--' + options.type, '-d', options.podir, + '--template', options.input, '-o', options.output], + env=env) diff --git a/mesonbuild/scripts/uninstall.py b/mesonbuild/scripts/uninstall.py index 85c4bba..1480921 100644 --- a/mesonbuild/scripts/uninstall.py +++ b/mesonbuild/scripts/uninstall.py @@ -36,7 +36,7 @@ def do_uninstall(log): print('\nRemember that files created by custom scripts have not been removed.') def run(args): - if len(args) != 0: + if args: print('Weird error.') return 1 if not os.path.exists(logfile): diff --git a/mesonbuild/wrap/wraptool.py b/mesonbuild/wrap/wraptool.py index 79bd5df..79b00e0 100644 --- a/mesonbuild/wrap/wraptool.py +++ b/mesonbuild/wrap/wraptool.py @@ -135,7 +135,7 @@ def update(name): def info(name): jd = get_result(API_ROOT + 'projects/' + name) versions = jd['versions'] - if len(versions) == 0: + if not versions: print('No available versions of', name) sys.exit(0) print('Available versions of %s:' % name) @@ -162,7 +162,7 @@ def status(): print('', name, 'not up to date. Have %s %d, but %s %d is available.' % (current_branch, current_revision, latest_branch, latest_revision)) def run(args): - if len(args) == 0 or args[0] == '-h' or args[0] == '--help': + if not args or args[0] == '-h' or args[0] == '--help': print_help() return 0 command = args[0] diff --git a/mesontest.py b/mesontest.py index b59d1ed..101ce5f 100755 --- a/mesontest.py +++ b/mesontest.py @@ -364,7 +364,7 @@ TIMEOUT: %4d return False def test_suitable(self, test): - return (len(self.options.include_suites) == 0 or TestHarness.test_in_suites(test, self.options.include_suites)) \ + return (not self.options.include_suites or TestHarness.test_in_suites(test, self.options.include_suites)) \ and not TestHarness.test_in_suites(test, self.options.exclude_suites) def load_suites(self): @@ -610,7 +610,7 @@ def run(args): if options.list: list_tests(th) return 0 - if len(options.args) == 0: + if not options.args: return th.doit() return th.run_special() diff --git a/run_project_tests.py b/run_project_tests.py index 149a183..9bba632 100755 --- a/run_project_tests.py +++ b/run_project_tests.py @@ -368,7 +368,7 @@ def _run_test(testdir, test_build_dir, install_dir, extra_args, compiler, backen if returncode != 0: return TestResult('Running unit tests failed.', BuildStep.test, stdo, stde, mesonlog, gen_time, build_time, test_time) # Do installation, if the backend supports it - if len(install_commands) != 0: + if install_commands: env = os.environ.copy() env['DESTDIR'] = install_dir # Install with subprocess @@ -384,7 +384,7 @@ def _run_test(testdir, test_build_dir, install_dir, extra_args, compiler, backen stde += e if pi.returncode != 0: return TestResult('Running clean failed.', BuildStep.clean, stdo, stde, mesonlog, gen_time, build_time, test_time) - if len(install_commands) == 0: + if not install_commands: return TestResult('', BuildStep.install, '', '', mesonlog, gen_time, build_time, test_time) return TestResult(validate_install(testdir, install_dir, compiler), BuildStep.validate, stdo, stde, mesonlog, gen_time, build_time, test_time) |