From acfcb4de760c6d51ce9e69410b41d68aaea99b1e Mon Sep 17 00:00:00 2001 From: Niklas Guertler Date: Tue, 15 Sep 2020 16:24:04 +0200 Subject: [PATCH 01/10] Glib: Make libelf dependency optional --- recipes/glib/all/conandata.yml | 4 +++ recipes/glib/all/conanfile.py | 8 +++++- recipes/glib/all/patches/00-optdeps.patch | 32 +++++++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 recipes/glib/all/patches/00-optdeps.patch diff --git a/recipes/glib/all/conandata.yml b/recipes/glib/all/conandata.yml index d61e107dcfe6c..d145d47343fb7 100644 --- a/recipes/glib/all/conandata.yml +++ b/recipes/glib/all/conandata.yml @@ -14,3 +14,7 @@ sources: "2.66.0": url: "https://download.gnome.org/sources/glib/2.66/glib-2.66.0.tar.xz" sha256: "c5a66bf143065648c135da4c943d2ac23cce15690fc91c358013b2889111156c" +patches: + "2.66.0": + - patch_file: "patches/00-optdeps.patch" + base_path: "source_subfolder" diff --git a/recipes/glib/all/conanfile.py b/recipes/glib/all/conanfile.py index 5ca3a7d366c10..af2c2aec24575 100644 --- a/recipes/glib/all/conanfile.py +++ b/recipes/glib/all/conanfile.py @@ -10,6 +10,7 @@ class GLibConan(ConanFile): description = "GLib provides the core application building blocks for libraries and applications written in C" topics = ("conan", "glib", "gobject", "gio", "gmodule") url = "https://github.com/conan-io/conan-center-index" + exports_sources = ["patches/**"] homepage = "https://gitlab.gnome.org/GNOME/glib" license = "LGPL-2.1" settings = "os", "arch", "compiler", "build_type" @@ -94,12 +95,16 @@ def _configure_meson(self): defs["selinux"] = "enabled" if self.options.with_selinux else "disabled" defs["libmount"] = "enabled" if self.options.with_mount else "disabled" defs["internal_pcre"] = not self.options.with_pcre + defs["libelf"] = "enabled" if self.options.with_elf else "disabled" meson.configure(source_folder=self._source_subfolder, args=['--wrap-mode=nofallback'], build_folder=self._build_subfolder, defs=defs) return meson def build(self): + for patch in self.conan_data["patches"][self.version]: + tools.patch(**patch) + for filename in [os.path.join(self._source_subfolder, "meson.build"), os.path.join(self._source_subfolder, "glib", "meson.build"), os.path.join(self._source_subfolder, "gobject", "meson.build"), @@ -196,7 +201,8 @@ def package_info(self): self.cpp_info.components["gio-unix-2.0"].includedirs = [os.path.join("include", "gio-unix-2.0")] self.cpp_info.components["gresource"].libs = [] # this is actualy an executable - self.cpp_info.components["gresource"].requires.append("libelf::libelf") # this is actualy an executable + if self.options.with_elf: + self.cpp_info.components["gresource"].requires.append("libelf::libelf") # this is actualy an executable bin_path = os.path.join(self.package_folder, "bin") self.output.info("Appending PATH env var with: {}".format(bin_path)) diff --git a/recipes/glib/all/patches/00-optdeps.patch b/recipes/glib/all/patches/00-optdeps.patch new file mode 100644 index 0000000000000..c601132ee25c9 --- /dev/null +++ b/recipes/glib/all/patches/00-optdeps.patch @@ -0,0 +1,32 @@ +diff -ur a/gio/meson.build b/gio/meson.build +--- a/gio/meson.build 2020-09-10 12:42:41.546684000 +0200 ++++ b/gio/meson.build 2020-09-15 10:45:38.897447913 +0200 +@@ -874,14 +874,14 @@ + + # Dependencies used by executables below + have_libelf = false +-libelf = dependency('libelf', version : '>= 0.8.12', required : false) ++libelf = dependency('libelf', version : '>= 0.8.12', required : get_option ('libelf')) + if libelf.found() + have_libelf = true + else + # This fallback is necessary on *BSD. elfutils isn't the only libelf + # implementation, and *BSD usually includes their own libelf as a system + # library which doesn't have a corresponding .pc file. +- libelf = cc.find_library('elf', required : false) ++ libelf = cc.find_library('elf', required : get_option ('libelf')) + have_libelf = libelf.found() + have_libelf = have_libelf and cc.has_function('elf_begin', dependencies : libelf) + have_libelf = have_libelf and cc.has_function('elf_getshdrstrndx', dependencies : libelf) +diff -ur a/meson_options.txt b/meson_options.txt +--- a/meson_options.txt 2020-09-10 12:42:41.673685600 +0200 ++++ b/meson_options.txt 2020-09-15 10:44:18.049745441 +0200 +@@ -111,3 +111,8 @@ + value : true, + yield : true, + description : 'Enable GLib checks such as API guards (see docs/macros.txt)') ++ ++option('libelf', ++ type : 'feature', ++ value : 'auto', ++ description : 'Use libelf') From dba4fc4c63a3c622172d86ab5e01662a5044fea0 Mon Sep 17 00:00:00 2001 From: Niklas Guertler Date: Wed, 23 Sep 2020 15:05:31 +0200 Subject: [PATCH 02/10] Glib: Use libelf patch only for vesions >= 2.65.1 --- recipes/glib/all/conandata.yml | 10 ++++++++++ recipes/glib/all/conanfile.py | 8 +++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/recipes/glib/all/conandata.yml b/recipes/glib/all/conandata.yml index d145d47343fb7..2574887d745b4 100644 --- a/recipes/glib/all/conandata.yml +++ b/recipes/glib/all/conandata.yml @@ -15,6 +15,16 @@ sources: url: "https://download.gnome.org/sources/glib/2.66/glib-2.66.0.tar.xz" sha256: "c5a66bf143065648c135da4c943d2ac23cce15690fc91c358013b2889111156c" patches: + "2.65.1": + - patch_file: "patches/00-optdeps.patch" + base_path: "source_subfolder" + "2.65.2": + - patch_file: "patches/00-optdeps.patch" + base_path: "source_subfolder" + "2.65.3": + - patch_file: "patches/00-optdeps.patch" + base_path: "source_subfolder" "2.66.0": - patch_file: "patches/00-optdeps.patch" base_path: "source_subfolder" + diff --git a/recipes/glib/all/conanfile.py b/recipes/glib/all/conanfile.py index af2c2aec24575..ccb731096af05 100644 --- a/recipes/glib/all/conanfile.py +++ b/recipes/glib/all/conanfile.py @@ -95,15 +95,17 @@ def _configure_meson(self): defs["selinux"] = "enabled" if self.options.with_selinux else "disabled" defs["libmount"] = "enabled" if self.options.with_mount else "disabled" defs["internal_pcre"] = not self.options.with_pcre - defs["libelf"] = "enabled" if self.options.with_elf else "disabled" + if tools.Version(self.version) >= tools.Version("2.65.1"): + defs["libelf"] = "enabled" if self.options.with_elf else "disabled" meson.configure(source_folder=self._source_subfolder, args=['--wrap-mode=nofallback'], build_folder=self._build_subfolder, defs=defs) return meson def build(self): - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) + if self.version in self.conan_data["patches"]: + for patch in self.conan_data["patches"][self.version]: + tools.patch(**patch) for filename in [os.path.join(self._source_subfolder, "meson.build"), os.path.join(self._source_subfolder, "glib", "meson.build"), From 0163f6928b5f75cb9ec711556970530364ba3e89 Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Tue, 29 Sep 2020 11:08:54 +0200 Subject: [PATCH 03/10] glib: delete with_elf option if < 2.65.1 libelf is always required if version < 2.65.1 --- recipes/glib/all/conanfile.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/recipes/glib/all/conanfile.py b/recipes/glib/all/conanfile.py index ccb731096af05..52d1953154c63 100644 --- a/recipes/glib/all/conanfile.py +++ b/recipes/glib/all/conanfile.py @@ -52,6 +52,8 @@ def config_options(self): if self.settings.os != "Linux": del self.options.with_mount del self.options.with_selinux + if tools.Version(self.version) < "2.65.1": + del self.options.with_elf def build_requirements(self): self.build_requires("meson/0.54.2") @@ -61,7 +63,7 @@ def build_requirements(self): def requirements(self): if self.options.with_pcre: self.requires("pcre/8.41") - if self.options.with_elf: + if self.options.get_safe("with_elf", True): self.requires("libelf/0.8.13") if self.settings.os == "Linux": if self.options.with_mount: @@ -95,7 +97,7 @@ def _configure_meson(self): defs["selinux"] = "enabled" if self.options.with_selinux else "disabled" defs["libmount"] = "enabled" if self.options.with_mount else "disabled" defs["internal_pcre"] = not self.options.with_pcre - if tools.Version(self.version) >= tools.Version("2.65.1"): + if tools.Version(self.version) >= "2.65.1": defs["libelf"] = "enabled" if self.options.with_elf else "disabled" meson.configure(source_folder=self._source_subfolder, args=['--wrap-mode=nofallback'], @@ -145,7 +147,6 @@ def package(self): os.unlink(pdb_file) def package_info(self): - self.cpp_info.components["glib-2.0"].libs = ["glib-2.0"] if self.settings.os == "Linux": self.cpp_info.components["glib-2.0"].system_libs.append("pthread") @@ -169,11 +170,11 @@ def package_info(self): self.cpp_info.components["gmodule-no-export-2.0"].system_libs.append("pthread") self.cpp_info.components["gmodule-no-export-2.0"].system_libs.append("dl") self.cpp_info.components["gmodule-no-export-2.0"].requires.append("glib-2.0") - + self.cpp_info.components["gmodule-export-2.0"].requires.extend(["gmodule-no-export-2.0", "glib-2.0"]) if self.settings.os == "Linux": self.cpp_info.components["gmodule-export-2.0"].sharedlinkflags.append("-Wl,--export-dynamic") - + self.cpp_info.components["gmodule-2.0"].requires.extend(["gmodule-no-export-2.0", "glib-2.0"]) if self.settings.os == "Linux": self.cpp_info.components["gmodule-2.0"].sharedlinkflags.append("-Wl,--export-dynamic") @@ -203,7 +204,7 @@ def package_info(self): self.cpp_info.components["gio-unix-2.0"].includedirs = [os.path.join("include", "gio-unix-2.0")] self.cpp_info.components["gresource"].libs = [] # this is actualy an executable - if self.options.with_elf: + if self.options.get_safe("with_elf", True): self.cpp_info.components["gresource"].requires.append("libelf::libelf") # this is actualy an executable bin_path = os.path.join(self.package_folder, "bin") From a674bc4457612a4fbd8ac1ddd7a808c7c97a6c69 Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Tue, 29 Sep 2020 11:14:56 +0200 Subject: [PATCH 04/10] glib: move requires in requirements method --- recipes/glib/all/conanfile.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/recipes/glib/all/conanfile.py b/recipes/glib/all/conanfile.py index 52d1953154c63..cb3c3991714d6 100644 --- a/recipes/glib/all/conanfile.py +++ b/recipes/glib/all/conanfile.py @@ -30,7 +30,6 @@ class GLibConan(ConanFile): _build_subfolder = 'build_subfolder' short_paths = True generators = "pkg_config" - requires = "zlib/1.2.11", "libffi/3.2.1" @property def _is_msvc(self): @@ -61,6 +60,8 @@ def build_requirements(self): self.build_requires("pkgconf/1.7.3") def requirements(self): + self.requires("libffi/3.2.1") + self.requires("zlib/1.2.11") if self.options.with_pcre: self.requires("pcre/8.41") if self.options.get_safe("with_elf", True): From f2d805ec71a743e56c93f153f7c5f7ba981017c5 Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Tue, 29 Sep 2020 11:17:36 +0200 Subject: [PATCH 05/10] glib: fix loop in patches --- recipes/glib/all/conanfile.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/recipes/glib/all/conanfile.py b/recipes/glib/all/conanfile.py index cb3c3991714d6..2a2f66b281081 100644 --- a/recipes/glib/all/conanfile.py +++ b/recipes/glib/all/conanfile.py @@ -106,9 +106,8 @@ def _configure_meson(self): return meson def build(self): - if self.version in self.conan_data["patches"]: - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) for filename in [os.path.join(self._source_subfolder, "meson.build"), os.path.join(self._source_subfolder, "glib", "meson.build"), From ed4de69951bc16508ec3e10cae953665f4c9eec3 Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Tue, 29 Sep 2020 13:05:01 +0200 Subject: [PATCH 06/10] glib: delete with_elf option in configure --- recipes/glib/all/conanfile.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/recipes/glib/all/conanfile.py b/recipes/glib/all/conanfile.py index 2a2f66b281081..b1015f6e0aa2e 100644 --- a/recipes/glib/all/conanfile.py +++ b/recipes/glib/all/conanfile.py @@ -51,7 +51,11 @@ def config_options(self): if self.settings.os != "Linux": del self.options.with_mount del self.options.with_selinux + + def configure(self): if tools.Version(self.version) < "2.65.1": + if not self.options.with_elf: + self.output.warn("libelf dependency can't be disabled in glib < 2.65.1") del self.options.with_elf def build_requirements(self): From c59d4c19f58cf3834b4b921c05852ed6f9402c68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20G=C3=BCrtler?= Date: Thu, 14 Jan 2021 18:03:37 +0100 Subject: [PATCH 07/10] Update recipes/glib/all/conanfile.py Co-authored-by: ericLemanissier --- recipes/glib/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/glib/all/conanfile.py b/recipes/glib/all/conanfile.py index a30a25a8a43f7..ef450148abb85 100644 --- a/recipes/glib/all/conanfile.py +++ b/recipes/glib/all/conanfile.py @@ -289,7 +289,7 @@ def package_info(self): if self.options.get_safe("with_elf", True): self.cpp_info.components["gresource"].requires.append( "libelf::libelf" - ) # this is actualy an executable + ) # this is actually an executable bin_path = os.path.join(self.package_folder, "bin") self.output.info("Appending PATH env var with: {}".format(bin_path)) From a57403f5474010bfa541421ff844cc14dc9b7414 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20G=C3=BCrtler?= Date: Fri, 15 Jan 2021 16:59:41 +0100 Subject: [PATCH 08/10] Update recipes/glib/all/conanfile.py Co-authored-by: Uilian Ries --- recipes/glib/all/conanfile.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/recipes/glib/all/conanfile.py b/recipes/glib/all/conanfile.py index ef450148abb85..e7edc534e0332 100644 --- a/recipes/glib/all/conanfile.py +++ b/recipes/glib/all/conanfile.py @@ -48,10 +48,8 @@ def configure(self): "glib can not be built as static library on Windows. " "see https://gitlab.gnome.org/GNOME/glib/-/issues/692" ) - if tools.Version(self.version) < "2.67.0": - if not self.options.with_elf: - self.output.warn("libelf dependency can't be disabled in glib < 2.67.0") - del self.options.with_elf + if tools.Version(self.version) < "2.67.0" and not self.options.with_elf: + raise ConanInvalidConfiguration("libelf dependency can't be disabled in glib < 2.67.0") def config_options(self): if self.settings.os == "Windows": From 979751bb676794ed098317d28c2177eb2d3e813b Mon Sep 17 00:00:00 2001 From: Niklas Guertler Date: Fri, 15 Jan 2021 17:01:18 +0100 Subject: [PATCH 09/10] Glib: Reverted get_safe on with_elf --- recipes/glib/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/glib/all/conanfile.py b/recipes/glib/all/conanfile.py index e7edc534e0332..c53dabfdaea97 100644 --- a/recipes/glib/all/conanfile.py +++ b/recipes/glib/all/conanfile.py @@ -68,7 +68,7 @@ def requirements(self): self.requires("libffi/3.3") if self.options.with_pcre: self.requires("pcre/8.44") - if self.options.get_safe("with_elf", True): + if self.options.with_elf: self.requires("libelf/0.8.13") if self.options.get_safe("with_mount"): self.requires("libmount/2.36") From 10fad7130b03c65f84edbc6bd3bb6e413a8638e3 Mon Sep 17 00:00:00 2001 From: Niklas Guertler Date: Fri, 15 Jan 2021 17:02:36 +0100 Subject: [PATCH 10/10] Glib: Unneccessary whitespace modification removed --- recipes/glib/all/conanfile.py | 1 - 1 file changed, 1 deletion(-) diff --git a/recipes/glib/all/conanfile.py b/recipes/glib/all/conanfile.py index c53dabfdaea97..8127a6b68be03 100644 --- a/recipes/glib/all/conanfile.py +++ b/recipes/glib/all/conanfile.py @@ -108,7 +108,6 @@ def _configure_meson(self): build_folder=self._build_subfolder, defs=defs, ) - return meson def _patch_sources(self):