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

at-spi2-core: enable non-linux #20101

Merged
merged 19 commits into from
Oct 6, 2023
Merged
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
2 changes: 2 additions & 0 deletions recipes/at-spi2-core/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ versions:
folder: new
"2.49.1":
folder: new
"2.50.0":
folder: new
3 changes: 3 additions & 0 deletions recipes/at-spi2-core/new/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
sources:
"2.50.0":
sha256: e9f5a8c8235c9dd963b2171de9120301129c677dde933955e1df618b949c4adc
url: https://ftp.gnome.org/pub/gnome/sources/at-spi2-core/2.50/at-spi2-core-2.50.0.tar.xz
"2.49.1":
sha256: 53ed9eb77e4c48b3bf6ac4afb5689391e0d7d0f44f7ca4443d8b13c7dd26119c
url: https://ftp.gnome.org/pub/gnome/sources/at-spi2-core/2.49/at-spi2-core-2.49.1.tar.xz
Expand Down
67 changes: 51 additions & 16 deletions recipes/at-spi2-core/new/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.errors import ConanException, ConanInvalidConfiguration
from conan.tools.apple import fix_apple_shared_install_name
from conan.tools.env import VirtualBuildEnv
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, replace_in_file, rmdir
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, replace_in_file, rm, rmdir
from conan.tools.gnu import PkgConfigDeps
from conan.tools.layout import basic_layout
from conan.tools.meson import Meson, MesonToolchain
Expand Down Expand Up @@ -37,31 +38,40 @@ class AtSpi2CoreConan(ConanFile):
def export_sources(self):
export_conandata_patches(self)

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC

def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")
self.settings.rm_safe("compiler.libcxx")
self.settings.rm_safe("compiler.cppstd")

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

def requirements(self):
self.requires("glib/2.77.0")
self.requires("glib/2.78.0")
if self.options.with_x11:
self.requires("xorg/system")
self.requires("dbus/1.15.6")
if self.settings.os == "Linux":
self.requires("dbus/1.15.8")

def validate(self):
if self.options.shared and not self.dependencies["glib"].options.shared:
raise ConanInvalidConfiguration(
"Linking a shared library against static glib can cause unexpected behaviour."
)
if self.settings.os != "Linux":
raise ConanInvalidConfiguration("only linux is supported by this recipe")
if Version(self.version) < "2.49.1":
if self.settings.os == "Windows":
raise ConanInvalidConfiguration("Windows is not supported before version 2.49.1")
if Version(self.version) < "2.50.0":
if self.settings.os == "Macos":
raise ConanInvalidConfiguration("macos is not supported before version 2.50.0")

def layout(self):
basic_layout(self, src_folder="src")
Expand All @@ -80,6 +90,9 @@ def generate(self):
else:
tc.project_options["introspection"] = "no"
tc.project_options["x11"] = "yes" if self.options.with_x11 else "no"
if self.settings.os != "Linux":
tc.project_options["atk_only"] = "true"

tc.project_options["docs"] = "false"
tc.generate()
tc = PkgConfigDeps(self)
Expand Down Expand Up @@ -107,20 +120,42 @@ def package(self):
meson.install()
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
rmdir(self, os.path.join(self.package_folder, "etc"))
rm(self, "*.pdb", os.path.join(self.package_folder, "bin"))
fix_apple_shared_install_name(self)
fix_msvc_libname(self)


def package_info(self):
self.cpp_info.components["atspi"].libs = ['atspi']
self.cpp_info.components["atspi"].includedirs = ["include/at-spi-2.0"]
self.cpp_info.components["atspi"].requires = ["dbus::dbus", "glib::glib"]
self.cpp_info.components["atspi"].set_property("pkg_config_name", "atspi-2")
if self.settings.os == "Linux":
self.cpp_info.components["atspi"].libs = ['atspi']
self.cpp_info.components["atspi"].includedirs = ["include/at-spi-2.0"]
self.cpp_info.components["atspi"].requires = ["dbus::dbus", "glib::glib"]
self.cpp_info.components["atspi"].set_property("pkg_config_name", "atspi-2")

self.cpp_info.components["atk"].libs = ["atk-1.0"]
self.cpp_info.components["atk"].includedirs = ['include/atk-1.0']
self.cpp_info.components["atk"].requires = ["glib::glib"]
self.cpp_info.components["atk"].set_property("pkg_config_name", 'atk')

self.cpp_info.components["atk-bridge"].libs = ['atk-bridge-2.0']
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')
if self.settings.os == "Linux":
self.cpp_info.components["atk-bridge"].libs = ['atk-bridge-2.0']
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 fix_msvc_libname(conanfile, remove_lib_prefix=True):
"""remove lib prefix & change extension to .lib in case of cl like compiler"""
if not conanfile.settings.get_safe("compiler.runtime"):
return
from conan.tools.files import rename
import glob
libdirs = getattr(conanfile.cpp.package, "libdirs")
for libdir in libdirs:
for ext in [".dll.a", ".dll.lib", ".a"]:
full_folder = os.path.join(conanfile.package_folder, libdir)
for filepath in glob.glob(os.path.join(full_folder, f"*{ext}")):
libname = os.path.basename(filepath)[0:-len(ext)]
if remove_lib_prefix and libname[0:3] == "lib":
libname = libname[3:]
rename(conanfile, filepath, os.path.join(os.path.dirname(filepath), f"{libname}.lib"))
4 changes: 2 additions & 2 deletions recipes/at-spi2-core/new/test_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ def requirements(self):
self.requires(self.tested_reference_str)

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

def build(self):
meson = Meson(self)
Expand Down
2 changes: 1 addition & 1 deletion recipes/at-spi2-core/new/test_package/meson.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
project('test_package', 'c')
package_dep = dependency('atspi-2')
package_dep = dependency('atk')
executable('test_package',
sources : ['test_package.c'],
dependencies : [package_dep])
11 changes: 6 additions & 5 deletions recipes/at-spi2-core/new/test_package/test_package.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#include "atspi/atspi.h"
#include "assert.h"
#include <stdio.h>
#include <atk/atk.h>

int main()
{
atspi_init ();
assert(atspi_get_desktop_count() > 0);
return atspi_exit();
printf("ATK version %d.%d.%d\n",atk_get_major_version(), atk_get_minor_version(), atk_get_micro_version());
printf("binary age %d\n", atk_get_binary_age());
printf("interface age %d\n", atk_get_interface_age());
return 0;
}