Commit Graph

239 Commits

Author SHA1 Message Date
Peter Hutterer a576791064 Use American English - 'ise' -> 'ize' where applicable 2017-05-04 22:09:27 +03:00
Jussi Pakkanen 33b79dcf25 Kill RawFile dead! 2017-05-03 18:27:04 +03:00
Dylan Baker a8173630ea Don't use len() to test emptiness vs not emptiness
Meson has a common pattern of using 'if len(foo) == 0:' or
'if len(foo) != 0:', however, this is a common anti-pattern in python.
Instead tests for emptiness/non-emptiness should be done with a simple
'if foo:' or 'if not foo:'

Consider the following:
>>> import timeit
>>> timeit.timeit('if len([]) == 0: pass')
0.10730923599840025
>>> timeit.timeit('if not []: pass')
0.030033907998586074
>>> timeit.timeit('if len(['a', 'b', 'c', 'd']) == 0: pass')
0.1154778649979562
>>> timeit.timeit("if not ['a', 'b', 'c', 'd']: pass")
0.08259823200205574
>>> timeit.timeit('if len("") == 0: pass')
0.089759664999292
>>> timeit.timeit('if not "": pass')
0.02340641999762738
>>> timeit.timeit('if len("foo") == 0: pass')
0.08848102600313723
>>> timeit.timeit('if not "foo": pass')
0.04032287199879647

And for the one additional case of 'if len(foo.strip()) == 0', which can
be replaced with 'if not foo.isspace()'
>>> timeit.timeit('if len("   ".strip()) == 0: pass')
0.15294511600222904
>>> timeit.timeit('if "   ".isspace(): pass')
0.09413968399894657
>>> timeit.timeit('if len("   abc".strip()) == 0: pass')
0.2023209120015963
>>> timeit.timeit('if "   abc".isspace(): pass')
0.09571301700270851

In other words, it's always a win to not use len(), when you don't
actually want to check the length.
2017-05-02 21:57:26 +03:00
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
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 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
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
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 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 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
Jussi Pakkanen cf97c7af81 Use get_option_for_target for builtins where sensible. 2017-04-02 00:07:23 +03:00
Jussi Pakkanen 294abe244f Use relative object file name for unity files everywhere. 2017-04-02 00:04:45 +03:00
Jussi Pakkanen 7b66ff8921 Create unity files with the VS backend. 2017-04-02 00:04:45 +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 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
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
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
Jussi Pakkanen 98af711ca6 Merge pull request #1403 from centricular/compile_resources
Make configure_file() great again
2017-02-20 14:27:06 -05:00
Nirbheek Chauhan 73b2ee08a8 Rewrite custom_target template string substitution
Factor it out into a function in mesonlib.py. This will allow us to
reuse it for generators and for configure_file(). The latter doesn't
implement this at all right now.

Also includes unit tests.
2017-02-20 23:32:03 +05:30
Nirbheek Chauhan 7e805a019a find_program: Fix implementation of .path()
And actually test that prog.path() works. The earlier test was just
running the command without checking if it succeeded.

Also make everything use prog.get_command() or get_path() instead of
accessing the internal member prog.fullpath directly.
2017-02-19 03:49:31 +05:30
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 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
Mike Sinkovsky 969be1f679 cleanup: Remove redundant parentheses 2017-01-18 21:22:47 +02:00
Mike Sinkovsky 22eed4c417 cleanup: Redundant character escape 2017-01-18 21:22:47 +02:00
Jussi Pakkanen 11f9425a5e Can use targets directly in test arguments. 2017-01-15 21:54:26 +02:00
Mike Sinkovsky 77515ee541 style: [E303] too many blank lines (2) 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 776b0d9a5f Merge pull request #1263 from centricular/meson_exe_deterministic
serialise_executable: Name the data file deterministically
2017-01-02 11:42:56 -05:00
Igor Gnatenko 969dc7e995 style: fix E124 violations
E124: closing bracket does not match visual indentation

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
Nirbheek Chauhan 5060e2045b serialise_executable: Name the data file deterministically
Closes #1062
2016-12-31 21:59:02 +05:30
Jussi Pakkanen b55235dfbd Fix space before :. 2016-12-31 16:28:15 +02:00
Matthias Klumpp 8ee1c9a07a Do not automatically set warning flags if buildtype is 'plain' 2016-12-23 00:27:33 +02:00
Matthias Klumpp a9c09e6004 ldc: Protect linker flags from deduplication
This is the better way to pass arguments through to the linker when
compiling D code with LDC.
2016-12-21 15:49:44 +01:00
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
Jussi Pakkanen 4317edca25 Merge pull request #1227 from centricular/ninja-clean-recursive-dir-delete
run_project_tests.py: Also do ninja clean on tests
2016-12-20 00:15:53 +02:00
Nirbheek Chauhan 589a56e78f Cache the scripts used for postconf and install phases
Cache the absolute dir that the script is searched in and the name of
the script. These are the only two things that change.

