Commit Graph

243 Commits

Author SHA1 Message Date
Jussi Pakkanen 4b7c39d9d1 Merge pull request #1247 from centricular/fix-installed-soname-aliases
Fix soname symlinking after installation
2016-12-23 00:28:00 +02:00
Elliott Sales de Andrade 18c38df875 Add Generator.process_files to reduce code duplication. 2016-12-22 17:08:32 +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
Elliott Sales de Andrade c7f788e184 Fix exception when linking with invalid object.
If you declare_dependency(link_with : 'string'), an exception is
supposed to be raised, but instead of a proper message, it's an
exception about a missing attribute.
2016-12-21 00:10:39 +02: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 98c4fd2d5d Add per target argument for Fortran. 2016-12-20 22:46:36 +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 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 8268eb4959 tree-wide: remove unused imports
./setup.py:17:1: F401 'os' imported but unused
import os
^
./setup.py:37:1: F401 'stat.ST_MODE' imported but unused
from stat import ST_MODE
^
./run_tests.py:17:1: F401 'os' imported but unused
import subprocess, sys, os
^
./run_tests.py:18:1: F401 'shutil' imported but unused
import shutil
^
./run_unittests.py:23:1: F401 'mesonbuild.dependencies.Qt5Dependency' imported but unused
from mesonbuild.dependencies import PkgConfigDependency, Qt5Dependency
^
./mesonbuild/build.py:15:1: F401 '.coredata' imported but unused
from . import coredata
^
./mesonbuild/interpreter.py:32:1: F401 'subprocess' imported but unused
import os, sys, subprocess, shutil, uuid, re
^
./mesonbuild/interpreter.py:32:1: F401 're' imported but unused
import os, sys, subprocess, shutil, uuid, re
^
./mesonbuild/dependencies.py:23:1: F401 'subprocess' imported but unused
import os, stat, glob, subprocess, shutil
^
./mesonbuild/mesonlib.py:17:1: F401 'sys' imported but unused
import platform, subprocess, operator, os, shutil, re, sys
^
./mesonbuild/modules/qt5.py:15:1: F401 'subprocess' imported but unused
import os, subprocess
^
./mesonbuild/modules/pkgconfig.py:15:1: F401 '..coredata' imported but unused
from .. import coredata, build
^
./mesonbuild/scripts/scanbuild.py:15:1: F401 'sys' imported but unused
import sys, os
^
./mesonbuild/scripts/meson_exe.py:20:1: F401 'subprocess' imported but unused
import subprocess
^
./mesonbuild/scripts/meson_exe.py:22:1: F401 '..mesonlib.MesonException' imported but unused
from ..mesonlib import MesonException, Popen_safe
^
./mesonbuild/scripts/symbolextractor.py:23:1: F401 'subprocess' imported but unused
import os, sys, subprocess
^
./mesonbuild/scripts/symbolextractor.py:25:1: F401 '..mesonlib.MesonException' imported but unused
from ..mesonlib import MesonException, Popen_safe
^
./mesonbuild/scripts/meson_install.py:19:1: F401 '..mesonlib.MesonException' imported but unused
from ..mesonlib import MesonException, Popen_safe
^
./mesonbuild/scripts/yelphelper.py:15:1: F401 'sys' imported but unused
import sys, os
^
./mesonbuild/scripts/yelphelper.py:20:1: F401 '..mesonlib.MesonException' imported but unused
from ..mesonlib import MesonException
^
./mesonbuild/backend/vs2010backend.py:17:1: F401 're' imported but unused
import re
^
./test cases/vala/8 generated sources/src/copy_file.py:3:1: F401 'os' imported but unused
import os
^
./test cases/common/107 postconf/postconf.py:3:1: F401 'sys' imported but unused
import sys, os
^
./test cases/common/129 object only target/obj_generator.py:5:1: F401 'shutil' imported but unused
import sys, shutil, subprocess
^
./test cases/common/57 custom target chain/usetarget/subcomp.py:3:1: F401 'os' imported but unused
import sys, os
^
./test cases/common/95 dep fallback/subprojects/boblib/genbob.py:3:1: F401 'os' imported but unused
import os
^
./test cases/common/98 gen extra/srcgen.py:4:1: F401 'os' imported but unused
import os
^
./test cases/common/113 generatorcustom/gen.py:3:1: F401 'os' imported but unused
import sys, os
^
./test cases/common/113 generatorcustom/catter.py:3:1: F401 'os' imported but unused
import sys, os
^
./test cases/common/59 object generator/obj_generator.py:5:1: F401 'shutil' imported but unused
import sys, shutil, subprocess
^

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-12-19 18:19:35 +01:00
Nirbheek Chauhan c693bd9bb4 Allow passing arguments to install scripts
Closes #1213
2016-12-18 18:30:47 +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 2c83bd16fc Test targets with only generated and prebuilt objects 2016-12-13 09:37:48 +05:30
Nirbheek Chauhan 038b15a7b2 Add __repr__ for ExtractedObjects and better error for Vala libraries 2016-12-13 09:37:47 +05:30
Nirbheek Chauhan d766475176 Use the linker to determine if we are using MSVC
This is much more accurate since this is actually what determines what
file naming to use and whether there will be PDB debugging information
or not.

