Skip to content

Commit

Permalink
(#18611) at-spi2-core: conan V2 compatibility
Browse files Browse the repository at this point in the history
* at-spi2-core: conan V2 compatibility

* bump deps

* add glib as tool requirement

* Use proper conan min version check

* Option

* Add package_type

---------

Co-authored-by: Rubén Rincón Blanco <git@rinconblanco.es>
  • Loading branch information
ericLemanissier and AbrilRBS authored Aug 11, 2023
1 parent 78976dd commit d05b789
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 30 deletions.
22 changes: 10 additions & 12 deletions recipes/at-spi2-core/new/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
import os


required_conan_version = ">=1.53.0"
required_conan_version = ">=1.60.0 <2.0 || >=2.0.5"

class AtSpi2CoreConan(ConanFile):
name = "at-spi2-core"
description = "It provides a Service Provider Interface for the Assistive Technologies available on the GNOME platform and a library against which applications can be linked"
Expand All @@ -20,17 +21,18 @@ class AtSpi2CoreConan(ConanFile):

provides = "at-spi2-atk", "atk"

package_type = "library"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
"with_x11": [True, False],
}
}
default_options = {
"shared": False,
"fPIC": True,
"with_x11": False,
}
}

def export_sources(self):
export_conandata_patches(self)
Expand All @@ -40,22 +42,21 @@ def configure(self):
self.options.rm_safe("fPIC")
self.settings.rm_safe("compiler.libcxx")
self.settings.rm_safe("compiler.cppstd")
if self.options.shared:
self.options["glib"].shared = True

def build_requirements(self):
self.tool_requires("meson/1.1.1")
self.tool_requires("meson/1.2.0")
if not self.conf.get("tools.gnu:pkg_config", default=False, check_type=str):
self.tool_requires("pkgconf/1.9.3")
self.tool_requires("pkgconf/1.9.5")
self.tool_requires("glib/<host_version>")

def requirements(self):
self.requires("glib/2.76.3")
self.requires("glib/2.77.0")
if self.options.with_x11:
self.requires("xorg/system")
self.requires("dbus/1.15.6")

def validate(self):
if self.options.shared and not self.options["glib"].shared:
if self.options.shared and not self.dependencies["glib"].options.shared:
raise ConanInvalidConfiguration(
"Linking a shared library against static glib can cause unexpected behaviour."
)
Expand Down Expand Up @@ -123,6 +124,3 @@ def package_info(self):
self.cpp_info.components["atk-bridge"].includedirs = [os.path.join('include', 'at-spi2-atk', '2.0')]
self.cpp_info.components["atk-bridge"].requires = ["dbus::dbus", "atk", "glib::glib", "atspi"]
self.cpp_info.components["atk-bridge"].set_property("pkg_config_name", 'atk-bridge-2.0')

def package_id(self):
self.info.requires["glib"].full_package_mode()
9 changes: 0 additions & 9 deletions recipes/at-spi2-core/new/test_package/CMakeLists.txt

This file was deleted.

33 changes: 24 additions & 9 deletions recipes/at-spi2-core/new/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,32 @@
from conans import ConanFile, CMake, tools
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.layout import basic_layout
from conan.tools.meson import Meson
import os


class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"
settings = "os", "arch", "compiler", "build_type"
generators = "PkgConfigDeps", "MesonToolchain", "VirtualRunEnv", "VirtualBuildEnv"
test_type = "explicit"

def layout(self):
basic_layout(self)

def requirements(self):
self.requires(self.tested_reference_str)

def build_requirements(self):
self.tool_requires("meson/1.2.0")
if not self.conf.get("tools.gnu:pkg_config", default=False, check_type=str):
self.tool_requires("pkgconf/1.9.5")

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
meson = Meson(self)
meson.configure()
meson.build()

def test(self):
if not tools.cross_building(self):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindir, "test_package")
self.run(bin_path, env="conanrun")
5 changes: 5 additions & 0 deletions recipes/at-spi2-core/new/test_package/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
project('test_package', 'c')
package_dep = dependency('atspi-2')
executable('test_package',
sources : ['test_package.c'],
dependencies : [package_dep])

0 comments on commit d05b789

Please sign in to comment.