Skip to content

Commit

Permalink
(#19226) pixman: fix static and allow shared MSVC build
Browse files Browse the repository at this point in the history
* pixman: avoid __declspec(dllexport) for static MSVC build

* pixman/0.40.0: enable shared MSVC build
  • Loading branch information
db4 authored Feb 8, 2024
1 parent 846e6ad commit 0c171ff
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 4 deletions.
4 changes: 4 additions & 0 deletions recipes/pixman/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
10 changes: 6 additions & 4 deletions recipes/pixman/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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"):
Expand Down
28 changes: 28 additions & 0 deletions recipes/pixman/all/patches/0003-meson-static-build.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
From 48d5df1f3772a08a929dcb3b2fe4d7b1853223c9 Mon Sep 17 00:00:00 2001
From: Benjamin Gilbert <bgilbert@backtick.net>
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

0 comments on commit 0c171ff

Please sign in to comment.