Closes #1169
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 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 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 f62f730821 Merge pull request #1126 from mesonbuild/sharedmodule
Support for shared modules
2016-12-07 21:49:16 +02:00
Jussi Pakkanen 3276bdd23d Merge pull request #1102 from mesonbuild/soname
Fix soname symlink generation
2016-12-02 23:57:19 +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
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 c9a46fcc93 Can set compiler arguments in Java. 2016-11-20 16:57:58 -05:00
Jussi Pakkanen a01919976e Always specify installed data with a File object. Closes #858. 2016-11-18 17:37:35 -05: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 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 6762d30c6a Exposes the install names of targets in introspection. Closes #829. 2016-10-30 06:46:08 -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 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 70265c3782 Improve error when using the dependencies kwarg
The error message is misleading (talks about external dependencies), and
doesn't tell you what you need to do (use the output of
declare_dependency, dependency, or find_library). At the same time
rename add_external_deps to add_deps since it adds internal deps too.

Plus many more error message improvements all over the place.
2016-10-23 18:02:19 +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 6f4406928b BuildTarget: Add compilers needed by generated sources 2016-10-21 07:11:11 +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 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
Elliott Sales de Andrade 779788ad82 Split generator @BASENAME@ at the first extension. 2016-10-13 21:28:26 +03:00
Nirbheek Chauhan d819914af0 pkgconfig: Warn if library has name_prefix/suffix set
GCC/Clang won't be able to find it via an -lfoo flag, so the pkg-config
file might be unusable.

Fixes https://github.com/mesonbuild/meson/issues/889
2016-10-12 13:40:08 +05:30
Jussi Pakkanen 3a3db9fc5e Merge pull request #885 from centricular/fix-staticlib-pic-error
Warn if -fPIC is passed instead of pic to static libraries (instead of erroring out)
2016-10-10 21:30:20 +03:00
Jussi Pakkanen 28df8b800e Add an option to select if static libraries are built with -fPIC. 2016-10-10 21:28:28 +03:00
Nirbheek Chauhan 2d0eb2cec5 Warn if -fPIC is passed instead of pic to static libraries
Also print the name of the static library that has PIC-related issues,
print more details in exceptions, and test for all this.
2016-10-10 23:28:19 +05:30
Nirbheek Chauhan ce1393609f Error out if shared lib links to static lib without PIC
This is only needed on Linux and BSD. So, we always unconditionally
enable self.pic for Windows and OS X.
2016-10-08 01:02:16 +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
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 98e7625c64 Add a list of compilers used to each BuildTarget
When the BuildTarget (executable, shared-library, static-library, etc)
is created, process the source list and assign compilers to this target.
This allows us to do compiler-specific file-naming without resorting to
ugly hacks.

