Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pixman: fix static and allow shared MSVC build #19226

Merged
merged 2 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions recipes/pixman/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,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.1.1")
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