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

Glib: Make libelf dependency optional #2925

Merged
merged 14 commits into from
Jan 16, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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/glib/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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":

This comment was marked as outdated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made the patch available since 2.65.1 because it works from there. On 2.65.0 we keep the old behaviour.

- patch_file: "patches/00-optdeps.patch"
base_path: "source_subfolder"
8 changes: 7 additions & 1 deletion recipes/glib/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -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))
Expand Down
32 changes: 32 additions & 0 deletions recipes/glib/all/patches/00-optdeps.patch
Original file line number Diff line number Diff line change
@@ -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')