Commit Graph

340 Commits

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