Commit Graph

416 Commits

Author SHA1 Message Date
Jussi Pakkanen 1aa68cf6e3 Merge pull request #1610 from valum-framework/vala-use-generate-basic-compiler-args
Use 'generate_basic_compiler_args' for Vala targets
2017-05-09 18:45:06 +03:00
Nicolas Schneider 39520d5688 vs: surround project guid with '{}'
Closes #1672.
2017-05-09 18:43:11 +03:00
Dylan Baker 7053d9abfd Allow link_depends to take strings, Files or generated objects. Closes #1172
Currently only strings can be passed to the link_depends argument of
executable and *library, which solves many cases, but not every one.
This patch allows generated sources and Files to be passed as well.

On the implementation side, it uses a helper method to keep the more
complex logic separated from the __init__ method. This also requires
that Targets set their link_depends paths as Files, and the backend is
responsible for converting to strings when it wants them.

This adds tests for the following cases:
- Using a file in a subdir
- Using a configure_file as an input
- Using a custom_target as an input

It does not support using a generator as an input, since currently that
would require calling the generator twice, once for the -Wl argument,
and once for the link_depends.

Also updates the docs.
2017-05-08 20:59:46 +02:00
Guillaume Poirier-Morency 904ed5a599 Use 'generate_basic_compiler_args' for Vala targets
Move '-C' option into 'get_always_args' as we always generate C sources.

Add a branch in the dependency management to perform Vala-specific work
of adding '--pkg' and '--target-glib'.
2017-05-08 14:58:52 -04:00
Alberto Aguirre ccab7d64f4 Add support for @CURRENT_SOURCE_DIR@ in generator arguments
Allow users to specify @CURRENT_SOURCE_DIR@ in generator arguments
to specify the current target source directory.
This is useful when creating protobuf generator objects in sub-directories
because protoc will then generate files in the expected location.

Fixes #1622.

Remove stray semicolon

Update documentation
2017-05-08 20:53:57 +02:00
Elliott Sales de Andrade bbcf0c0550 Serialize CustomTargets with newlines in command. 2017-05-05 17:23:36 -04:00
Elliott Sales de Andrade 7d6c6fe166 Remove extra quoting in swiftc invocation. 2017-05-05 16:27:01 -04:00
Patrick Griffis 60d560b5a7 ninja: Fix quoting newlines and $ 2017-05-05 16:27:01 -04:00
Peter Hutterer a576791064 Use American English - 'ise' -> 'ize' where applicable 2017-05-04 22:09:27 +03:00
Peter Hutterer ca924451ac Use American English: behaviour -> behavior 2017-05-04 22:09:27 +03:00
Jussi Pakkanen 108dac5c16 Store extra_files as file objects. Helps with #1686. 2017-05-04 00:17:33 +03:00
Jussi Pakkanen 8f49764896 Merge pull request #1717 from valum-framework/fix-descriptions-for-ninja-backend
ninjabackend: Use more consistent descriptions
2017-05-03 18:52:46 +03:00
Jussi Pakkanen 33b79dcf25 Kill RawFile dead! 2017-05-03 18:27:04 +03:00
Elliott Sales de Andrade a96d79cc00 ninjabackend: Don't pluralize twice custom target cleaning description 2017-05-02 18:45:56 -04:00
Guillaume Poirier-Morency 820fc8ee24 ninjabackend: Fix implicit comment for 'C#' rule description 2017-05-02 18:40:00 -04:00
Guillaume Poirier-Morency 253201d9bf ninjabackend: Add a set of raw names 2017-05-02 16:54:13 -04: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
Guillaume Poirier-Morency ce2e36fd6e ninjabackend: Fix typography for JAR and C# in descriptions 2017-05-02 10:44:35 -04:00
Guillaume Poirier-Morency f16232856e ninjabackend: Use 'custom targets' instead of 'CustomTarget' in description
The build definition is basically cleaning all the directories of all
custom targets.
2017-05-02 10:29:58 -04:00
Guillaume Poirier-Morency 91dc6a60df ninjabackend: Don't quote descriptions 2017-05-02 10:27:05 -04:00
Guillaume Poirier-Morency 3afc44973d ninjabackend: Use more consistent descriptions
Use a titlecase for arbitrary language, this was we don't have 'C' in
lowercase.

Rename 'Static linking library $out' for 'Linking static target $out.'.

Add missing punctuation.
2017-05-02 10:16:09 -04:00
Paolo Borelli 83c5c738dd Try to be locale-independent when we match VS output
Different locales have a different number of ':' in the string
we want to match. Closes #1639.
2017-04-29 12:35:47 +03:00
Jussi Pakkanen b6a3d34bd6 Replace cmd line arguments on install scripts. Closes #1681. 2017-04-28 17:26:37 +03:00
Guillaume Poirier-Morency aa486f5bb2 vala: Add 'VALAFLAGS' to considered environment variables
Fix precedence of arguments for Vala tasks and include those considered
external (i.e. '-Dvala_args' and 'VALAFLAGS').
2017-04-22 21:56:43 +03:00
Nirbheek Chauhan 61ed2702bf ninja: Don't use @file.rsp with ArLinker on Windows
We can't use @file.rsp on Windows with ArLinker because llvm-ar and
gcc-ar blindly pass the --plugin argument to `ar` and you cannot pass
options as arguments while using the @file.rsp syntax.

[5/7] cc @mylib@sta/libfile4.c.obj.rsp
[6/7] gcc-ar @libmylib.a.rsp
FAILED: libmylib.a
gcc-ar @libmylib.a.rsp
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/bin/ar.exe: invalid option -- @

