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: add v2.80.0 #23559

Closed
wants to merge 7 commits into from
Closed
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
7 changes: 7 additions & 0 deletions recipes/glib/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
sources:
"2.80.0":
source:
url: "https://download.gnome.org/sources/glib/2.80/glib-2.80.0.tar.xz"
sha256: "8228a92f92a412160b139ae68b6345bd28f24434a7b5af150ebe21ff587a561d"
pypa-packaging:
url: "https://github.com/pypa/packaging/archive/refs/tags/24.0.tar.gz"
sha256: "1bf35cf2c2be982f2ae6c905760ae19cb744fadbf56269f2e54f7bdcef64d291"
"2.78.3":
url: "https://download.gnome.org/sources/glib/2.78/glib-2.78.3.tar.xz"
sha256: "609801dd373796e515972bf95fc0b2daa44545481ee2f465c4f204d224b2bc21"
Expand Down
57 changes: 52 additions & 5 deletions recipes/glib/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,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
import os
import shutil

Expand All @@ -23,7 +24,8 @@ class GLibConan(ConanFile):
topics = "gio", "gmodule", "gnome", "gobject", "gtk"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://gitlab.gnome.org/GNOME/glib"
license = "LGPL-2.1-or-later"
# The latter half of the AND in the license is for the vendored pypa/packaging components
license = "LGPL-2.1-or-later AND (Apache-2.0 OR BSD-2-Clause)"
package_type = "library"
settings = "os", "arch", "compiler", "build_type"
options = {
Expand Down Expand Up @@ -59,6 +61,8 @@ def configure(self):
self.options.rm_safe("fPIC")
self.settings.rm_safe("compiler.cppstd")
self.settings.rm_safe("compiler.libcxx")
if Version(self.version) < "2.79":
self.license = "LGPL-2.1-or-later"

def layout(self):
basic_layout(self, src_folder="src")
Expand All @@ -81,12 +85,30 @@ def requirements(self):
self.requires("libiconv/1.17")

def build_requirements(self):
self.tool_requires("meson/1.2.2")
self.tool_requires("meson/1.4.0")
if not self.conf.get("tools.gnu:pkg_config", check_type=str):
self.tool_requires("pkgconf/2.0.3")
self.tool_requires("pkgconf/2.1.0")

@property
def _vendor_pypa_packaging(self):
return Version(self.version) >= "2.79"

@property
def _pypa_packaging_dir(self):
return os.path.join(self.source_folder, "pypa-packaging")

@property
def _codegen_dir(self):
return os.path.join(self.source_folder, "gio", "gdbus-2.0", "codegen")

def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)
if self._vendor_pypa_packaging:
get(self, **self.conan_data["sources"][self.version]["source"], strip_root=True)
# Vendor https://github.com/pypa/packaging/blob/24.0/src/packaging/version.py
get(self, **self.conan_data["sources"][self.version]["pypa-packaging"], strip_root=True,
destination=self._pypa_packaging_dir)
else:
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def generate(self):
virtual_build_env = VirtualBuildEnv(self)
Expand All @@ -101,6 +123,9 @@ def generate(self):
tc.project_options["xattr"] = "false"
tc.project_options["tests"] = "false"
tc.project_options["libelf"] = "enabled" if self.options.get_safe("with_elf") else "disabled"
if Version(self.version) >= "2.79.0":
# https://gitlab.gnome.org/GNOME/glib/-/commit/fe32c3f5c5155eab5cd4838867b0c95beefa2239
tc.project_options["introspection"] = "disabled"
tc.generate()

def _patch_sources(self):
Expand Down Expand Up @@ -130,14 +155,36 @@ def _patch_sources(self):
"'res'",
)

if self._vendor_pypa_packaging:
# Use the vendored packaging.version.Version
copy(self, "version.py", os.path.join(self._pypa_packaging_dir, "src", "packaging"), self._codegen_dir)
copy(self, "_structures.py", os.path.join(self._pypa_packaging_dir, "src", "packaging"), self._codegen_dir)
replace_in_file(self, os.path.join(self._codegen_dir, "utils.py"),
"import packaging.version",
"from .version import Version")
replace_in_file(self, os.path.join(self._codegen_dir, "utils.py"),
"packaging.version.Version",
"Version")
replace_in_file(self, os.path.join(self._codegen_dir, "meson.build"),
"'utils.py',",
"'utils.py', 'version.py', '_structures.py',")
replace_in_file(self, os.path.join(self.source_folder, "meson.build"),
".find_installation(modules: ['packaging'])",
".find_installation()")

def build(self):
self._patch_sources()
meson = Meson(self)
meson.configure()
meson.build()

def package(self):
copy(self, pattern="LGPL-2.1-or-later.txt", dst=os.path.join(self.package_folder, "licenses"), src=os.path.join(self.source_folder, "LICENSES"))
copy(self, "LGPL-2.1-or-later.txt", os.path.join(self.source_folder, "LICENSES"), os.path.join(self.package_folder, "licenses"))
if self._vendor_pypa_packaging:
# pypa/packaging license files
copy(self, "LICENSE*", os.path.join(self.source_folder, "pypa-packaging"), os.path.join(self.package_folder, "licenses"))
os.rename(os.path.join(self.package_folder, "licenses", "LICENSE"),
os.path.join(self.package_folder, "licenses", "LICENSE.pypa-packaging"))
meson = Meson(self)
meson.install()
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
Expand Down
11 changes: 6 additions & 5 deletions recipes/glib/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
from conan.tools.build import can_run
from conan.tools.cmake import cmake_layout, CMake, CMakeDeps, CMakeToolchain
from conan.tools.env import Environment, VirtualBuildEnv, VirtualRunEnv
from conan.tools.gnu import PkgConfig, PkgConfigDeps
from conan.tools.gnu import PkgConfigDeps
import io
import os


Expand All @@ -18,7 +19,7 @@ def requirements(self):

def build_requirements(self):
if self.settings.os != "Windows" and not self.conf.get("tools.gnu:pkg_config", default=False, check_type=str):
self.tool_requires("pkgconf/2.0.3")
self.tool_requires("pkgconf/2.1.0")

def generate(self):
tc = CMakeToolchain(self)
Expand Down Expand Up @@ -54,6 +55,6 @@ def test(self):
self.run(bin_path, env="conanrun")

if self.settings.os != "Windows":
pkg_config = PkgConfig(self, "gio-2.0", pkg_config_path=self.generators_folder)
gdbus_codegen = pkg_config.variables["gdbus_codegen"]
self.run(f"{gdbus_codegen} -h", env="conanrun")
mybuf = io.StringIO()
self.run(f"PKG_CONFIG_PATH={self.generators_folder} pkgconf --variable=gdbus_codegen gio-2.0", mybuf, env="conanbuild")
self.run(f"{mybuf.getvalue().strip()} -h")
2 changes: 2 additions & 0 deletions recipes/glib/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
versions:
"2.80.0":
folder: all
"2.78.3":
folder: all
"2.78.1":
Expand Down
Loading