Update the test to test for both #1235 and the case when a script of the
same name is in a different directory (which also covers the subproject
case).

Closes #1235
2016-12-20 00:09:02 +02:00
Igor Gnatenko 9ffc0d2f89 tree-wide: remove blank lines at EOF
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-12-19 18:34:06 +01:00
Igor Gnatenko 971a3a3cd9 tree-wide: remove trailing whitespaces
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-12-19 18:34:02 +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 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
Nirbheek Chauhan d5f7ba862b gnome.mkenums: Use absolute paths for all commandline args
Closes #973

test cases/vala/8 generated sources/ tests this.
2016-12-15 14:58:43 +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 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 0fc4ad2a0b Also use objects to populate target compilers
This avoids us having no compilers at all for targets that are composed
entirely of objects with no sources.

Now we will always have a compiler for a target even if it is composed
entirely of objects generated with custom targets unless it has
completely unknown sources.
2016-12-13 09:20:34 +05:30
Nirbheek Chauhan 864b9b1957 Only check for unity compat when doing unity builds
Also don't bother setting self.unity_compatible since it will never be
checked.

Closes #1097
2016-11-24 03:51:11 +05:30
Jussi Pakkanen 951262d759 Removed Valgrind from core. 2016-11-18 22:04:29 +02:00
Thibault Saunier 85a0cd7635 Add new add_project_[link]_args functions
Fixes 979
2016-11-12 17:34:06 -05:00
Nirbheek Chauhan 3a84136268 Fix regex used in custom target evaluation
Instead of using a whitelist, use a blacklist. Also print a more useful
error if the regex fails to match.

Use an underscore in the gir test to trigger this.

Fixes #436
2016-11-12 11:51:37 -05:00
Nirbheek Chauhan 45996b0f92 vala: Fix compiled object extraction
Fixes #791
2016-11-12 11:37:14 -05:00
Patrick Griffis 573b3afb52 backends: Output depfiles in same directory as target 2016-11-09 17:39:30 +01:00
Nirbheek Chauhan 5fdac48250 custom_target: Substitute @OUTPUT@ and @INPUT properly
They weren't being substituted if they were a part of a command
argument, ala --output=@OUTPUT@, etc.

Closes https://github.com/mesonbuild/meson/issues/824
2016-11-09 11:30:09 -05:00
Nirbheek Chauhan a2262103fb Implement mlog.warning and use it everywhere for warnings
Prepends the string with 'WARNING:' in ANSI yellow.

Closes https://github.com/mesonbuild/meson/issues/961
2016-11-08 17:43:24 -05:00
Jussi Pakkanen 8d182e00c9 Use a cross linker when cross compiling. 2016-11-06 10:14:43 -08:00
Mark Schulte 1e4bdea7d8 Allow running native executable in cross build
Make so both executable() targets that are marked as native and
external programs (which are usually build tools compiled for the
host machine) are not supposed to be run with the exe wrapper.
2016-10-27 14:42:43 -07:00
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 93035fd112 Print a useful error when unable to determine linker 2016-10-21 07:11:11 +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 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
Nirbheek Chauhan ee8b3b12a0 Add cross-platform PIC support for static libraries
With C/C++, on Windows you don't need to pass any arguments for a static
library to be PIC. On UNIX platforms you need to pass -fPIC.

Other languages such as D have compiler-specific PIC arguments required
for PIC support in static libraries on UNIX platforms.

