From e43d4cfee080085f0ef4e144f3e3c9719bddfe93 Mon Sep 17 00:00:00 2001 From: Michael Kuhn Date: Mon, 29 May 2023 12:38:57 +0200 Subject: glib: add 2.76.3 and 2.76.2, update build systems (#37226) This also converts the package to the new way of handling multiple build systems. Co-authored-by: michaelkuhn --- var/spack/repos/builtin/packages/glib/package.py | 203 +++++++++++------------ 1 file changed, 97 insertions(+), 106 deletions(-) diff --git a/var/spack/repos/builtin/packages/glib/package.py b/var/spack/repos/builtin/packages/glib/package.py index 5d53b74c25..2452550f30 100644 --- a/var/spack/repos/builtin/packages/glib/package.py +++ b/var/spack/repos/builtin/packages/glib/package.py @@ -9,7 +9,7 @@ from spack.package import * from spack.util.environment import is_system_path -class Glib(Package): +class Glib(MesonPackage, AutotoolsPackage): """GLib provides the core application building blocks for libraries and applications written in C. @@ -26,6 +26,8 @@ class Glib(Package): maintainers("michaelkuhn") + version("2.76.3", sha256="c0be444e403d7c3184d1f394f89f0b644710b5e9331b54fa4e8b5037813ad32a") + version("2.76.2", sha256="24f3847857b1d8674cdb0389a36edec0f13c666cd3ce727ecd340eb9da8aca9e") version("2.76.1", sha256="43dc0f6a126958f5b454136c4398eab420249c16171a769784486e25f2fda19f") version("2.74.7", sha256="196ab86c27127a61b7a70c3ba6af7b97bdc01c07cd3b21abd5e778b955eccb1b") version("2.74.6", sha256="069cf7e51cd261eb163aaf06c8d1754c6835f31252180aff5814e5afc7757fbc") @@ -119,9 +121,17 @@ class Glib(Package): description="Enable tracing support", ) - depends_on("meson@0.49.2:", when="@2.61.2:", type="build") - depends_on("meson@0.48.0:", when="@2.58.0:", type="build") - depends_on("ninja", when="@2.58.0:", type="build") + build_system( + conditional("meson", when="@2.58:"), + conditional("autotools", when="@:2.57"), + default="meson", + ) + + with when("build_system=meson"): + depends_on("meson@0.60.0:", when="@2.73:", type="build") + depends_on("meson@0.52.0:", when="@2.71:2.72", type="build") + depends_on("meson@0.49.2:", when="@2.61.2:2.70", type="build") + depends_on("meson@0.48.0:", when="@:2.61.1", type="build") depends_on("pkgconfig", type="build") depends_on("libffi") @@ -180,6 +190,88 @@ class Glib(Package): def libs(self): return find_libraries(["libglib*"], root=self.prefix, recursive=True) + +class BaseBuilder(metaclass=spack.builder.PhaseCallbacksMeta): + @property + def dtrace_copy_path(self): + return join_path(self.stage.source_path, "dtrace-copy") + + @run_before("install") + def fix_python_path(self): + if not self.spec.satisfies("@2.53.4:"): + return + + files = ["gobject/glib-genmarshal.in", "gobject/glib-mkenums.in"] + + filter_file( + "^#!/usr/bin/env @PYTHON@", + "#!/usr/bin/env {0}".format(os.path.basename(self.spec["python"].command.path)), + *files, + ) + + @run_before("install") + def fix_dtrace_usr_bin_path(self): + if "tracing=dtrace" not in self.spec: + return + + # dtrace may cause glib build to fail because it uses + # '/usr/bin/python' in the shebang. To work around that + # we copy the original script into a temporary folder, and + # change the shebang to '/usr/bin/env python' + dtrace = which("dtrace").path + dtrace_copy = join_path(self.dtrace_copy_path, "dtrace") + + with working_dir(self.dtrace_copy_path, create=True): + copy(dtrace, dtrace_copy) + filter_file( + "^#!/usr/bin/python", + "#!/usr/bin/env {0}".format(os.path.basename(self.spec["python"].command.path)), + dtrace_copy, + ) + + # To have our own copy of dtrace in PATH, we need to + # prepend to PATH the temporary folder where it resides + env["PATH"] = ":".join([self.dtrace_copy_path] + env["PATH"].split(":")) + + @run_after("install") + def filter_sbang(self): + # Revert sbang, so Spack's sbang hook can fix it up (we have to do + # this after install because otherwise the install target will try + # to rebuild files as filter_file updates the timestamps) + if self.spec.satisfies("@2.53.4:"): + pattern = "^#!/usr/bin/env {0}".format( + os.path.basename(self.spec["python"].command.path) + ) + repl = "#!{0}".format(self.spec["python"].command.path) + files = ["glib-genmarshal", "glib-mkenums"] + else: + pattern = "^#! /usr/bin/perl" + repl = "#!{0}".format(self.spec["perl"].command.path) + files = ["glib-mkenums"] + + files = [join_path(self.prefix.bin, file) for file in files] + filter_file(pattern, repl, *files, backup=False) + + @run_after("install") + def gettext_libdir(self): + # Packages that link to glib were also picking up -lintl from glib's + # glib-2.0.pc file. However, packages such as py-pygobject were + # bypassing spack's compiler wrapper for linking and thus not finding + # the gettext library directory. The patch below explicitly adds the + # appropriate -L path. + spec = self.spec + if ( + spec.satisfies("@2.0:2") + and "intl" in self.spec["gettext"].libs.names + and not is_system_path(spec["gettext"].prefix) + ): + pattern = "Libs:" + repl = "Libs: -L{0} -Wl,-rpath={0} ".format(spec["gettext"].libs.directories[0]) + myfile = join_path(self.spec["glib"].libs.directories[0], "pkgconfig", "glib-2.0.pc") + filter_file(pattern, repl, myfile, backup=False) + + +class MesonBuilder(BaseBuilder, spack.build_systems.meson.MesonBuilder): def meson_args(self): args = [] if self.spec.satisfies("@2.63.5:"): @@ -220,21 +312,8 @@ class Glib(Package): args.append("-Diconv=gnu") return args - def install(self, spec, prefix): - with working_dir("spack-build", create=True): - # We cannot simply do - # meson('..', *std_meson_args, *self.meson_args()) - # because that is not Python 2 compatible. Instead, collect - # arguments into a temporary buffer first. - args = [] - args.extend(std_meson_args) - args.extend(self.meson_args()) - meson("..", *args) - ninja("-v") - if self.run_tests: - ninja("test") - ninja("install") +class AutotoolsBuilder(BaseBuilder, spack.build_systems.autotools.AutotoolsBuilder): def configure_args(self): args = [] if "+libmount" in self.spec: @@ -275,91 +354,3 @@ class Glib(Package): args.append("GTKDOC_MKPDF={0}".format(true)) args.append("GTKDOC_REBASE={0}".format(true)) return args - - @when("@:2.57") - def install(self, spec, prefix): - configure("--prefix={0}".format(prefix), *self.configure_args()) - make() - if self.run_tests: - make("check") - make("install") - if self.run_tests: - make("installcheck") - - @property - def dtrace_copy_path(self): - return join_path(self.stage.source_path, "dtrace-copy") - - @run_before("install") - def fix_python_path(self): - if not self.spec.satisfies("@2.53.4:"): - return - - files = ["gobject/glib-genmarshal.in", "gobject/glib-mkenums.in"] - - filter_file( - "^#!/usr/bin/env @PYTHON@", - "#!/usr/bin/env {0}".format(os.path.basename(self.spec["python"].command.path)), - *files, - ) - - @run_before("install") - def fix_dtrace_usr_bin_path(self): - if "tracing=dtrace" not in self.spec: - return - - # dtrace may cause glib build to fail because it uses - # '/usr/bin/python' in the shebang. To work around that - # we copy the original script into a temporary folder, and - # change the shebang to '/usr/bin/env python' - dtrace = which("dtrace").path - dtrace_copy = join_path(self.dtrace_copy_path, "dtrace") - - with working_dir(self.dtrace_copy_path, create=True): - copy(dtrace, dtrace_copy) - filter_file( - "^#!/usr/bin/python", - "#!/usr/bin/env {0}".format(os.path.basename(self.spec["python"].command.path)), - dtrace_copy, - ) - - # To have our own copy of dtrace in PATH, we need to - # prepend to PATH the temporary folder where it resides - env["PATH"] = ":".join([self.dtrace_copy_path] + env["PATH"].split(":")) - - @run_after("install") - def filter_sbang(self): - # Revert sbang, so Spack's sbang hook can fix it up (we have to do - # this after install because otherwise the install target will try - # to rebuild files as filter_file updates the timestamps) - if self.spec.satisfies("@2.53.4:"): - pattern = "^#!/usr/bin/env {0}".format( - os.path.basename(self.spec["python"].command.path) - ) - repl = "#!{0}".format(self.spec["python"].command.path) - files = ["glib-genmarshal", "glib-mkenums"] - else: - pattern = "^#! /usr/bin/perl" - repl = "#!{0}".format(self.spec["perl"].command.path) - files = ["glib-mkenums"] - - files = [join_path(self.prefix.bin, file) for file in files] - filter_file(pattern, repl, *files, backup=False) - - @run_after("install") - def gettext_libdir(self): - # Packages that link to glib were also picking up -lintl from glib's - # glib-2.0.pc file. However, packages such as py-pygobject were - # bypassing spack's compiler wrapper for linking and thus not finding - # the gettext library directory. The patch below explicitly adds the - # appropriate -L path. - spec = self.spec - if ( - spec.satisfies("@2.0:2") - and "intl" in self.spec["gettext"].libs.names - and not is_system_path(spec["gettext"].prefix) - ): - pattern = "Libs:" - repl = "Libs: -L{0} -Wl,-rpath={0} ".format(spec["gettext"].libs.directories[0]) - myfile = join_path(self.spec["glib"].libs.directories[0], "pkgconfig", "glib-2.0.pc") - filter_file(pattern, repl, myfile, backup=False) -- cgit v1.2.3-70-g09d2