Skip to content

Commit 7e65c57

Browse files
Chrismarshwdconinc
andauthored
cairo: add new version and update build system (#48822)
* update cairo for new meson build system * update patch range. remove old conflict * style * update pango to reflect the changes in cairo * refine depends * style * add lzo depends * add +shared * non self-referential variant requireme * style * Move +shared variant back to just autotools as meson automatically handles it * clarify patch when= * update based on reviews. switch from conflicts to requires to enforce variant synchronization * refine conflicts and requires * better group build deps together * comment for meson build lower version bound * clarifying comments * clarify version ranges, enforce build_system with version ranges * style * cairo: no need to require for build_systems --------- Co-authored-by: Wouter Deconinck <[email protected]>
1 parent 9213bf5 commit 7e65c57

File tree

2 files changed

+188
-35
lines changed

2 files changed

+188
-35
lines changed

var/spack/repos/builtin/packages/cairo/package.py

Lines changed: 186 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
#
33
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
44

5+
from spack.build_systems import autotools, meson
56
from spack.package import *
67

78

8-
class Cairo(AutotoolsPackage):
9+
class Cairo(AutotoolsPackage, MesonPackage):
910
"""Cairo is a 2D graphics library with support for multiple output
1011
devices."""
1112

@@ -14,6 +15,7 @@ class Cairo(AutotoolsPackage):
1415

1516
license("LGPL-2.1-or-later OR MPL-1.1", checked_by="tgamblin")
1617

18+
version("1.18.2", sha256="a62b9bb42425e844cc3d6ddde043ff39dbabedd1542eba57a2eb79f85889d45a")
1719
version("1.18.0", sha256="243a0736b978a33dee29f9cca7521733b78a65b5418206fef7bd1c3d4cf10b64")
1820
version(
1921
"1.17.4",
@@ -25,56 +27,205 @@ class Cairo(AutotoolsPackage):
2527
sha256="6b70d4655e2a47a22b101c666f4b29ba746eda4aa8a0f7255b32b2e9408801df",
2628
url="https://cairographics.org/snapshots/cairo-1.17.2.tar.xz",
2729
) # Snapshot
28-
version(
29-
"1.16.0",
30-
sha256="5e7b29b3f113ef870d1e3ecf8adf21f923396401604bda16d44be45e66052331",
31-
preferred=True,
32-
)
30+
version("1.16.0", sha256="5e7b29b3f113ef870d1e3ecf8adf21f923396401604bda16d44be45e66052331")
3331
version("1.14.12", sha256="8c90f00c500b2299c0a323dd9beead2a00353752b2092ead558139bd67f7bf16")
3432
version("1.14.8", sha256="d1f2d98ae9a4111564f6de4e013d639cf77155baf2556582295a0f00a9bc5e20")
3533
version("1.14.0", sha256="2cf5f81432e77ea4359af9dcd0f4faf37d015934501391c311bfd2d19a0134b7")
3634

3735
depends_on("c", type="build") # generated
3836
depends_on("cxx", type="build") # generated
3937

38+
# 1.17.4 is the last autotools based version. From 1.18.0 onward it is meson only
39+
build_system(
40+
conditional("meson", when="@1.18.0:"),
41+
conditional("autotools", when="@:1.17.4"),
42+
default="meson",
43+
)
44+
4045
variant("X", default=False, description="Build with X11 support")
41-
variant("pdf", default=False, description="Enable cairo's PDF surface backend feature")
4246
variant("gobject", default=False, description="Enable cairo's gobject functions feature")
43-
variant("ft", default=False, description="Enable cairo's FreeType font backend feature")
44-
variant("fc", default=False, description="Enable cairo's Fontconfig font backend feature")
45-
variant("png", default=False, description="Enable cairo's PNG functions feature")
46-
variant("svg", default=False, description="Enable cairo's SVG functions feature")
47-
variant("shared", default=True, description="Build shared libraries")
48-
variant("pic", default=True, description="Enable position-independent code (PIC)")
49-
50-
depends_on("libx11", when="+X")
51-
depends_on("libxext", when="+X")
52-
depends_on("libxrender", when="+X")
53-
depends_on("libxcb", when="+X")
54-
depends_on("python", when="+X", type="build")
55-
depends_on("libpng", when="+png")
56-
depends_on("glib")
57-
depends_on("[email protected]:", when="@1.17.2:")
58-
depends_on("pixman")
59-
depends_on("automake", type="build")
60-
depends_on("autoconf", type="build")
61-
depends_on("libtool", type="build")
62-
depends_on("m4", type="build")
63-
depends_on("freetype build_system=autotools", when="+ft")
47+
48+
# variants and build system depends for the autotools builds
49+
with when("build_system=autotools"):
50+
variant("png", default=False, description="Enable cairo's PNG functions feature")
51+
variant("svg", default=False, description="Enable cairo's SVG functions feature")
52+
variant("pic", default=True, description="Enable position-independent code (PIC)")
53+
variant("pdf", default=False, description="Enable cairo's PDF surface backend feature")
54+
variant("ft", default=False, description="Enable cairo's FreeType font backend feature")
55+
variant("fc", default=False, description="Enable cairo's Fontconfig font backend feature")
56+
57+
# seems to be an older cairo limitation as [email protected] seems to build fine against libpng
58+
conflicts("+png", when="platform=darwin")
59+
conflicts("+svg", when="platform=darwin")
60+
61+
# meson build already defines these and maps them to args
62+
# variant("shared", default=True, description="Build shared libraries")
63+
variant("shared", default=True, description="Build shared libraries")
64+
conflicts("+shared~pic")
65+
66+
depends_on("automake", type="build")
67+
depends_on("autoconf", type="build")
68+
depends_on("libtool", type="build")
69+
depends_on("m4", type="build")
70+
depends_on("which", type="build")
71+
72+
# variants and build system depends for the autotools builds
73+
# these names follow those listed here
74+
# https://gitlab.freedesktop.org/cairo/cairo/-/blob/1.18.2/meson_options.txt
75+
with when("build_system=meson"):
76+
variant("dwrite", default=False, description="Microsoft Windows DWrite font backend")
77+
78+
# doesn't exist @1.17.8: but kept as compatibility
79+
variant(
80+
"pdf",
81+
default=False,
82+
description="""+pdf is combined into +zlib now, kept seperate for compatibility.
83+
+pdf implies +zlib now. Please use the updated variants""",
84+
)
85+
# svg is combined into png now, kept seperate for compatibility
86+
variant(
87+
"svg",
88+
default=False,
89+
description="""+svg is combined into +png now, kept seperate for compatibility.
90+
+svg implies +png now. Please use the updated variants""",
91+
)
92+
93+
# meson seems to have assumptions about what is enabled/disabled
94+
# these four compile best if +variant in unison, otherwise various errors happen
95+
# if these aren't in sync. It is easier to have a sane default. conflicts below
96+
# to try to protect known incompatibilities
97+
variant("png", default=True, description="Enable cairo's PNG and SVG functions feature")
98+
variant("ft", default=True, description="Enable cairo's FreeType font backend feature")
99+
variant("fc", default=True, description="Enable cairo's Fontconfig font backend feature")
100+
variant(
101+
"zlib",
102+
default=True,
103+
description="Enable cairo's script, ps, pdf, xml functions feature",
104+
)
105+
106+
variant("quartz", default=False, description="Enable cairo's Quartz functions feature")
107+
variant("tee", default=False, description="Enable cairo's tee functions feature")
108+
109+
# not in spack
110+
variant(
111+
"spectre",
112+
default=False,
113+
description="Not available. Enable cairo's spectre functions feature",
114+
)
115+
116+
# (bfd might be too old) with binutils 2.43.1 on macos
117+
# so not sure how this is supposed to work
118+
variant(
119+
"symbol-lookup",
120+
default=False,
121+
description="Not available. Enable cairo's symbol lookup functions feature",
122+
)
123+
124+
# not currently supported variants
125+
conflicts("+spectre", msg="Not currently supported")
126+
conflicts("+symbol-lookup", msg="Not currently supported")
127+
128+
# meson seems to have assumptions about what is enabled/disabled
129+
# so this protects against incompatible combinations
130+
conflicts("~zlib+png", msg="+png requires +zlib")
131+
conflicts("~ft+fc", msg="+fc requires +ft")
132+
conflicts("+ft~fc", msg="+ft requires +fc")
133+
conflicts("+ft+fc~zlib", msg="+fc+ft requires +zlib")
134+
conflicts("+fc+ft~png+zlib", msg="+ft+fc+zlib requires +png")
135+
136+
# +pdf implies zlib now
137+
requires("+zlib", when="+pdf")
138+
requires("~zlib", when="~pdf", msg="+pdf implies +zlib now")
139+
# +svg implies png now
140+
requires("+svg", when="+png")
141+
requires("~png", when="~svg", msg="+svg implies +png now")
142+
143+
# https://gitlab.freedesktop.org/cairo/cairo/-/blob/1.18.2/meson.build?ref_type=tags#L2
144+
depends_on("[email protected]:", type="build")
145+
146+
# both autotools and meson need this for auto discovery of depends
64147
depends_on("pkgconfig", type="build")
65-
depends_on("[email protected]:", when="+fc") # Require newer version of fontconfig.
66-
depends_on("which", type="build")
67148

68-
conflicts("+png", when="platform=darwin")
69-
conflicts("+svg", when="platform=darwin")
70-
conflicts("+shared~pic")
149+
# non build system specific depends
150+
# versions that use (the old) autotools build
151+
with when("@:1.17.4"):
152+
depends_on("[email protected]:", when="@1.17.2:")
153+
depends_on("freetype", when="+ft")
154+
depends_on("[email protected]:", when="+fc")
155+
depends_on("libpng", when="+png")
156+
depends_on("glib")
157+
158+
# non build system specific depends
159+
# versions that use (the new) meson build
160+
with when("@1.18.0:"):
161+
depends_on("binutils", when="+symbol-lookup")
162+
depends_on("[email protected]:", when="+ft")
163+
depends_on("[email protected]:", when="+png")
164+
depends_on("[email protected]:", when="+gobject")
165+
depends_on("[email protected]:")
166+
depends_on("[email protected]:", when="+fc")
167+
168+
# lzo is not strictly required, but cannot be disabled and may be pulled in accidentally
169+
# https://github.com/mesonbuild/meson/issues/8224
170+
# https://github.com/microsoft/vcpkg/pull/38313
171+
depends_on("lzo")
172+
173+
# needed for both meson and autotools builds when including X
174+
with when("+X"):
175+
depends_on("libx11")
176+
depends_on("libxext")
177+
178+
depends_on("libxrender")
179+
depends_on("[email protected]:", when="@1.17.8:")
180+
181+
depends_on("libxcb")
182+
depends_on("[email protected]:", when="@1.17.8:")
183+
184+
depends_on("python", type="build")
71185

72186
# patch from https://gitlab.freedesktop.org/cairo/cairo/issues/346
73187
patch("fontconfig.patch", when="@1.16.0:1.17.2")
74188
# Don't regenerate docs to avoid a dependency on gtk-doc
75-
patch("disable-gtk-docs.patch", when="^[email protected]:")
189+
patch("disable-gtk-docs.patch", when="build_system=autotools ^[email protected]:")
190+
191+
192+
class MesonBuilder(meson.MesonBuilder):
193+
def enable_or_disable(self, feature_name, variant=None):
194+
if variant is None:
195+
variant = feature_name
196+
return (
197+
f"-D{feature_name}=enabled"
198+
if self.spec.satisfies(f"+{variant}")
199+
else f"-D{feature_name}=disabled"
200+
)
201+
202+
def meson_args(self):
203+
args = []
204+
205+
args.append(self.enable_or_disable("dwrite"))
206+
args.append(self.enable_or_disable("fontconfig", variant="ft"))
207+
args.append(self.enable_or_disable("freetype", variant="fc"))
208+
209+
args.append(self.enable_or_disable("png"))
210+
211+
args.append(self.enable_or_disable("quartz"))
212+
args.append(self.enable_or_disable("tee"))
213+
args.append(self.enable_or_disable("xcb"))
214+
215+
args.append(self.enable_or_disable("xlib", variant="X"))
216+
args.append(self.enable_or_disable("xlib-xcb", variant="X"))
217+
218+
args.append(self.enable_or_disable("zlib"))
219+
220+
args.append(self.enable_or_disable("glib", variant="gobject"))
221+
args.append(self.enable_or_disable("spectre"))
222+
args.append(self.enable_or_disable("symbol-lookup"))
223+
224+
return args
225+
76226

77-
def autoreconf(self, spec, prefix):
227+
class AutotoolsBuilder(autotools.AutotoolsBuilder):
228+
def autoreconf(self, pkg, spec, prefix):
78229
# Regenerate, directing the script *not* to call configure before Spack
79230
# does
80231
which("sh")("./autogen.sh", extra_env={"NOCONFIGURE": "1"})

var/spack/repos/builtin/packages/pango/package.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ class Pango(MesonPackage):
5454
depends_on("harfbuzz")
5555
depends_on("harfbuzz+coretext", when="platform=darwin")
5656
depends_on("cairo+ft+fc")
57+
# quartz needed even when ~X on the new cairo versions
58+
requires("^cairo+quartz", when="^[email protected]: platform=darwin")
5759
depends_on("cairo~X", when="~X")
5860
depends_on("cairo+X", when="+X")
5961
depends_on("libxft", when="+X")

0 commit comments

Comments
 (0)