This kwarg allows people to specify which static libraries should be
built with PIC support. This is usually used for static libraries that
will be linked into shared libraries.
2016-10-08 01:02:13 +05:30
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 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
Sam Thursfield 24e50b2697 Fix missing comma in backend.Backend.dedup_arguments()
This error meant that -I flags passed to the compiler were never
actually deduplicated.
2016-10-01 15:09:25 -04:00
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 cb2eff8440 ninja: Fix checking of exe_wrapper for CustomTargets (#806)
It was making a trivially incorrect check
2016-09-25 19:06:04 +03:00
Jussi Pakkanen 49583ccfab Revert #737. Closes #773. 2016-09-12 21:54:49 +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 cdf0c4f1a9 Merge branch 'QuLogic-context-managers' 2016-09-01 23:12:06 +03:00
Elliott Sales de Andrade 389259c229 Stop "fixing" command line in CustomTargets. (#737) 2016-09-01 22:10:33 +03:00
Jussi Pakkanen fa59fa55e2 Use absolute paths for dep files in Visual Studio. 2016-09-01 21:58:41 +03:00
Elliott Sales de Andrade 6475bdbe20 Properly handle Files used in CustomTarget commands. 2016-08-29 04:29:49 -04:00
Elliott Sales de Andrade cd03df4a4c Fix CustomTargets used as input to CustomTargets. (#727) 2016-08-28 21:14:15 +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
Elliott Sales de Andrade dcaf2d7b3d Accept string exe with Backend.serialise_executable.
Normally, this accepts a build.Executable, but it accept
build.BuildTarget and build.CustomTarget as well. Now it will also
accept a string path.
2016-08-26 20:46:42 -04:00
Jussi Pakkanen 3ae918a463 Add support for dependency files in custom targets. 2016-08-20 21:01:49 +03:00
Matthias Klumpp 56823272ab Implement D support
This patch adds support for the D programming language[1] to Meson.

The following compilers are supported:
* LDC
* GDC
* DMD

[1]: http://dlang.org/
2016-08-19 03:02:51 +02:00
Nirbheek Chauhan bfa25fc1d3 ninja: Add escaping for backslash in -D arguments
This is only needed for defines. Other arguments such as -I and /Fa that
also take arguments with spaces and backslashes don't need it at all.
2016-07-29 19:51:11 +05:30
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
Nirbheek Chauhan 64cb70441b CustomTarget: Use mesonlib.File objects as-is in the command to be run
This allows us to output either the relative or absolute path as
requested. Fixes usage of configure_file inside CustomTarget commands
with the VS backends.
2016-07-01 20:50:47 +05:30
Nirbheek Chauhan 2e986ae30d backend: Raise a RuntimeError if an unknown object is added to the command list
This allows us to catch these errors early and print a useful message
2016-07-01 20:50:47 +05:30
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 68dbbeb78f Octopus merged cross fixes and genetor custom because why not. 2016-06-16 21:03:57 +03:00
Noam Meltzer 038e575d78 determine_linker(): choose static cross linker for cross compiling
somewhere after 0.29.0 a bug was introduced where the LINK_ARGS of the
native static linker were used instead of the cross static linker
2016-06-16 20:52:03 +03:00
Jussi Pakkanen 475175f4b5 Can use generator outputs in custom targets. Closes #587. 2016-06-13 21:17:13 +03:00
Nicolas Schneider a29d9c2c33 vs: fix generators that use indexed output replacements (like @OUTPUT0@) 2016-05-26 13:08:33 +02:00
Jussi Pakkanen df03f849a8 Merge pull request #542 from mesonbuild/ownstdlib
Build transparently with a custom standard library
2016-05-25 23:44:24 +03:00
Jussi Pakkanen afe7252476 Can specify a stdlib subproject that is used implicitly on all targets with said language. 2016-05-21 21:46:03 +03:00
Jussi Pakkanen 46ce7a9d4b Merge pull request #516 from centricular/cross-compile_32bit-x86_on_64bit-x86_exe-wrapper
Special-case the 32-bit executable on 64-bit x86 case while cross-compiling
2016-05-01 18:56:07 +03:00
Jussi Pakkanen 2e2df70dd0 Merge branch 'centricular-customtarget-path-windows' 2016-05-01 18:39:45 +03:00
Nicolas Schneider 060f195fe0 vs2010: add generated libs as link dependencies 2016-04-19 23:25:45 +02:00
Nirbheek Chauhan 86aa51232e backends: Don't duplicate test setup data file name
Instead, return the values of the test and benchmark setup data files so
that the ninja/osx/vs backends can use those filenames instead of
hard-coding them.
2016-04-15 05:49:42 +05:30
Nirbheek Chauhan e3bc2e5c68 ninja: Set PATH for CustomTargets with built EXEs on Windows
When a CustomTarget is run with a command that is an executable built
by the project which also has a DLL built in the same project as a
dependency, the EXE can't run on Windows because the DLL can't be found.
On UNIX-like systems, we set the RPATH using the linker so these
dependencies can be found, but on Windows the only way is to set the
PATH environment variable.

The same problem exists for tests, so we reuse that infrastructure by
creating a new meson_exe.py script that can be used as a wrapper to run
CustomTarget commands on Windows. This can later also be extended to add
support for setting an environment while calling the command needed to
generate a CustomTarget: https://github.com/mesonbuild/meson/issues/266
2016-04-15 05:49:42 +05:30
Nirbheek Chauhan c0765b0e8d Don't require an exe_wrapper when cross-compiling 32-bit on 64-bit
Almost all 64-bit x86 OSes can run 32-bit x86 binaries natively. Detect
that case and don't require an exe wrapper.
2016-04-15 00:25:34 +05:30
Jussi Pakkanen cab5ce4fc0 Merge pull request #438 from trhd/testing_options
New options for controlling test output.
2016-04-06 23:10:20 +03:00
Jussi Pakkanen 16b3e22016 Removed lingering coverage flags. 2016-04-04 01:41:56 +03:00
Hemmo Nieminen 336904b553 Move MesonException from coredata to mesonlib. 2016-04-01 00:52:45 +03:00
Jussi Pakkanen 67377e69b5 Invoke depfixer in-process to make it faster. Closes #480. 2016-03-30 22:09:36 +03:00
Jussi Pakkanen 1d89d091f8 Merge branch 'vs-extraargs' 2016-03-29 22:32:48 +03:00
Nicolas Schneider a33d9d56cf vs2010: support EXTRA_ARGS for generators 2016-03-29 12:08:34 +02:00
Nicolas Schneider 8787ec3ea2 vs2010: fix object extraction with same source file name
This also refactors determine_ext_objs() to use inheritance instead of a
method flag for determining the object output name.
2016-03-25 09:49:30 +01:00
Jussi Pakkanen d87eb7d290 Merge branch 'base_options'. 2016-03-20 22:04:24 +02:00
Jussi Pakkanen 9071c8fc45 Merge branch 'Custom target absolute paths'. 2016-03-20 21:39:49 +02:00
Jussi Pakkanen 0c63f75aaf Converted coverage into a base option. 2016-03-20 19:16:49 +02:00
Jussi Pakkanen b5c7cca0dc Works when mixing Java and C. 2016-03-17 21:24:13 +02:00
Nicolas Schneider d72cc6e6f8 vs2010: fix object extraction
1. Dependencies must be set up with the target's id instead of its
basename.
2. Extracted object output file names must not include the directory
prefix, because MSBuild puts all object files into the same directory
and names them srcfilename.obj instead of dir/filename.obj or
dir_filename.obj.
2016-03-17 12:37:38 +01:00
Nicolas Schneider e067c4a79d fix eval_custom_target_command() to use absolute paths for output files 2016-03-15 23:26:12 +01:00
Nicolas Schneider 749aeefe0c pass meson source and build dirs as env variables for postconf scripts 2016-03-03 22:28:56 +01:00
Nicolas Schneider 9f9f73fa52 add args support for add_postconf_script 2016-03-01 14:31:37 +01:00
Nicolas Schneider 92187501ed Can add postconfigure script. 2016-03-01 14:07:38 +01:00
Jussi Pakkanen 2d32c39471 Handle built targets in custom rules. Closes #411. 2016-02-29 20:51:25 +02:00
Minijackson 3b688c6114 Create directories of unity temporary files 2016-02-24 15:07:43 +01:00
Martin Ejdestig 47db4e3d53 Pass warning arguments to compiler even if buildtype is plain
Noticed when trying to pass custom optimization flags, and hence setting
buildtype to plain, that warnings for different levels were not passed to
compiler.

This was a bit confusing since mesonconf still displayed "warning_level=3"
and -Werror was passed correctly due to "werror=true". So this change
aligns warning_level behavior with werror. That is, heed what is in
project() in meson.build but user can still override if necessary.
2016-02-22 18:57:07 +01:00
Jussi Pakkanen 560d9d7375 Merge pull request #398 from nirbheek/target-link-implib
Re-introduce patch to fix linking with MSVC by linking with import library.
2016-02-21 13:25:51 +02:00
Nirbheek Chauhan 81544feffe Explicitly use the import library while generating link args for a target 2016-02-20 02:17:51 +05:30
Jussi Pakkanen aaf6075c89 Reverted implib patch as it broke mingw completely. 2016-02-17 23:09:39 +02:00
Nirbheek Chauhan deff35eef6 Filter out UNIX flags from external deps when using the MSVC compiler
This is very useful to prevent compiler noise about invalid cflags; particularly
for the -mms-bitfields cflag which most libraries send to the mingw-gcc
compiler. More can be added later.
2016-02-17 20:22:34 +02:00
Nirbheek Chauhan 440d73902d Explicitly use the import library while generating link args for a target 2016-02-17 20:13:24 +02:00
Nirbheek Chauhan 8bd0f432a0 backends: Clarify the reason behind a grotesque hack 2016-02-17 15:03:54 +05:30
Jussi Pakkanen 7435df8399 Moved backends to their own module. 2016-01-23 20:02:52 +02:00