Commit Graph

502 Commits

Author SHA1 Message Date
Jussi Pakkanen bff37a90fc Merged buildrpath branch. 2017-07-21 22:19:07 +03:00
Patrick Griffis 67f0a1a44d Fix run_target() accepting ConfigureFile for command 2017-07-21 20:16:08 +03:00
Jussi Pakkanen 2269b7f60b Add build_rpath as new property allowing people to specify rpath entries that are used in the build tree but will be removed on install. 2017-07-21 19:40:54 +03:00
Jon Turney 3fa3922cea Support implibs for executables on Windows
Add a boolean 'implib' kwarg to executable().  If true, it is permitted to
use the returned build target object in link_with:

On platforms where this makes sense (e.g. Windows), an implib is generated
for the executable and used when linking.  Otherwise, it has no effect.

(Rather than checking if it is a StaticLibrary or SharedLibary, BuildTarget
subclasses gain the is_linkable_target method to test if they can appear in
link_with:)

Also install any executable implib in a similar way to a shared library
implib, i.e. placing the implib in the appropriate place

Add tests of:
- a shared_module containing a reference to a symbol which is known (at link
time) to be provided by the executable
- trying to link with non-implib executables (should fail)
- installing the implib

(This last one needs a little enhancement of the installed file checking as
this is the first install test we have which needs to work with either
MSVC-style or GCC-style implib filenames)
2017-07-20 21:11:56 +01:00
Jussi Pakkanen 5eb64a6f3e Revert "Merge pull request #1931 from centricular/use-patched-ninja"
This reverts commit aab7ada356, reversing
changes made to e1b24765af.
2017-07-18 00:30:52 +02:00
Nirbheek Chauhan e307865596 ninja backend: Detect ninja only once and log it
Needed for the CI, but good to have in general too.
2017-07-17 17:26:21 +05:30
Goncalo Carvalho bcb2556c69 add project/global args and include_dirs (useful for module maps) to swift targets 2017-06-29 11:04:57 -04:00
Jussi Pakkanen dfb0414d9c Merged Genie support. 2017-06-27 19:01:00 +03:00
Guillaume Poirier-Morency fab5634916 Add 'Compiler.get_display_language'
Use this when we print language-related information to the console and
via the Ninja backend.
2017-06-26 14:15:44 -04:00
Alistair Thomas cca0fa8154 Recognise .gs extension as a Vala source 2017-06-26 13:57:52 +01:00
Alistair Thomas e5559903b3 Split linkers out from compilers.py 2017-06-22 20:09:58 +01:00
Jussi Pakkanen 65d5ec5f18 Merge pull request #1922 from acfoltzer/rust-improvements
Enhance Rust support
2017-06-22 06:12:27 -04:00
Nirbheek Chauhan 185808bf16 vala: Only add --use-header for unity builds
Closes https://github.com/mesonbuild/meson/issues/1969
2017-06-22 06:07:45 -04:00
Adam C. Foltzer 6165612f6b fix indentation per @ignatenkobrain 2017-06-19 16:52:31 -07:00
Jussi Pakkanen cccb932f8f Expand magic markers on custom and run targets too. Closes #1681. 2017-06-19 14:09:57 -04:00
Adam C. Foltzer 35fae9d019 fix failing Rust test cases 2017-06-14 11:50:35 -07:00
Adam C. Foltzer 69b18cf7e9 rename `crate_type` to `rust_crate_type` per @TingPing 2017-06-14 08:39:41 -07:00
Nirbheek Chauhan d23e6b34c7 Preserve -L -l pairings fetched from external deps
While adding link args for external deps, sometimes different
libraries come from different prefixes, and an older version of the
same library might be present in other prefixes and we don't want to
accidentally pick that up.

For example:

/usr/local/lib/libglib-2.0.so
/usr/local/lib/pkgconfig/glib-2.0.pc
/usr/local/lib/libz.so
/usr/local/lib/pkgconfig/zlib.pc
/home/mesonuser/.local/lib/libglib-2.0.so
/home/mesonuser/.local/lib/pkgconfig/glib-2.0.pc

PKG_CONFIG_PATH="/home/mesonuser/.local/lib/pkgconfig/:/usr/local/lib/pkgconfig/"

If a target uses `dependencies : [glib_dep, zlib_dep]`, it will end up
using /usr/local/lib/libglib-2.0.so instead of
/home/mesonuser/.local/lib/libglib-2.0.so despite using the pkg-config
file in /home/mesonuser/.local/lib/pkgconfig because we reorder the -L
flag and separate it from the -l flag.

With this change, external link arguments will be added to the
compiler list without de-dup or reordering.

Closes https://github.com/mesonbuild/meson/issues/1718
2017-06-12 20:55:19 +05:30
Nirbheek Chauhan d38f3deaed gnome: Work around GNU ld bug with -rpath,$ORIGIN
g-ir-scanner doesn't understand -rpath, so we use -L instead which
has the same effect.

Closes https://github.com/mesonbuild/meson/issues/1911
2017-06-11 14:32:39 +05:30
Adam C. Foltzer bdd4c45b17 Enhance Rust support
- Adds a `crate_type` kwarg to library targets, allowing the different
  types of Rust [linkage][1].
- Shared libraries use the `dylib` crate type by default, but can also
  be `cdylib`
- Static libraries use the `rlib` crate type by default, but can also
  be `staticlib`
- If any Rust target has shared library dependencies, add the
  appropriate linker arguments, including rpath for the sysroot of the
  Rust compiler