This is one step towards consolidating all the 'what language does this
target use' checks and the 'this target should only have $lang files as
sources' checks we have all over the codebase. All those checks should
be done only when the target is created.
2016-09-27 00:27:38 +05:30
Tim-Philipp Müller 3aebdb717a configuration_data: can pass descriptions to setters (#783)
Add support for passing a description to configuration data
setter methods via a 'description' kwarg. The description
string will be used when meson generates the entire configure
file without a template, autoconf-style.
2016-09-25 18:56:49 +03:00
Thibault Saunier a2e7ebc575 Add a new 'environment' object to be used to build test environment (#781)
Allowing user to fine tune tests environment variables
2016-09-14 23:11:27 +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 165f8a913d Better error message when trying to use subprojects as dependencies. 2016-09-07 21:25:34 +03: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
Jussi Pakkanen 7cd6206d9a Check for embedded @OUTPUT@s in commands. 2016-08-27 14:41:14 +03:00
Elliott Sales de Andrade 3e09aa9f11 Don't allow @OUTPUT@ when capturing output. 2016-08-26 20:46:42 -04: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 6ae40344e0 Merge pull request #680 from centricular/osx-dylib-soversion
Add a test to find libfoo.X.dylib via -lfoo
2016-08-21 14:12:19 +03:00
Jussi Pakkanen 399d653803 Merge pull request #685 from ximion/master
Implement D support
2016-08-21 13:22:19 +03:00
Matthias Klumpp 12a01c26f3 trivial: Use stringlistify 2016-08-21 01:40:29 +02: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
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 88037c4385 shared_library: Add vs_module_defs to link_depends
With this, if the module definitions file is edited, the shared library
and all reverse-dependencies will be re-linked.

Fixes #643
2016-08-18 20:53:34 +05:30
Nirbheek Chauhan 5f3097a492 Don't add the soversion to the dylib filename on OS X
Doing so messes up library search with -lfoo.
See: https://github.com/mesonbuild/meson/pull/680
2016-08-16 16:14:10 +05:30
Nirbheek Chauhan e0dcb3160a BuildTarget: Print a better message when passing GeneratedList to 'objects' (#681) 2016-08-15 20:45:37 +02:00
Nirbheek Chauhan d8b9b12adb Ninja now supports backslash in command args, so we can too
At the same time, this also adds a bunch of tests that document and keep
track of how we expect quoting to pass through via Ninja to the
compiler.

We need at least Ninja 1.6.0 for this.

This fixes https://github.com/mesonbuild/meson/issues/489
2016-07-29 19:51:09 +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
Nirbheek Chauhan 358598816f build: Fix implementation of sources_are_suffix
The first file might be a header file, in which case this test will
fail, so check all the files till a match is found instead.

Also remove duplicate and incorrect can_compile check. It just checks
the suffix and we already check that above.
2016-07-05 16:24:10 +05:30
Nirbheek Chauhan 4516e8a49f Add repr() implementations for build targets and File
This aids debugging
2016-07-01 20:50:47 +05:30
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 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 475175f4b5 Can use generator outputs in custom targets. Closes #587. 2016-06-13 21:17:13 +03:00
Jussi Pakkanen cff4e7d299 Can query version strings of dependencies. 2016-05-29 03:15:16 +03:00
Jussi Pakkanen 4377f773e0 Can set global linker arguments. Closes #536. 2016-05-28 21:31:59 +03: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 babdb27570 Merge pull request #479 from mesonbuild/i18n
Moved gettext into i18n module.
2016-05-25 17:53:35 +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 dc148e0702 Remove all special casing for gettext and use elementary operations instead. 2016-05-21 18:21:23 +03:00
Nirbheek Chauhan 35ef1d109a CustomTarget: require install_dir only when install is true (#519) 2016-04-17 22:52:10 +03:00
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 873ffe782c Merge pull request #390 from nirbheek/msvc-module-defs
Add support for passing a module definitions file for exporting symbols while linking
2016-04-03 18:12:18 +03:00
Hemmo Nieminen 336904b553 Move MesonException from coredata to mesonlib. 2016-04-01 00:52:45 +03:00
Nirbheek Chauhan 1713fa0297 Add shared_library argument for a Visual Studio module definitions file
On MSVC, shared libraries only export symbols that have been explicitly exported
either as part of the symbol prototype or via a module definitions file.

On compilers other than MSVC, all symbols are exported in the shared library by
default and the format for the list of symbols to export is different, so this
is only used with the VisualStudio compiler.

The module defs file path can either be relative to the current source directory
or an absolute path using meson.source_root() + '/some/path'
2016-03-30 16:24:35 +05:30
Jussi Pakkanen 12a4e7d7e7 Moved gettext into i18n module. 2016-03-28 20:15:16 +03:00
Jussi Pakkanen 317a735b07 Error out if using a not found binary in the build. Closes #469. 2016-03-23 21:26:55 +02:00
Nicolas Schneider 4d9db21039 vs2010: fix dependencies of CustomTarget 2016-03-16 00:00:39 +01:00
Nicolas Schneider 92187501ed Can add postconfigure script. 2016-03-01 14:07:38 +01:00
Jussi Pakkanen 52b66edb6c Can specify compile and link args for internal deps. 2016-02-29 21:28:16 +02:00
Jussi Pakkanen 836b121a9c Refix Linux. 2016-02-22 00:09:06 +02:00
Jussi Pakkanen a04c33e125 Can build Python extension on OSX. 2016-02-21 17:12:09 +02:00
Jussi Pakkanen 98d00386b1 Can build a Python extension module. 2016-02-21 14:52:36 +02:00
Nirbheek Chauhan 36c9a165ed build.CustomTarget: Also accept mesonlib.File types as 'command' arguments 2016-02-17 14:45:50 +05:30
Jussi Pakkanen 23b98cd6e6 Renamed meson package to mesonbuild so that we can have a script named meson in the same toplevel dir. 2016-01-16 17:35:29 +02:00