diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2016-07-01 14:43:51 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2016-07-01 20:50:47 +0530 |
commit | 0143c32c7cd82872e42f57216bb94a26191f2824 (patch) | |
tree | 7b6030e63de5283548ce234dd4d96a36a7380f1b /mesonbuild/backend/ninjabackend.py | |
parent | bc347aed0be4d8ea6210a546fb350f7bc1eee529 (diff) | |
download | meson-0143c32c7cd82872e42f57216bb94a26191f2824.zip meson-0143c32c7cd82872e42f57216bb94a26191f2824.tar.gz meson-0143c32c7cd82872e42f57216bb94a26191f2824.tar.bz2 |
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.
Diffstat (limited to 'mesonbuild/backend/ninjabackend.py')
-rw-r--r-- | mesonbuild/backend/ninjabackend.py | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index b583e62..f6a3c75 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -492,18 +492,33 @@ int dummy; pickle.dump(d, ofile) def generate_target_install(self, d): - libdir = self.environment.get_libdir() - bindir = self.environment.get_bindir() - should_strip = self.environment.coredata.get_builtin_option('strip') for t in self.build.get_targets().values(): if t.should_install(): + # Find the installation directory outdir = t.get_custom_install_dir() - if outdir is None: - if isinstance(t, build.Executable): - outdir = bindir - else: - outdir = libdir + if outdir is not None: + pass + elif isinstance(t, build.SharedLibrary): + # For toolchains/platforms that need an import library for + # linking (separate from the shared library with all the + # code), we need to install the import library (dll.a/.lib) + if t.get_import_filename(): + # Install the import library. + i = [self.get_target_filename_for_linking(t), + self.environment.get_import_lib_dir(), + # It has no aliases, should not be stripped, and + # doesn't have an install_rpath + [], False, ''] + d.targets.append(i) + outdir = self.environment.get_shared_lib_dir() + elif isinstance(t, build.SharedLibrary): + outdir = self.environment.get_static_lib_dir() + elif isinstance(t, build.Executable): + outdir = self.environment.get_bindir() + else: + # XXX: Add BuildTarget-specific install dir cases here + outdir = self.environment.get_libdir() i = [self.get_target_filename(t), outdir, t.get_aliaslist(),\ should_strip, t.install_rpath] d.targets.append(i) @@ -1661,8 +1676,12 @@ rule FORTRAN_DEP_HACK else: soversion = None commands += linker.get_soname_args(target.name, abspath, soversion) + # This is only visited when using the Visual Studio toolchain if target.vs_module_defs and hasattr(linker, 'gen_vs_module_defs_args'): commands += linker.gen_vs_module_defs_args(target.vs_module_defs.rel_to_builddir(self.build_to_src)) + # This is only visited when building for Windows using either MinGW/GCC or Visual Studio + if target.import_filename: + commands += linker.gen_import_library_args(os.path.join(target.subdir, target.import_filename)) elif isinstance(target, build.StaticLibrary): commands += linker.get_std_link_args() else: |