[1]: https://doc.rust-lang.org/reference/linkage.html
2017-06-09 15:14:02 -07:00
Jussi Pakkanen 62051626a5 Merge pull request #1545 from centricular/dont-link-recursively
Don't add dependencies recursively while linking
2017-06-04 14:07:27 +03:00
Jussi Pakkanen 4828b46b73 Use relative rpath so builds are reproducible. 2017-06-03 16:03:53 +03:00
Nirbheek Chauhan 4b428053f4 ninja: Use shlex.quote for quoting on non-Windows
This is more reliable, and more accurate. For instance, this means
arguments in commands aren't surrounded by `'` on Linux unless that
is actually needed by that specific argument.

There is no equivalent helper for Windows, so we keep the old
behaviour for that.
2017-06-02 10:41:13 +05:30
Nirbheek Chauhan d2dc38abd4 ninja: Use a set for target deps and ordered deps
This significantly reduces the size of build.ninja for GStreamer.
2017-06-02 05:32:16 +05:30
Alistair Thomas a195b78c8d Whitespace tweaks to reduce Flake8 warnings 2017-05-29 19:32:47 +03:00
Bálint Aradi 809a5938ff Fix case sensitivity in Fortran module names 2017-05-26 23:21:27 +03:00
Rob Doolittle 56b41d1c79 mesontest: use unbuffered IO
This helps when running mesontest as part of CI.
2017-05-24 20:00:47 +03:00
Ole André Vadla Ravnås b595cda4ed Fix cross environment pollution.
Environment variables like CFLAGS and LDFLAGS should not affect the
cross environment.

Fixes #1772
2017-05-21 23:04:19 +03:00
Elliott Sales de Andrade ea636fcd51 Remove unused variables. 2017-05-17 04:41:54 -04:00
Elliott Sales de Andrade 65b1d33931 Remove unused imports. 2017-05-17 03:42:16 -04:00
Jussi Pakkanen 18b11489cf Merge pull request #1775 from mesonbuild/covupdate
Better coverage report
2017-05-14 11:55:02 +03:00
Ole André Vadla Ravnås 9b5df6e442 ninja: Deduplicate dependent vapis
The Vala compiler does not like being fed the same .vapi multiple times.
2017-05-14 11:54:42 +03:00
Jussi Pakkanen 08bd92a6ae Merge pull request #1788 from aradi/fix-fortran-scan
Fix scanning of Fortran sources created during configuration
2017-05-13 23:24:14 +03:00
Ole André Vadla Ravnås 97339d3be4 ninja: Also include Vala headers in generated headers 2017-05-13 22:59:06 +03:00
Jon Turney 61a145fcb5 Implement executable(gui_app:) for gcc on Windows
Note that gui_app: is currently ignored when using the ninja backend with VS
compilers, so I guess you get the default linker behaviour, which the
documentation says is guessing the subsystem depending on if a main or
WinMain symbol exists...
2017-05-13 22:58:06 +03:00
Jussi Pakkanen 111e3df45d Moved coverage commands to a standalone script. 2017-05-13 22:54:08 +03:00
Jussi Pakkanen c2282f9382 Merged rust_args branch. 2017-05-13 22:51:43 +03:00
Jussi Pakkanen 84012a5099 Merge pull request #1669 from mesonbuild/dist
Create a dist target
2017-05-12 19:37:31 +03:00
Jon Turney e99cfdfbc7 Make vs_module_defs: do something for gcc on Windows as well
Module definition files may be useful when building with gcc on Windows also
(e.g. if the existing build uses them, if exports are aliased, if we were
retro enough to export by ordinal, etc.)

Add the .def file to the link command line when using gcc on Windows

Run the appropriate windows tests irrespective of compiler.
2017-05-12 18:56:43 +03:00
Bálint Aradi 540fd2f0e0 Fix scanning of Fortran sources created during configuration 2017-05-12 14:34:19 +02:00
Jussi Pakkanen a91aed8854 Test created tarball by doing a full build + test + install cycle. 2017-05-11 19:34:16 +03:00
Jussi Pakkanen 255be79e22 Created a dist target. Closes #877. 2017-05-11 19:34:16 +03:00
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
Patrick Griffis b520a4f030 rust: Support rust_args 2017-05-08 15:25:52 -04: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 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
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
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 878b0f1401 Fix shared module installation directory on Windows 2017-04-10 03:38:04 +05:30
Jussi Pakkanen 1652dccea2 Merge pull request #1469 from centricular/install-secondary-outputs
Support multiple install dirs for built/custom targets
2017-04-09 21:57:46 +03:00
Jussi Pakkanen 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
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
Jussi Pakkanen cf97c7af81 Use get_option_for_target for builtins where sensible. 2017-04-02 00:07:23 +03:00
Jussi Pakkanen 7b66ff8921 Create unity files with the VS backend. 2017-04-02 00:04:45 +03:00
Jussi Pakkanen e5a6283c4c Add MVP implementation of overriding options. 2017-04-02 00:04:45 +03:00
Jussi Pakkanen 571451b521 Merge pull request #1346 from msink/test-mingw
appveyor: run tests against MSYS2-MinGW
2017-03-29 22:52:14 +03:00
Patrick Griffis 9929e0efac rust: Support executable name differing from source name 2017-03-29 21:09:51 +03:00
Nirbheek Chauhan 976c9abcd0 modules: Start using @SOURCE_ROOT@ and @BUILD_ROOT@
First step in fixing https://github.com/mesonbuild/meson/issues/1419

Also works around an issue in the MinGW windres.exe that causes it to
fail if any of the arguments passed to it contain a space. There seems
to be no way to quote or escape the spaces in the path to make windres
parse the path correctly, so we just warn about it instead.

https://sourceware.org/bugzilla/show_bug.cgi?id=4933
https://github.com/mesonbuild/meson/pull/1346
2017-03-28 14:49:32 +05:30
Nirbheek Chauhan 2376d6eadf Don't delete static library on Windows
The actual fix is quite involved (#1526), so just disable this for now
since it's much worse to not be able to generate static libraries at
all vs a minor bug in static libraries getting stale objects (#1356)

Closes https://github.com/mesonbuild/meson/issues/1517
2017-03-27 23:11:26 +03:00
Nirbheek Chauhan 27f5f0a963 Export MESONINTROSPECT to postconf/install/run_command scripts
Points to the `mesonintrospect.py` script corresponding to the
currently-running version of Meson.

Includes a test for all three methods of running scripts/commands.

Closes https://github.com/mesonbuild/meson/issues/1385
2017-03-28 00:55:01 +05:30
Jussi Pakkanen d668bea11d Merge pull request #1496 from centricular/fix-internal-dep-order
Preserve internal-dep include order in build target dependencies
2017-03-25 18:55:47 +02:00
Elliott Sales de Andrade aeb694d9c3 Cache compiler args for each target.
Adding together a bunch of include directories can be very slow if done
for each source of a target.
2017-03-25 18:44:49 +02:00
Nirbheek Chauhan 7f80f81ac9 Preserve the order of internal deps in a target
We were adding them to the CompilerArgs instance in the order in which
they are specified, which is wrong because later dependencies would
override previous ones. Add them in the reverse order instead.

Closes https://github.com/mesonbuild/meson/issues/1495
2017-03-23 10:26:29 +05:30
Thibault Saunier 2c6627d573 Also cleanup custom target paths for not installed not default targets 2017-03-20 18:47:46 -04:00
Jussi Pakkanen 2ecb26c9ae Merge pull request #1444 from mesonbuild/pdbinstall
Install PDB files. Closes #1442.
2017-03-04 05:52:33 -05:00
Jussi Pakkanen b3aaab3a03 Have all compiler invocations in compdb. Closes #1439. 2017-03-04 05:51:56 -05:00
Nirbheek Chauhan 303b8819ec Nuke dead code which was used for installing PDB files
We check for the existence of PDB files in the install script, so we
don't need to do all this mucking about here. That's more robust too
because we don't need to parse build arguments in buildtype=plain
and decide if the PDB file would be generated.
2017-03-03 15:52:31 +05:30
Jussi Pakkanen b927468137 Use cross stripper when cross compiling and allow overriding native strip executable. Closes #1414. 2017-02-27 16:49:32 -05:00
Fabio Porcedda 7cece438cc ninjabackend: generate "compile_commands.json" even for cross compile
Just add 'c_CROSS_COMPILER' and 'cpp_CROSS_COMPILER' to the
'ninja -t compdb' command.
2017-02-26 07:27:51 -05:00
Nirbheek Chauhan a14eba27a9 ninja: Delete output static lib before calling `ar`
Otherwise if the list of sources changes on reconfigure after building,
the static library will contain both the old and new objects.

Closes https://github.com/mesonbuild/meson/issues/1355
2017-02-18 02:38:54 +05:30
Matthieu Gautier fab04b1fbe Change the order of link_args when cross_compiling with ninja.
A user may want to add libraries to link with in the (c|cpp)_link_args
property of the cross-compile file.
Those libraries should be at the end of the command line due to reference
resolution mechanism of the compiler.

By moving the cross_args after LINK_ARGS we are sure that specific
cross-compilation libraries are at the end of the command line.

See [github PR #1363](https://github.com/mesonbuild/meson/pull/1363) to
have the context of this change.
2017-02-06 15:17:17 +01:00
Matthieu Gautier 0b2146c8f7 Use named field for command_template when generating ninja command.
The command template become easier to read with named field.
2017-02-06 11:51:46 +01:00
Nirbheek Chauhan ccb0580f4f ninja: Don't scan generated fortran files for mod deps
See: https://github.com/mesonbuild/meson/issues/1348
2017-02-02 19:40:42 +02:00
Jussi Pakkanen 4a08841331 Merge pull request #1335 from tp-m/test-custom-target-used-in-test-cmd
tests: check custom target output is created before being used in a t…
2017-01-28 19:05:54 +02:00
Nirbheek Chauhan 50c4851daa Use CompilerArgs for generation of link commands
Also, now the linker options are added from various sources in the same
order as compiler arguments for compile commands. As a result, all
libraries and library paths from external and internal sources are added
after all the linker options have been added.

As a result option_link_args() are added when libraries are added to the
list since currently the only thing they add are the libraries specific
in cpp_winlibs/c_winlibs. This fixes an issue where compilation with the
MinGW toolchain (which uses static libraries for winlibs) would result
in undefined symbol errors because the static libraries would be added
in the very beginning and hence would not be scanned for symbols.

Detailed comments have been added that explain where each option is
coming from and why it's been added at that specific point.

More improvements are necessary here because we currently still
unnecessarily repeat libraries from dependencies over and over, which
is a major problem in gst-build because inter-subproject dependencies
cause linker command-lines to almost exceed the argument list length
limit imposed by the kernel. It is also causing us to unnecessarily
add static libraries which have already been linked into a shared
library. See: self.build_target_link_arguments()
2017-01-28 05:10:00 +05:30
Nirbheek Chauhan 2bb58c909f Use CompilerArgs for generation of compile commands
At the same time, also fix the order in which compile arguments are
added. Detailed comments have been added concerning the priority and
order of the arguments.

Also adds a unit test and an integration test for the same.
2017-01-28 05:09:51 +05:30
Nirbheek Chauhan fc4e332601 backends: Add support for build_by_default to vs2010 backend
Always generate the vcxproj file, but only add it to the build
configuration if it's either supposed to be built by default, or is
a dependency of another target that is built by default.
2017-01-28 01:05:20 +05:30
Nirbheek Chauhan 01547e8c61 ninja: Fix build_by_default=false targets in tests
Previously, build_by_default=false targets would not be built at all
even if they were used in a test (as the exe or as a command-line
argument) which would lead to a test failure.

Now we look into all the defined tests and add all CustomTargets and
BuildTargets used in them to the list of build_by_default targets.
2017-01-28 01:05:19 +05:30
Nirbheek Chauhan dbcbf19ece compilers: New class CompilerArgs derived from list()
The purpose of this class is to make it possible to sanely generate
compiler command-lines by ensuring that new arguments appended or added
to a list of arguments properly override previous arguments.
For instance:

>>> a = CompilerArgs(['-Lfoo', '-DBAR'])
>>> a += ['-Lgah', '-DTAZ']
>>> print(a)
['-Lgah', '-Lfoo', '-DBAR', '-DTAZ']

Arguments will be de-duped if it is safe to do so. Currently, this is
only done for -I and -L arguments (previous occurances are removed when
a new one is added) and arguments that once added cannot be overriden
such as -pipe are removed completely.
2017-01-27 23:42:22 +05:30
Nirbheek Chauhan 7d6f628ed4 Support file perms for install_data and install_subdir
With the 'install_mode' kwarg, you can now specify the file and
directory permissions and the owner and the group to be used while
installing. You can pass either:

* A single string specifying just the permissions
* A list of strings with:
  - The first argument a string of permissions
  - The second argument a string specifying the owner or
    an int specifying the uid
  - The third argument a string specifying the group or
    an int specifying the gid

Specifying `false` as any of the arguments skips setting that one.

The format of the permissions kwarg is the same as the symbolic
notation used by ls -l with the first character that specifies 'd',
'-', 'c', etc for the file type omitted since that is always obvious
from the context.

Includes unit tests for the same. Sadly these only run on Linux right
now, but we want them to run on all platforms. We do set the mode in the
integration tests for all platforms but we don't check if they were
actually set correctly.
2017-01-24 00:20:51 +05:30
Jussi Pakkanen 469a758c32 Merge pull request #1320 from centricular/fix-llvmir-and-assembly
Fix llvmir and assembly
2017-01-23 20:42:47 +02:00
Nirbheek Chauhan f71136b89e Print the problematic headers in these assertions 2017-01-21 20:17:21 +05:30
Mike Sinkovsky 969be1f679 cleanup: Remove redundant parentheses 2017-01-18 21:22:47 +02:00
Jussi Pakkanen cfc33ac421 Merge pull request #1303 from mesonbuild/buildonall
Add kwarg build_by_default
2017-01-15 21:28:10 +02:00
Jussi Pakkanen 21d8505825 build_by_default it is. 2017-01-15 20:14:46 +02:00
Jussi Pakkanen 58878b998d Get rid of hasattr. 2017-01-15 19:45:23 +02:00
Jussi Pakkanen db8ad2a4bd Add test for build_on_all. 2017-01-15 19:45:23 +02:00
Jussi Pakkanen b1087f011c Moved detection of targets to build on all into own function. 2017-01-15 19:45:23 +02:00
Elliott Sales de Andrade 78b030cf19 Add support for Files passed to generators.
I need this for windows.compile_resources to be able to use
configure_file results, but it may have other benefits.
2017-01-12 03:25:08 -05:00
Mike Sinkovsky 5b626ab4cb style: [E1**] Indentation 2017-01-11 12:33:27 -05:00
Mike Sinkovsky ab4f7b56ce style: [E272] multiple spaces before keyword 2017-01-11 12:33:27 -05:00
Mike Sinkovsky 84902cb93a style: [E301] expected 1 blank line, found 0 2017-01-11 12:33:27 -05:00
Mike Sinkovsky e9a891fe25 style: [E502] the backslash is redundant between brackets 2017-01-11 12:33:27 -05:00
Jussi Pakkanen 56e2c46ce1 Merge pull request #1272 from mesonbuild/ignatenko/lint
fix some linting errors
2017-01-03 16:04:24 -05:00
Philipp Geier 54697b4130 ICC 17.0.0 working for Linux and Ninja Backend.
Added IntelCompiler, IntelCCompiler and IntelCCompiler.
environments.py has been changed to detect icc and icpc.
ninjabackend changed for proper pch generation.

ICC 17.0.0 does not support C++13 (that's why default arguments tests fails).
Test 25 object extraction fails due to some unescaped whitespaces.
Some test with vala fail because of successful build, although they
should fail, as warning do not exit with failure.
2017-01-04 00:40:54 +05:30
Igor Gnatenko f4058b692d backends/ninja: remove unused variable
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2017-01-02 17:07:23 -05:00
Igor Gnatenko cdd05aa5dc style: fix E241 violations
E241: multiple spaces after ','

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2017-01-02 19:12:52 +01:00
Igor Gnatenko 116da33cdd style: fix E128 violations
E128: continuation line under-indented for visual indent

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2017-01-01 12:02:05 -05:00
Igor Gnatenko 5693758e46 style: fix E231 violations
E231: missing whitespace after ','

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2017-01-01 12:02:05 -05:00
Igor Gnatenko 2a835c2c10 style: fix E221 violations
E221: multiple spaces before operator

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2017-01-01 12:02:05 -05:00
Igor Gnatenko ef608f217d style: fix E222 violations
E222: multiple spaces after operator

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2017-01-01 12:02:05 -05:00
Igor Gnatenko 2017d8578a style: fix E226 violations
E226: missing whitespace around arithmetic operator

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2017-01-01 12:02:05 -05:00
Igor Gnatenko f0b30baa39 style: fix E225 violations
E225: missing whitespace around operator

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2017-01-01 12:02:05 -05:00
Igor Gnatenko 15629d2fae backends/ninja: remove unused variables
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2017-01-01 12:02:05 -05:00
Hemmo Nieminen 504f974204 Pass project's user options to scan-build temporary project.
This allows (among other things) scan-build to process a project's
optional components that will not get built unless a (user) option has
been set.
2016-12-31 14:08:15 +02:00
Jussi Pakkanen 0a14ad63de Add simple uninstall target. Closes #753. 2016-12-31 13:55:55 +02:00
Nirbheek Chauhan 0ac965cc10 Fix shared library symlink aliasing on install
Set the rules for the symlinking on the target itself, and then reuse
that information while generating aliases during the build, and then
pass it to the install script too.
2016-12-22 02:27:01 +05:30
Jussi Pakkanen a2528a8816 Merge pull request #1233 from mesonbuild/wip/ignatenko/code-style
Trivial cleanups in code
2016-12-21 00:09:44 +02:00
Igor Gnatenko 139e020ede tree-wide: use proper 'not in' notation
Let's be more pythonic and 'not is' seems really weird.

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-12-19 21:48:35 +01:00
Igor Gnatenko e611b6748b tree-wide: remove unused variables
./mesonbuild/scripts/regen_checker.py:35:5: F841 local variable 'scriptdir' is assigned to but never used
    scriptdir = os.path.split(__file__)[0]
    ^
./mesonbuild/scripts/yelphelper.py:84:13: F841 local variable 'symfile' is assigned to but never used
            symfile = os.path.join(install_dir, m)
            ^
./mesonbuild/backend/backends.py:164:13: F841 local variable 'lang' is assigned to but never used
            lang = comp.get_language()
            ^
./mesonbuild/backend/ninjabackend.py:1286:9: F841 local variable 'scriptdir' is assigned to but never used
        scriptdir = self.environment.get_script_dir()
        ^
./mesonbuild/backend/vs2010backend.py:736:9: F841 local variable 'additional_options_set' is assigned to but never used
        additional_options_set = True
        ^

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-12-19 18:22:20 +01: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 7d71e9f8b2 backend/ninja: pass language name instead of compiler
Traceback (most recent call last):
  File "F:\avian\meson\mesonbuild\mesonmain.py", line 289, in run
    app.generate()
  File "F:\avian\meson\mesonbuild\mesonmain.py", line 179, in generate
    g.generate(intr)
  File "F:\avian\meson\mesonbuild\backend\ninjabackend.py", line 185, in generate
    self.generate_rules(outfile)
  File "F:\avian\meson\mesonbuild\backend\ninjabackend.py", line 745, in generate_rules
    self.generate_compile_rules(outfile)
  File "F:\avian\meson\mesonbuild\backend\ninjabackend.py", line 1530, in generate_compile_rules
    self.generate_llvm_ir_compile_rule(compiler, True, outfile)
  File "F:\avian\meson\mesonbuild\backend\ninjabackend.py", line 1386, in generate_llvm_ir_compile_rule
    ' '.join(self.get_cross_info_lang_args(compiler, is_cross)),
  File "F:\avian\meson\mesonbuild\backend\ninjabackend.py", line 1406, in get_cross_info_lang_args
    return self.environment.cross_info.config['properties'][lang + '_args']
TypeError: unsupported operand type(s) for +: 'ClangCCompiler' and 'str'

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-12-19 17:09:35 +02:00
Igor Gnatenko d5ccd20aac fix some of pylint's undefined-variable
************* Module mesonbuild.modules.rpm
E:106,29: Unsupported format character '{' (0x7b) at index 16 (bad-format-character)
************* Module mesonbuild.modules
E: 12,14: Undefined variable 'MesonException' (undefined-variable)
************* Module mesonbuild.modules.gnome
E:699,69: Undefined variable 'sargs' (undefined-variable)
************* Module mesonbuild.wrap.wrap
E:103,25: Undefined variable 'checkoutdir' (undefined-variable)
************* Module mesonbuild.backend.backends
E: 83,16: Undefined variable 'mlog' (undefined-variable)
************* Module mesonbuild.backend.ninjabackend
E:254,105: Undefined variable 't' (undefined-variable)

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-12-19 17:09:35 +02:00
Jussi Pakkanen 21e475b64b Merge pull request #1194 from centricular/critical-bugfixes-vala
A bunch of bugfixes for Vala
2016-12-15 22:20:03 +02:00
Nirbheek Chauhan e6f48a03fc Allow all code to access module target classes
It is often useful to be able to check if a specific object is of a type
defined in a module. To that end, define all such targets in
modules/__init__.py so that everyone can refer to them without poking
into module-specific code.
2016-12-15 04:12:23 +05:30
Nirbheek Chauhan 79f6626867 Pass --gresources to valac for each compiled gresource
Without this, the user has to both compile the resource with
gnome.compile_resources, pass that to the target sources, and also
pass --gresources=/path/to/gres.xml to vala_args in the target.

With this, we will do that automatically.
2016-12-15 04:12:23 +05:30
Nirbheek Chauhan fc540b72a6 vala: Fix duplicate output detection
The same vapi or vala might be added multiple times. Don't freak out if
that happens. Only freak out if a vapi or vala generated source by the
same name and the output same path is added twice.

This should never happen anyway since we would refuse to create the
target in the first place in theory, but it might happen because of bugs
in generators and custom targets.

Closes #1084
2016-12-15 04:12:23 +05:30
Jussi Pakkanen b01d2c35b7 Only add build dir inlude directives if the corresponding dir exists. Closes #1185. 2016-12-13 14:19:34 +02:00
Nirbheek Chauhan 038b15a7b2 Add __repr__ for ExtractedObjects and better error for Vala libraries 2016-12-13 09:37:47 +05:30
Nirbheek Chauhan 82a77609e8 Query the target itself for the dynamic linker
This greatly improves the logic for determining the linker. Previously,
we would completely break if a target contained only extracted objects
and we were using more than one compiler in our project.

This also fixes determination of the linker if our target only contains
generated objc++ sources, and other funky combinations.
2016-12-13 09:37:47 +05:30
Nirbheek Chauhan 7b3d00fee4 Use dict for self.build.compilers instead of list
Everywhere we use this object, we end up iterating over it and comparing
compiler.get_language() with something. Using a dict is the obvious
choice and simplifies a lot of code.
2016-12-13 09:20:34 +05:30
Jussi Pakkanen 5787a4b4fb Make Java compilation work with inner classes. Closes #1157. 2016-12-12 21:01:10 +02:00
Nirbheek Chauhan 70f39ee21e unity builds: Assembly and LLVM IR are incompatible
Can't just #include them and use them directly in unity builds. Inline
assembly is a thing, but it's not trivial and is deprecated with some
compilers. Just build them separately and link them in. Ideally the user
would then use LTO to ensure the same result.
2016-12-11 14:54:30 +05:30
Nirbheek Chauhan 04c1909a4d compilers: Implement support for LLVM IR compilation
Also C++ compilers can build .S assembly files. This wasn't noticed
earlier because most people were also using C compilers in their C++
projects and we would fall back to using the C compiler for building the
assembly files. Now we have a test for this.

This was trivial to add; except that we needed a new LLVM IR rule
because the compiler emits warnings if you pass any special arguments to
it such as include arguments or dependency arguments.

Closes #1089
2016-12-11 14:54:30 +05:30
Nirbheek Chauhan 60716fcd6d Use universal_newlines=True for all Popen calls
Instead of adding it everywhere manually, create a wrapper called
mesonlib.Popen_safe and use that everywhere that we call an executable
and extract its output.

This will also allow us to tweak it to do more/different things if
needed for some locales and/or systems.

Closes #1079
2016-12-11 01:59:58 +02:00
Jussi Pakkanen f62f730821 Merge pull request #1126 from mesonbuild/sharedmodule
Support for shared modules
2016-12-07 21:49:16 +02:00
Jussi Pakkanen dc1f537fb3 Skip shared module test on VS because it fails for some reason nobody understands. 2016-12-07 00:30:28 +02:00
Nirbheek Chauhan c7a2664cb7 Better error when passing invalid objects to install_header
This will print the object type when you pass a generated file to
install_header instead of printing an assert.
2016-12-06 20:27:33 +02:00
Thibault Saunier 10e2b9bca0 mesontest: Rebuild all before running tests
Only supporting ninja backend for now.
2016-12-03 22:41:31 +02:00
Nirbheek Chauhan e1c9d94708 Allow many version conditions for pkg-config deps
Sometimes we want to restrict the acceptable versions to a list of
versions, or a smallest-version + largest-version, or both. For
instance, GStreamer's opencv plugin is only compatible with
3.1.0 >= opencv >= 2.3.0
2016-12-03 21:46:20 +02:00
Jussi Pakkanen 04a2e6ded3 Do not use -install_name or -shared when building modules on OSX,
but do use -bundle. Closes #1112.
2016-12-02 22:28:18 +02:00
Jussi Pakkanen 6d84b9b646 Created new shared module build target type, and make sure -Wl,--no-undefined is not used when linking it. 2016-12-02 21:55:56 +02:00
Jussi Pakkanen 07d7e87411 Allow soname to be an arbitrary string and fix symlink generation. 2016-11-26 22:16:05 +02:00
Jussi Pakkanen c9a46fcc93 Can set compiler arguments in Java. 2016-11-20 16:57:58 -05:00
Jussi Pakkanen 8f41154827 Can specify headers to install with Files. 2016-11-20 16:52:45 -05:00
Jussi Pakkanen aa9668a2fc Merge pull request #730 from mesonbuild/newtest
New testing tool
2016-11-20 16:07:32 -05:00
Jussi Pakkanen a01919976e Always specify installed data with a File object. Closes #858. 2016-11-18 17:37:35 -05:00
Jussi Pakkanen 1ebc5c1ea0 Can run special tests with the new tool. 2016-11-18 22:10:22 +02: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 0d619df2f3 Removed subsuite targets. 2016-11-18 22:04:29 +02:00
Jussi Pakkanen 951262d759 Removed Valgrind from core. 2016-11-18 22:04:29 +02:00
Guillaume Poirier-Morency b2a39dd06e vala: Generate GIR into the build directory (fix #185)
Add a Vala test generating GIR and typelib files.
2016-11-12 18:03:24 -05:00
Thibault Saunier 85a0cd7635 Add new add_project_[link]_args functions
Fixes 979
2016-11-12 17:34:06 -05:00
Nirbheek Chauhan 085650a1e3 vala: Implement valac.find_library
Move CCompiler.compile to Compiler.compile so that ValaCompiler can use
it. Also rewrite ValaCompiler.sanity_check to use it since it does
a simple compile check.

At the same time, it enhances ExternalLibrary to support arguments for
languages other than C-like.

Includes a test for this that links against zlib through Vala.

Closes #983
2016-11-12 13:56:17 -05:00
Jussi Pakkanen 1e0ae0a083 Revert "vala: Build with '--nostdpkg'", MR #920
This reverts commit 0f098c37ae.
2016-11-12 18:46:51 +02:00
Guillaume Poirier-Morency 0f098c37ae vala: Build with '--nostdpkg'
Since Vala require 'glib-2.0' and 'gobject-2.0' dependencies, it's
better to fail at 'valac' step with meaningful error.

Add missing 'gobject-2.0' dependency on the mixed source test case.
2016-11-12 10:55:47 -05:00
Jussi Pakkanen e02aaad632 Merge pull request #1011 from centricular/runtarget-files-rel-builddir
ninja: Pass absolute path of files to run targets
2016-11-10 14:47:35 -05:00
Jussi Pakkanen fd425d56a5 Merge pull request #991 from mesonbuild/wip/tingping/gresource-depfile
gnome: Use depfile support of recent glib-compile-resources
2016-11-10 14:08:32 -05:00
Nirbheek Chauhan 88f1d400c0 Fix debug PCH builds with MSVC 2012 and later
With MSVC 2013 and newer, using pre-compiled headers with .pdb debugging
fails with the following error message:

fatal error C1041: cannot open program database '[...]\prog.pdb'; if multiple CL.EXE write to the same .PDB file, please use /FS

So we use /FS when PCH is enabled. When PCH is enabled and debugging is
disabled, this will have no effect since .pdb files will not be written.
2016-11-10 00:40:16 +05:30
Patrick Griffis 573b3afb52 backends: Output depfiles in same directory as target 2016-11-09 17:39:30 +01: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
Nirbheek Chauhan b1898fd139 ninja: Pass absolute path of files to run targets
We already pass everything else (custom targets, build targets, etc) as
absolute paths, and this is the only sane way to handle this till we
rework the codebase to use File objects everywhere (after reworking the
File object itself).

Fixes https://github.com/mesonbuild/meson/issues/957
2016-11-09 03:04:37 +05:30
Jussi Pakkanen 841380acfe Search for headers in build dir before source dir. Closes #984. 2016-11-08 15:00:42 -05:00
Jussi Pakkanen 1cf787f281 Added reconfigure target that always reruns Meson. 2016-11-06 09:10:04 -08:00
Tim-Philipp Müller d37bbef411 ninjabackend: fix error message 2016-11-05 03:10:36 -07:00
Jussi Pakkanen 72995b5800 Do not error out if compdb can not be created. 2016-11-02 13:48:24 -07:00
Jussi Pakkanen 33323bb7e3 Merge pull request #952 from centricular/deterministic-sources-outputs
Ninja: Use OrderedDict in places where order matters
2016-10-26 14:16:18 -07:00
Jussi Pakkanen 2d058bdcff Merge pull request #912 from valum-framework/wip/vala-custom-header-and-vapi
vala: Custom header and vapi name (fix #892)
2016-10-25 10:06:49 -07:00
Guillaume Poirier-Morency 66518d4dad vala: Use a portable path join for the VAPI 2016-10-25 10:57:40 -04:00
Nirbheek Chauhan 706425abd1 Ninja: Use OrderedDict in places where order matters
Specifically, wherever we have sources or outputs, we want to use an
OrderedDict so that the build is always deterministic. It was reported
by Olexa Bilaniuk that `ar D` creates static libraries with different
checksums depending on the order of the object files.

See: https://github.com/mesonbuild/meson/pull/951

We don't actually want to preserve the order in which they are listed.
We just want the order to be deterministic and predictable.
2016-10-25 14:36:16 +05:30
Guillaume Poirier-Morency 114b5b0637 vala: Use 'vala_header' and 'vala_vapi' directly
Move the fallback logic into 'BuildTarget.process_kwargs' to use the
target name instead.
2016-10-24 18:01:27 -04:00
Guillaume Poirier-Morency ff6b3c7a2d vala: Custom header and vapi name (fix #892) 2016-10-24 18:01:27 -04:00
Nirbheek Chauhan 7e9203fac9 Fix Unity builds for Fortran and D targets
Also warn if we're trying to use a unity build on a target with fortran
or D sources.
2016-10-21 08:39:12 +05:30
Nirbheek Chauhan 57ce7d4618 Add support for extracting objects in unity builds
Not only does extract_all_objects() now work properly again,
extract_objects() also works if you specify a subset of sources all of
which have been compiled into a single unified object.

So, for instance, this allows you to extract all the objects
corresponding to the C sources compiled into a target consisting of
C and C++ sources.
2016-10-21 08:00:39 +05:30
Nirbheek Chauhan b070f505d3 ninja: Generate Vala compile rules after all header_deps are found
Same reason as generated C sources
2016-10-21 08:00:39 +05:30
Nirbheek Chauhan 8bee336e2a ninja: Always use RawFilename for unity sources and deps
The use of has_dir_part is a terrible back that we need to move away
from. This will eventually be fixed by always using File() objects
everywhere. For now, this is needed for unity builds to work.
2016-10-21 07:30:02 +05:30
Nirbheek Chauhan 65e9761cb1 Support all kinds of generated vala and vapi sources
This is the first step in making Vala support have feature-parity with
C/C++ support. Vala and Vapi sources generated with Generators and
CustomTargets are no longer ignored. Dependencies are setup properly and
they are added to the commandline.
2016-10-19 20:46:04 +05:30
Nirbheek Chauhan 23b060f0aa Ninja: Consolidate generated sources handling
Pre-calculate the output directory for GeneratedList and CustomTarget so
we can directly use the same code for both while compiling C/C++ files
and headers.

There is no reason to have separate branches for GeneratedList and
CustomTarget since both can be used in almost exactly the same way for
generating sources.

This is going to used next for adding generated sources support to Vala.
2016-10-19 20:46:04 +05:30
Nirbheek Chauhan 092c593acd Process dependencies for all targets not just C/C++
This isn't useful yet because we currently only have dependencies for
C/C++ targets (the rest all use link deps), but we will need this for
Vala, Rust, and more.
2016-10-19 20:42:11 +05:30
Nirbheek Chauhan 419b84784f CustomTarget: Use get_outputs() instead of get_filename()
get_filename() made no sense for CustomTarget since it can have multiple
outputs. Also use get_outputs() for GeneratedList since it has the same
meaning and remove unused set_generated().

As a side-effect, we now install all the outputs of a CustomTarget.
2016-10-19 20:42:11 +05:30
Nirbheek Chauhan 4332df01b8 Add no-warning args while building Vala C code
This is done by adding a new compiler method called 'no_warn_args' which
returns the argument(s) required for the compiler to emit no warnings
for that compilation.

This take care of not disabling warnings for C code compiled into the
BuildTarget. Also includes tests for ensuring all this.

https://github.com/mesonbuild/meson/issues/864
2016-10-14 19:13:21 +05:30
Jussi Pakkanen f0fee2e542 Fix soname to work on OSX. 2016-10-08 14:34:24 +02:00
Jussi Pakkanen 4dc798dc7e Check that soname matches the filename. Closes #785. 2016-10-08 07:34:39 -04:00
Jussi Pakkanen 6ec1e99043 Merge pull request #803 from centricular/generated-sources-header-deps
ninja backend: Fix header deps of generated source compiles
2016-10-01 15:41:46 -04:00
Nirbheek Chauhan 1e3d03cc09 ninja: Fix C file name for generated Vala sources
The Vala compiler preserves the path components of a Vala source file if
the source file is in a subdir.

Fixes https://github.com/mesonbuild/meson/issues/815
2016-10-02 00:50:45 +05:30
Nirbheek Chauhan 9d1aeebc27 ninja: Don't add every CustomTarget to 'all'
Otherwise they are built regardless of whether they are actually used by
anything else. Only build them if they're going to be installed or
always-built.

Ideally, we should also do this with all BuildTargets, and provide
a mechanism for people to specify which targets they want built with
'all', and a way for people to add them to custom targets.. Without
this, things like tests and examples are *always* built with no way to
turn that off.

For now, we just do this because it also with tests that check for
dependency issues. Including all CustomTargets in `all` results in
dangling targets to also be built, which hides the problem and makes it
racy.
2016-10-02 00:48:12 +05:30
Nirbheek Chauhan e713aca1d1 backends: Remove self.dep_rules dead code
self.dep_rules is not set anywhere by anything, so this code always
results in a no-op. If it didn't result in a no-op, it would need to be
seriously rewritten because it has bitrotten and makes no sense anymore.
2016-10-02 00:48:12 +05:30
Jussi Pakkanen 295b67df51 Merge pull request #814 from centricular/heavy-cleanup-compilers-buildtargets
Heavy cleanup in compilers and BuildTarget
2016-09-30 15:30:57 -04:00
Jussi Pakkanen 154763f81b Deduplicate command line arguments. Slight improvement to #671. 2016-09-28 16:18:08 -04:00
Nirbheek Chauhan 89753ecc27 Use per-target compilers while generating targets
This is definitely more correct since it takes into account the
cross-compilation status. We also now do the Java and CSharp sanity
checks on the BuildTarget level instead of in the Ninja backend.
2016-09-27 00:27:38 +05:30
Nirbheek Chauhan f85415f0d4 ninjabackend: Remove duplicate vala compiler usage 2016-09-27 00:27:38 +05:30
Nirbheek Chauhan f5caf40f66 ninja: Also add generated sources to the source list
The generated sources should also be used for determining the linker
2016-09-26 23:48:11 +05:30
Nirbheek Chauhan cfbffc6ba1 ninja: Fix header deps of generated source compiles
Because we were iterating over all generated sources of a target in one
go, we weren't adding the correct header_deps for generated source
compiles. We need to aggregate the header_deps first before generating
source compile targets for generated source files.
2016-09-26 23:48:11 +05:30
Nirbheek Chauhan ca507cdcdf ninja: Add a str and repr methods for RawFilename
This aids debugging immensely
2016-09-26 23:44:38 +05:30
Jussi Pakkanen e23e5c48d7 Use custom target outputs to determine linker. Closes #786. 2016-09-25 19:20:26 +03:00
Jussi Pakkanen c334eeda76 Merge pull request #684 from mesonbuild/pdb
Create pdb files with MSVC
2016-09-11 13:04:55 +03:00
Nirbheek Chauhan 0840a908f2 ninjabackend: Add support for installing .pdb files
.pdb files are files created by MSVC which have debug symbols. These are
created when /ZI or /Zi is passed to the compiler and /DEBUG to the
linker.
2016-09-11 10:10:47 +05:30
Jussi Pakkanen c7e5e558f9 More PDB explanation. 2016-09-10 13:26:37 +03:00
Jussi Pakkanen 19ecad5b24 Mark all dependencies for run targets. 2016-09-09 02:02:23 +03:00
Jussi Pakkanen d26ab47072 Can use custom targets as executables to run in a run_target. 2016-09-07 23:14:14 +03:00
Jussi Pakkanen 9235fd4ec1 Permit use of file objects in run targets. 2016-09-07 23:04:11 +03:00
Jussi Pakkanen a9da6c5132 Moved targets with same name into subdirs to make all tests pass. 2016-09-02 22:52:37 +03:00
Elliott Sales de Andrade 4c71695e41 Use context manager for file I/O.
There are a few cases where a context manager cannot be used, such as
the logger.
2016-08-27 18:29:55 -04:00
Jussi Pakkanen b7392bb290 Merge pull request #696 from mesonbuild/depfile
Add support for dependency files in custom targets.
2016-08-27 16:43:14 +03:00
Elliott Sales de Andrade a2321b24f6 Flatten isinstance calls. (#715)
That is, isinstance(x, y) or isinstance(x, z) can be flattened with a
tuple to isinstance(x, (y, z)).
2016-08-27 15:47:29 +03:00
Elliott Sales de Andrade 70d94a5550 Allow capturing command output of a custom target.
For commands that always output to stdout and don't have a "-o" or
"--output" or some other similar option, this 'capture' setting allows
the build to capture the result and place it in the output file.
2016-08-26 20:46:42 -04:00
Jussi Pakkanen c02a175d52 Add depfile support to generators. 2016-08-21 00:12:56 +03:00
Jussi Pakkanen 3ae918a463 Add support for dependency files in custom targets. 2016-08-20 21:01:49 +03:00
Jussi Pakkanen 36870ace0f Document pdb insanity a bit. 2016-08-18 23:15:54 +03:00
Jussi Pakkanen 1bed33fba2 Create pdbs that work when using pch or doing extract object (sadly not both). 2016-08-18 22:56:14 +03:00
Jussi Pakkanen ccda29794b Make pdb work with pch. 2016-08-18 00:12:54 +03:00
Jussi Pakkanen b08581d394 Generate pdb files during linking. 2016-08-17 23:50:50 +03:00
Jussi Pakkanen 5e047d9c91 Write pdb info to a specific file. 2016-08-17 23:28:35 +03:00
Nirbheek Chauhan 6d7b020aa2 ninja: Fix static library installation dir
Trivially correct typo fix. Didn't actually break anything because the
fallback is libdir anyway, and we always install static libraries to
libdir.

Pointed out by Zhe Wang (0x1997).
2016-07-27 14:39:32 +05:30
Nirbheek Chauhan 88aafd363e Normalize the path of a configured file to avoid dupes (#640) 2016-07-19 20:10:57 +03:00
Nirbheek Chauhan 5351b091a8 ninja: Remove duplicated if check (#637)
Trivially correct
2016-07-15 17:52:14 +03:00
Jussi Pakkanen 64919b1c74 Merge pull request #417 from nirbheek/dll-paths
Fix filenames and paths used in DLL shared library generation
2016-07-13 22:18:50 +03:00
Jussi Pakkanen a0666ebf9c Gcc versions older than 4.9 do not support color output. 2016-07-01 23:38:25 +03:00
Jussi Pakkanen 4f2b663928 Unify common code in run_target and custom_target. 2016-07-01 22:12:15 +03:00
Nirbheek Chauhan 0143c32c7c Overhaul versioning and naming of libraries
This commit contains several changes to the naming and versioning of
shared and static libraries. The details are documented at:
https://github.com/mesonbuild/meson/pull/417

Here's a brief summary:

* The results of binary and compiler detection via environment functions
  are now cached so that they can be called repeatedly without
  performance penalty. This is necessary because every
  build.SharedLibrary object has to know whether the compiler is MSVC or
  not (output filenames depend on that), and so the compiler detection
  has to be called for each object instantiation.

* Linux shared libraries don't always have a library version. Sometimes
  only soversions are specified (and vice-versa), so support both.

* Don't use versioned filenames when generating DLLs, DLLs are never
  versioned using the suffix in the way that .so libraries are. Hence,
  they don't use "aliases". Only Linux shared libraries use those.

* OS X dylibs do not use filename aliases at all. They only use the
  soversion in the dylib name (libfoo.X.dylib), and that's it. If
  there's no soversion specified, the dylib is called libfoo.dylib.
  Further versioning in dylibs is supposed to be done with the
  -current_version argument to clang, but this is TBD.

  https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/DynamicLibraryDesignGuidelines.html#//apple_ref/doc/uid/TP40002013-SW23

* Install DLLs into bindir and import libraries into libdir

* Static libraries are now always called libfoo.a, even with MSVC

* .lib import libraries are always generated when building with MSVC

* .dll.a import libraries are always generated when building with
  MinGW/GCC or MinGW/clang

* TODO: Use dlltool if available to generate .dll.a when .lib is
  generated and vice-versa.

* Library and executable suffix/prefixes are now always correctly
  overriden by the values of the 'name_prefix' and 'name_suffix' keyword
  arguments.
2016-07-01 20:50:47 +05:30
Jussi Pakkanen 0733c0f9a1 Changed run_target to take command as kwarg and add depends. This makes it behave the same as custom_target. 2016-06-24 23:07:57 +03:00
Jussi Pakkanen ea4fe8e417 Run_target can run binaries obtained with find_program. 2016-06-24 15:02:43 +03:00
Nirbheek Chauhan 50fef89218 ninjabackend: Add subdir includes before external dep includes
Fixes https://github.com/mesonbuild/meson/issues/604
2016-06-21 01:53:26 +05:30
Jussi Pakkanen 68dbbeb78f Octopus merged cross fixes and genetor custom because why not. 2016-06-16 21:03:57 +03:00
Sam Thursfield a661708b54 Use target name to decide generated Vala .h & .vapi filenames
Previously Meson would use the name of the first .vala source file. This
doesn't work for some projects. Tracker is one example: it has
several libraries that mix Vala and C code. In such cases, none of the
.vala files tend to bear the name of the library we actually want to
generate.
2016-06-15 15:15:58 +01:00
Jussi Pakkanen 475175f4b5 Can use generator outputs in custom targets. Closes #587. 2016-06-13 21:17:13 +03:00
Martin Hostettler 7bd424fea6 ninjabackend: Add missing ninja_quote for cross compilation rule. 2016-06-13 00:12:15 +02:00
Hemmo Nieminen 1f76b76a84 Add support for running specific test suites with valgrind. 2016-06-06 10:28:00 +03:00