From 0c171ff419e92c3e927c2e1858630d65d3f85fa3 Mon Sep 17 00:00:00 2001 From: Dmitry Bely Date: Thu, 8 Feb 2024 09:04:08 +0000 Subject: [PATCH] (#19226) pixman: fix static and allow shared MSVC build * pixman: avoid __declspec(dllexport) for static MSVC build * pixman/0.40.0: enable shared MSVC build --- recipes/pixman/all/conandata.yml | 4 +++ recipes/pixman/all/conanfile.py | 10 ++++--- .../all/patches/0003-meson-static-build.patch | 28 +++++++++++++++++++ 3 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 recipes/pixman/all/patches/0003-meson-static-build.patch diff --git a/recipes/pixman/all/conandata.yml b/recipes/pixman/all/conandata.yml index 64d7ea0c4a642..f712201caaef3 100644 --- a/recipes/pixman/all/conandata.yml +++ b/recipes/pixman/all/conandata.yml @@ -30,6 +30,10 @@ patches: patch_description: "backport fix for clang build" patch_type: "portability" patch_source: "https://gitlab.freedesktop.org/pixman/pixman/-/merge_requests/48" + - patch_file: "patches/0003-meson-static-build.patch" + patch_description: "backport fix for msvc static build" + patch_type: "bugfix" + patch_source: "https://gitlab.freedesktop.org/pixman/pixman/-/commit/48d5df1f3772a08a929dcb3b2fe4d7b1853223c9.patch" "0.38.4": - patch_file: "patches/0002-meson-build.patch" patch_description: "backport meson build files from 0.40.0 to fix windows build" diff --git a/recipes/pixman/all/conanfile.py b/recipes/pixman/all/conanfile.py index aca2fe9a7ec26..8d655189662cb 100644 --- a/recipes/pixman/all/conanfile.py +++ b/recipes/pixman/all/conanfile.py @@ -11,6 +11,7 @@ from conan.tools.layout import basic_layout from conan.tools.meson import Meson, MesonToolchain from conan.tools.microsoft import is_msvc +from conan.tools.scm import Version required_conan_version = ">=1.53.0" @@ -50,8 +51,8 @@ def layout(self): basic_layout(self, src_folder="src") def validate(self): - if self.settings.os == "Windows" and self.options.shared: - raise ConanInvalidConfiguration("pixman can only be built as a static library on Windows") + if self.settings.os == "Windows" and self.options.shared and Version(self.version) < "0.40.0": + raise ConanInvalidConfiguration(f"pixman/{self.version} can only be built as a static library on Windows") def build_requirements(self): self.tool_requires("meson/1.2.3") @@ -84,16 +85,17 @@ def package(self): copy(self, "COPYING", self.source_folder, os.path.join(self.package_folder, "licenses")) meson = Meson(self) meson.install() + rm(self, "*.pdb", os.path.join(self.package_folder, "bin")) lib_folder = os.path.join(self.package_folder, "lib") rmdir(self, os.path.join(lib_folder, "pkgconfig")) rm(self, "*.la", lib_folder) fix_apple_shared_install_name(self) - if is_msvc(self): + if is_msvc(self) and not self.options.shared: prefix = "libpixman-1" rename(self, os.path.join(lib_folder, f"{prefix}.a"), os.path.join(lib_folder, f"{prefix}.lib")) def package_info(self): - self.cpp_info.libs = ['libpixman-1'] if self.settings.os == "Windows" else ['pixman-1'] + self.cpp_info.libs = ['libpixman-1'] if self.settings.os == "Windows" and not self.options.shared else ['pixman-1'] self.cpp_info.includedirs.append(os.path.join("include", "pixman-1")) self.cpp_info.set_property("pkg_config_name", "pixman-1") if self.settings.os in ("FreeBSD", "Linux"): diff --git a/recipes/pixman/all/patches/0003-meson-static-build.patch b/recipes/pixman/all/patches/0003-meson-static-build.patch new file mode 100644 index 0000000000000..6283ba2680054 --- /dev/null +++ b/recipes/pixman/all/patches/0003-meson-static-build.patch @@ -0,0 +1,28 @@ +From 48d5df1f3772a08a929dcb3b2fe4d7b1853223c9 Mon Sep 17 00:00:00 2001 +From: Benjamin Gilbert +Date: Thu, 5 Jan 2023 20:29:00 -0500 +Subject: [PATCH] meson: don't dllexport when built as static library + +If a static Pixman is linked with a dynamic library, Pixman shouldn't +export its own symbols into the latter's ABI. +--- + pixman/meson.build | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/pixman/meson.build b/pixman/meson.build +index 5dce870..62ec66b 100644 +--- a/pixman/meson.build ++++ b/pixman/meson.build +@@ -31,7 +31,8 @@ version_h = configure_file( + ) + + libpixman_extra_cargs = [] +-if cc.has_function_attribute('dllexport') ++default_library = get_option('default_library') ++if default_library != 'static' and cc.has_function_attribute('dllexport') + libpixman_extra_cargs = ['-DPIXMAN_API=__declspec(dllexport)'] + endif + +-- +GitLab +