https://github.com/mesonbuild/meson/pull/1649
https://ci.appveyor.com/project/jpakkane/meson/build/1.0.2330/job/w3hj9jfdasefsqi9
2017-04-21 17:21:57 +05:30
Jussi Pakkanen 0e45134dee Merge pull request #1628 from ximion/dfix
d: Fix linking shared libraries with DMD
2017-04-17 12:45:10 +03:00
Elliott Sales de Andrade 5b917a6e17 Skip all whole archive args if there aren't any.
No need to turn it on and off again if there's nothing requiring it.
2017-04-16 12:32:35 +03:00
Matthias Klumpp 52a56d441a d: Fix linking shared libraries with DMD 2017-04-15 18:40:11 +02:00
Jussi Pakkanen b48daeda1a Make it possible to only do unity builds on subprojects. 2017-04-15 18:28:36 +03:00
Jussi Pakkanen 4e1249c920 Merge pull request #1549 from mesonbuild/linkwhole
Add option to link the entire contents of a static library to a target.
2017-04-15 18:16:35 +03:00
Jussi Pakkanen b951e60f06 Merge pull request #1548 from ssssam/sam/stable-ordering
Stable ordering of some commandlines generated by 'gnome' module
2017-04-13 23:59:48 +03:00
Jussi Pakkanen 630d7a5175 Process VS dependency string as raw bytes. 2017-04-13 23:50:31 +03:00
Sam Thursfield 2db11f1383 Sort user commandline options when generating 'scan-build' target
We receive these options from the 'argparse' module in a random
order. To ensure the build.ninja file doesn't include random variations
we should sort them before writing them back out.
2017-04-12 21:37:25 +01:00
Nirbheek Chauhan c52963cd16 vala: Allow installation into default directories
For generated headers, vapis, and GIRs.

https://github.com/mesonbuild/meson/pull/1469#issuecomment-292814000
2017-04-12 23:33:02 +03:00
Nirbheek Chauhan 711c0cbd67 vs: Fix depend_files support in custom targets
This was totally broken and we didn't notice because we had no tests
for it at all.
2017-04-10 22:32:41 +05:30
Nirbheek Chauhan cdae69c0f8 vs: Pretty-print all vcxproj output
We were more hesitant to do this earlier because it might have messed
up custom_target command lines, but since we always use a wrapper for
that now, it should be ok to do this.

Add a test in the form of a funky generator script.
2017-04-10 22:32:41 +05:30
Nirbheek Chauhan 878b0f1401 Fix shared module installation directory on Windows 2017-04-10 03:38:04 +05:30
Jussi Pakkanen 0b772f37c0 Merge pull request #1575 from centricular/unit-tests-more-backends
Run unit tests on more backends
2017-04-09 22:12:57 +03:00
Jussi Pakkanen 1652dccea2 Merge pull request #1469 from centricular/install-secondary-outputs
Support multiple install dirs for built/custom targets
2017-04-09 21:57:46 +03:00
Nirbheek Chauhan 68c8bb49c3 vs: Pass absolute path of files to run_target
Fixes https://github.com/mesonbuild/meson/issues/957 for the VS backend
2017-04-09 23:11:36 +05:30
Jussi Pakkanen cbc8d6e537 Fix link whole on VS backend. 2017-04-08 22:50:53 +03:00
Jussi Pakkanen d152c1b5d5 Add option to link the entire contents of a static library to a target. 2017-04-08 22:14:09 +03:00
Jussi Pakkanen 761b28371a Merge pull request #1518 from centricular/mesonintrospect-evar
Export MESONINTROSPECT to postconf/install/run_command scripts
2017-04-08 21:25:25 +03:00
Jon Turney 600f16f9f8 Use extra_paths on Cygwin
Cygwin executables are still loaded by the Windows PE loader, so PATH needs
to include any extra directories where required DLLs can be found.

Cygwin uses a unix style ':'-separated PATH.  os.pathsep is used correctly
on extra_paths in meson_exe.py, but not in mesontest.py
2017-04-06 22:47:15 +01:00
Nirbheek Chauhan aa3480daba Reduce an indent level in the install for loop
if not t.should_install(): continue

No logic changes at all.

Also improve the message when erroring out about insufficient
install_dir: list elements.
2017-04-04 15:00:30 +05:30
Nirbheek Chauhan 98b1ce1cd9 Fix custom directory installation of import library
When install_dir was set for a shared_library, the import library
would not be installed at all, which is unintended.

Instead, install it into the custom directory if it is set, otherwise
install it in the default import library installation directory.

Includes a test for this.
2017-04-04 14:59:13 +05:30
Nirbheek Chauhan 57cb1f9aad Support multiple install dirs for built/custom targets
You can now pass a list of strings to the install_dir: kwarg to
build_target and custom_target.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Includes tests for all these.

Closes https://github.com/mesonbuild/meson/issues/705
Closes https://github.com/mesonbuild/meson/issues/891
Closes https://github.com/mesonbuild/meson/issues/892
Closes https://github.com/mesonbuild/meson/issues/1178
Closes https://github.com/mesonbuild/meson/issues/1193
2017-04-04 14:59:13 +05:30
Sam Thursfield f5b7cfdbf0 Ensure rules in the generated build.ninja file are in a stable order
Previously, two functionally identical builds could produce different
build.ninja files.  The ordering of the rules themselves doesn't affect
behaviour, but unnecessary changes in commandline arguments can cause
spurious rebuilds and if the ordering of the overall file is stable
than it's easy to use `diff` to compare different build.ninja files
and spot the differences in ordering that are triggering the unnecessary
rebuilds.
2017-04-03 17:02:41 +01:00
Jussi Pakkanen 553ac89e02 Review fixes. 2017-04-02 00:07:23 +03:00
Jussi Pakkanen 319398f074 Proxy object for overriding options transparently. 2017-04-02 00:07:23 +03:00