From 98b1ce1cd9f3220ec6a06ef2bfa122518a9245ed Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Tue, 14 Mar 2017 15:15:13 +0530 Subject: [PATCH] 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. --- mesonbuild/backend/ninjabackend.py | 32 ++++++++++++------- .../installed_files.txt | 2 ++ .../7 mingw dll versioning/meson.build | 4 +++ .../8 msvc dll versioning/installed_files.txt | 2 ++ .../windows/8 msvc dll versioning/meson.build | 4 +++ 5 files changed, 32 insertions(+), 12 deletions(-) diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 77b2d1d55..464cdcb0c 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -632,23 +632,13 @@ int dummy; should_strip = self.get_option_for_target('strip', t) # Find the installation directory. outdirs = t.get_custom_install_dir() + custom_install_dir = False if outdirs[0] is not None and outdirs[0] is not True: # Either the value is set, or is set to False which means # we want this specific output out of many outputs to not # be installed. - pass + custom_install_dir = True elif isinstance(t, build.SharedLibrary): - # On toolchains/platforms that use an import library for - # linking (separate from the shared library with all the - # code), we need to install that too (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) outdirs[0] = self.environment.get_shared_lib_dir() elif isinstance(t, build.StaticLibrary): outdirs[0] = self.environment.get_static_lib_dir() @@ -672,6 +662,24 @@ int dummy; i = [self.get_target_filename(t), outdirs[0], t.get_aliases(), should_strip, t.install_rpath] d.targets.append(i) + # On toolchains/platforms that use an import library for + # linking (separate from the shared library with all the + # code), we need to install that too (dll.a/.lib). + if isinstance(t, build.SharedLibrary) and t.get_import_filename(): + if custom_install_dir: + # If the DLL is installed into a custom directory, + # install the import library into the same place so + # it doesn't go into a surprising place + implib_install_dir = outdirs[0] + else: + implib_install_dir = self.environment.get_import_lib_dir() + # Install the import library. + i = [self.get_target_filename_for_linking(t), + implib_install_dir, + # It has no aliases, should not be stripped, and + # doesn't have an install_rpath + {}, False, ''] + d.targets.append(i) # Install secondary outputs. Only used for Vala right now. if num_outdirs > 1: for output, outdir in zip(t.get_outputs()[1:], outdirs[1:]): diff --git a/test cases/windows/7 mingw dll versioning/installed_files.txt b/test cases/windows/7 mingw dll versioning/installed_files.txt index ebad9e422..f02b4547b 100644 --- a/test cases/windows/7 mingw dll versioning/installed_files.txt +++ b/test cases/windows/7 mingw dll versioning/installed_files.txt @@ -6,3 +6,5 @@ usr/bin/libonlyversion-1.dll usr/lib/libonlyversion.dll.a usr/bin/libonlysoversion-5.dll usr/lib/libonlysoversion.dll.a +usr/libexec/libcustomdir.dll +usr/libexec/libcustomdir.dll.a diff --git a/test cases/windows/7 mingw dll versioning/meson.build b/test cases/windows/7 mingw dll versioning/meson.build index d1fe73a9c..7f65532c3 100644 --- a/test cases/windows/7 mingw dll versioning/meson.build +++ b/test cases/windows/7 mingw dll versioning/meson.build @@ -47,3 +47,7 @@ test('manually linked 3', executable('manuallink3', out, test('manually linked 4', executable('manuallink4', out, link_args : ['-L.', '-lonlysoversion'])) + +shared_library('customdir', 'lib.c', + install : true, + install_dir : get_option('libexecdir')) diff --git a/test cases/windows/8 msvc dll versioning/installed_files.txt b/test cases/windows/8 msvc dll versioning/installed_files.txt index ae0fa1f67..1a735e284 100644 --- a/test cases/windows/8 msvc dll versioning/installed_files.txt +++ b/test cases/windows/8 msvc dll versioning/installed_files.txt @@ -8,3 +8,5 @@ usr/bin/onlyversion-1.dll usr/lib/onlyversion.lib usr/bin/onlysoversion-5.dll usr/lib/onlysoversion.lib +usr/libexec/customdir.dll +usr/libexec/customdir.lib diff --git a/test cases/windows/8 msvc dll versioning/meson.build b/test cases/windows/8 msvc dll versioning/meson.build index b72c5ec0f..eea41d90c 100644 --- a/test cases/windows/8 msvc dll versioning/meson.build +++ b/test cases/windows/8 msvc dll versioning/meson.build @@ -48,3 +48,7 @@ test('manually linked 3', executable('manuallink3', out, test('manually linked 4', executable('manuallink4', out, link_args : ['-L.', '-lonlysoversion'])) + +shared_library('customdir', 'lib.c', + install : true, + install_dir : get_option('libexecdir'))