From c9363c6fef2bf0c8005901d8910d7e93b717d4e9 Mon Sep 17 00:00:00 2001 From: Julianiolo Date: Tue, 7 May 2024 15:46:29 +0200 Subject: [PATCH 1/9] first try --- recipes/librsvg/all/conandata.yml | 4 + recipes/librsvg/all/conanfile.py | 197 ++++++++++++++++++ .../librsvg/all/test_package/CMakeLists.txt | 7 + recipes/librsvg/all/test_package/conanfile.py | 27 +++ .../librsvg/all/test_package/test_package.c | 6 + recipes/librsvg/config.yml | 3 + 6 files changed, 244 insertions(+) create mode 100644 recipes/librsvg/all/conandata.yml create mode 100644 recipes/librsvg/all/conanfile.py create mode 100644 recipes/librsvg/all/test_package/CMakeLists.txt create mode 100644 recipes/librsvg/all/test_package/conanfile.py create mode 100644 recipes/librsvg/all/test_package/test_package.c create mode 100644 recipes/librsvg/config.yml diff --git a/recipes/librsvg/all/conandata.yml b/recipes/librsvg/all/conandata.yml new file mode 100644 index 0000000000000..39c19a645e849 --- /dev/null +++ b/recipes/librsvg/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "2.58.91": + url: "https://download.gnome.org/sources/librsvg/2.58/librsvg-2.58.91.tar.xz" + sha256: "65846ae57c11aba288bf3a6fe517f800f7e38e7fbc79b98c99a8177634ed29f7" \ No newline at end of file diff --git a/recipes/librsvg/all/conanfile.py b/recipes/librsvg/all/conanfile.py new file mode 100644 index 0000000000000..2931cf2a71e79 --- /dev/null +++ b/recipes/librsvg/all/conanfile.py @@ -0,0 +1,197 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.apple import fix_apple_shared_install_name +from conan.tools.build import check_min_cppstd +from conan.tools.env import VirtualBuildEnv +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 +from conan.tools.microsoft import is_msvc, is_msvc_static_runtime +from conan.tools.scm import Version +import os + + +required_conan_version = ">=1.53.0" + +# +# INFO: Please, remove all comments before pushing your PR! +# + +# some information taken from https://gitlab.gnome.org/GNOME/librsvg/-/blob/main/Cargo.toml +class LibrsvgConan(ConanFile): + name = "librsvg" + description = "A library to render SVG images to Cairo surfaces" + license = "LGPL-2.1-or-later" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://wiki.gnome.org/Projects/LibRsvg" + topics = ("svg", "cairo") + package_type = "library" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "introspection": [True, False], + "docs": [True, False], + "vala": [True, False], + "tests": [True, False], + "pixbuf-loader": [True, False], + "triplet": [False, "ANY"], + "avif": [True, False], + "rustc_version": [False, "ANY"], + "with_gdk_pixbuf": [True, False], + "with_gidocgen": [True, False], + "with_introspection": [True, False], + "with_vapigen": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "introspection": False, + "docs": False, + "vala": False, + "tests": False, + "pixbuf-loader": False, + "triplet": False, + "avif": True, + "rustc_version": False, + "with_gdk_pixbuf": False, + "with_gidocgen": False, # currently not on conancenter + "with_introspection": False, + "with_vapigen": False, + } + + # no exports_sources attribute, but export_sources(self) method instead + # this allows finer grain exportation of patches per version + 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") + # for plain C projects only + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") + + def layout(self): + # src_folder must use the same source folder name the project + basic_layout(self, src_folder="src") + + def requirements(self): + # prefer self.requires method instead of requires attribute + self.requires("cairo/1.18.0") + self.requires("dav1d/1.3.0") + self.requires("freetype/2.13.2") + self.requires("glib/2.78.3") # I think this includes gio? + self.requires("harfbuzz/8.3.0") + self.requires("libxml2/2.12.6") + self.requires("pango/1.51.0") + + if self.options.with_gdk_pixbuf: + self.requires("gdk-pixbuf/2.42.10") + if self.options.with_gidocgen: + pass # self.requires("...") + if self.options.with_introspection: + self.requires("gobject-introspection/1.72.0") + if self.options.with_vapigen: + pass # self.requires("...") + + def validate(self): + if self.options.with_gidocgen: + raise ConanInvalidConfiguration("gidocgen recipe not available in conancenter yet") + if self.options.with_vapigen: + raise ConanInvalidConfiguration("vapigen recipe not available in conancenter yet") + + if is_msvc(self) and is_msvc_static_runtime(self) and not self.options.shared and \ + self.dependencies["glib"].options.shared: + raise ConanInvalidConfiguration( + f"{self.ref} static with MT runtime not supported if glib shared due to conancenter CI limitations" + ) + + # if another tool than the compiler or Meson is required to build the project (pkgconf, bison, flex etc) + def build_requirements(self): + # CCI policy assumes that Meson may not be installed on consumers machine + self.tool_requires("meson/[>1.2.0]") + # pkgconf is largely used by Meson, it should be added in build requirement when there are dependencies + if not self.conf.get("tools.gnu:pkg_config", default=False, check_type=str): + self.tool_requires("pkgconf/2.0.3") + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + # Meson feature options must be set to "enabled" or "disabled" + feature = lambda option: "enabled" if option else "disabled" + true_false = lambda option: True if option else False + + # default_library and b_staticpic are automatically parsed when self.options.shared and self.options.fpic exist + # buildtype is automatically parsed for self.settings + tc = MesonToolchain(self) + + # Meson features are typically enabled automatically when possible. + # The default behavior can be changed to disable all features by setting "auto_features" to "disabled". + # tc.project_options["auto_features"] = "disabled" + tc.project_options["introspection"] = feature(self.options.get_safe("introspection")) + tc.project_options["docs"] = feature(self.options.get_safe("docs")) + tc.project_options["vala"] = feature(self.options.get_safe("vala")) + tc.project_options["tests"] = true_false(self.options.get_safe("tests")) + tc.project_options["avif"] = feature(self.options.get_safe("avif")) + tc.project_options["pixbuf"] = feature(self.options.with_gdk_pixbuf) + tc.project_options["pixbuf-loader"] = feature(self.options.get_safe("pixbuf-loader")) + if self.options.get_safe("triplet"): + tc.project_options["triplet"] = self.options.get_safe("triplet") + if self.options.get_safe("rustc_version"): + tc.project_options["rustc-version"] = self.options.get_safe("rustc_version") + tc.generate() + + + tc = PkgConfigDeps(self) + tc.generate() + + tc = VirtualBuildEnv(self) + tc.generate() + + def _patch_sources(self): + apply_conandata_patches(self) + + def build(self): + self._patch_sources() + meson = Meson(self) + meson.configure() + meson.build() + + def package(self): + copy(self, "COPYING.LIB", self.source_folder, os.path.join(self.package_folder, "licenses")) + meson = Meson(self) + meson.install() + + # some files extensions and folders are not allowed. Please, read the FAQs to get informed. + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) + rm(self, "*.pdb", os.path.join(self.package_folder, "lib")) + rm(self, "*.pdb", os.path.join(self.package_folder, "bin")) + + # In shared lib/executable files, meson set install_name (macOS) to lib dir absolute path instead of @rpath, it's not relocatable, so fix it + fix_apple_shared_install_name(self) + + def package_info(self): + self.cpp_info.libs = ["librsvg"] + # if package provides a pkgconfig file (package.pc, usually installed in /lib/pkgconfig/) + self.cpp_info.set_property("pkg_config_name", "librsvg-2") + # If they are needed on Linux, m, pthread and dl are usually needed on FreeBSD too + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.extend(["m", "pthread", "dl"]) + + if self.options.with_gdk_pixbuf: + self.cpp_info.components["librsvg"].requires.append("gdk-pixbuf::gdk-pixbuf") + if self.options.with_gidocgen: + pass + if self.options.with_introspection: + pass # self.cpp_info.components["librsvg"].requires.append() + # unsure about this, package seems to be broken anyway + if self.options.with_vapigen: + pass diff --git a/recipes/librsvg/all/test_package/CMakeLists.txt b/recipes/librsvg/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..fc1038abcb385 --- /dev/null +++ b/recipes/librsvg/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(librsvg REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE librsvg::librsvg) \ No newline at end of file diff --git a/recipes/librsvg/all/test_package/conanfile.py b/recipes/librsvg/all/test_package/conanfile.py new file mode 100644 index 0000000000000..fc4f8c0404d08 --- /dev/null +++ b/recipes/librsvg/all/test_package/conanfile.py @@ -0,0 +1,27 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageLibrsvg(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + print(f"################################{self.tested_reference_str}#######################") + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(f"{bin_path}", env="conanrun") \ No newline at end of file diff --git a/recipes/librsvg/all/test_package/test_package.c b/recipes/librsvg/all/test_package/test_package.c new file mode 100644 index 0000000000000..ad761c3f07c93 --- /dev/null +++ b/recipes/librsvg/all/test_package/test_package.c @@ -0,0 +1,6 @@ +#include + +int main() { + rsvg_set_default_dpi (72.0); + return 0; +} \ No newline at end of file diff --git a/recipes/librsvg/config.yml b/recipes/librsvg/config.yml new file mode 100644 index 0000000000000..87f2d0e2ecbf8 --- /dev/null +++ b/recipes/librsvg/config.yml @@ -0,0 +1,3 @@ +versions: + "2.58.91": + folder: all From 284bac6df5192bb2b878c83c94ca1033c65c1c1a Mon Sep 17 00:00:00 2001 From: Julianiolo <50519317+Julianiolo@users.noreply.github.com> Date: Sun, 12 May 2024 23:16:25 +0200 Subject: [PATCH 2/9] tried more stuff --- recipes/librsvg/all/conanfile.py | 25 +++++++++++++++++-- .../librsvg/all/test_package/CMakeLists.txt | 8 +++--- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/recipes/librsvg/all/conanfile.py b/recipes/librsvg/all/conanfile.py index 2931cf2a71e79..31b4a11a7bb5f 100644 --- a/recipes/librsvg/all/conanfile.py +++ b/recipes/librsvg/all/conanfile.py @@ -175,13 +175,17 @@ def package(self): rm(self, "*.pdb", os.path.join(self.package_folder, "lib")) rm(self, "*.pdb", os.path.join(self.package_folder, "bin")) - # In shared lib/executable files, meson set install_name (macOS) to lib dir absolute path instead of @rpath, it's not relocatable, so fix it fix_apple_shared_install_name(self) + fix_msvc_libname(self) def package_info(self): + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("cmake_file_name", "librsvg") + self.cpp_info.set_property("cmake_target_name", "librsvg::librsvg") self.cpp_info.libs = ["librsvg"] + #self.cpp_info.components["librsvg"].libs = ["rsvg"] # if package provides a pkgconfig file (package.pc, usually installed in /lib/pkgconfig/) - self.cpp_info.set_property("pkg_config_name", "librsvg-2") + self.cpp_info.set_property("pkg_config_name", "librsvg-2.0") # If they are needed on Linux, m, pthread and dl are usually needed on FreeBSD too if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs.extend(["m", "pthread", "dl"]) @@ -195,3 +199,20 @@ def package_info(self): # unsure about this, package seems to be broken anyway if self.options.with_vapigen: pass + +# stolen from the libvips recipe +def fix_msvc_libname(conanfile, remove_lib_prefix=True): + """remove lib prefix & change extension to .lib in case of cl like compiler""" + from conan.tools.files import rename + import glob + if not conanfile.settings.get_safe("compiler.runtime"): + return + 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")) \ No newline at end of file diff --git a/recipes/librsvg/all/test_package/CMakeLists.txt b/recipes/librsvg/all/test_package/CMakeLists.txt index fc1038abcb385..33f9707ba62c5 100644 --- a/recipes/librsvg/all/test_package/CMakeLists.txt +++ b/recipes/librsvg/all/test_package/CMakeLists.txt @@ -1,7 +1,7 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package LANGUAGES C) +cmake_minimum_required(VERSION 3.15) +project(test_package) -find_package(librsvg REQUIRED CONFIG) +find_package(librsvg REQUIRED) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} PRIVATE librsvg::librsvg) \ No newline at end of file +target_link_libraries(${PROJECT_NAME} librsvg::librsvg) \ No newline at end of file From a72e38e77bbf9b0586ae4e02551a3fd532bc3899 Mon Sep 17 00:00:00 2001 From: Julianiolo <50519317+Julianiolo@users.noreply.github.com> Date: Mon, 13 May 2024 01:53:16 +0200 Subject: [PATCH 3/9] fixed cmake find error --- recipes/librsvg/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/librsvg/all/conanfile.py b/recipes/librsvg/all/conanfile.py index 31b4a11a7bb5f..7279042117521 100644 --- a/recipes/librsvg/all/conanfile.py +++ b/recipes/librsvg/all/conanfile.py @@ -182,7 +182,7 @@ def package_info(self): self.cpp_info.set_property("cmake_find_mode", "both") self.cpp_info.set_property("cmake_file_name", "librsvg") self.cpp_info.set_property("cmake_target_name", "librsvg::librsvg") - self.cpp_info.libs = ["librsvg"] + self.cpp_info.libs = ["rsvg-2"] #self.cpp_info.components["librsvg"].libs = ["rsvg"] # if package provides a pkgconfig file (package.pc, usually installed in /lib/pkgconfig/) self.cpp_info.set_property("pkg_config_name", "librsvg-2.0") From dd87a5a4e1133155e9a956cd2edf74fee7f6b439 Mon Sep 17 00:00:00 2001 From: Julianiolo <50519317+Julianiolo@users.noreply.github.com> Date: Mon, 13 May 2024 02:36:23 +0200 Subject: [PATCH 4/9] fixed include issue --- recipes/librsvg/all/conanfile.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/recipes/librsvg/all/conanfile.py b/recipes/librsvg/all/conanfile.py index 7279042117521..86f0c49ea50b8 100644 --- a/recipes/librsvg/all/conanfile.py +++ b/recipes/librsvg/all/conanfile.py @@ -112,7 +112,6 @@ def validate(self): f"{self.ref} static with MT runtime not supported if glib shared due to conancenter CI limitations" ) - # if another tool than the compiler or Meson is required to build the project (pkgconf, bison, flex etc) def build_requirements(self): # CCI policy assumes that Meson may not be installed on consumers machine self.tool_requires("meson/[>1.2.0]") @@ -183,6 +182,9 @@ def package_info(self): self.cpp_info.set_property("cmake_file_name", "librsvg") self.cpp_info.set_property("cmake_target_name", "librsvg::librsvg") self.cpp_info.libs = ["rsvg-2"] + self.cpp_info.includedirs += [ + os.path.join("include", "librsvg-2.0"), + ] #self.cpp_info.components["librsvg"].libs = ["rsvg"] # if package provides a pkgconfig file (package.pc, usually installed in /lib/pkgconfig/) self.cpp_info.set_property("pkg_config_name", "librsvg-2.0") From 96712c6fa7b5f7b9388de3d5919a24e9c55e42d7 Mon Sep 17 00:00:00 2001 From: Julianiolo <50519317+Julianiolo@users.noreply.github.com> Date: Mon, 13 May 2024 10:26:37 +0200 Subject: [PATCH 5/9] more changes --- recipes/librsvg/all/test_package/CMakeLists.txt | 4 ++-- recipes/librsvg/all/test_package/conanfile.py | 1 - recipes/librsvg/all/test_package/test_package.c | 2 ++ 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/recipes/librsvg/all/test_package/CMakeLists.txt b/recipes/librsvg/all/test_package/CMakeLists.txt index 33f9707ba62c5..5be67bd3d9ad5 100644 --- a/recipes/librsvg/all/test_package/CMakeLists.txt +++ b/recipes/librsvg/all/test_package/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.15) project(test_package) -find_package(librsvg REQUIRED) +find_package(librsvg REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} librsvg::librsvg) \ No newline at end of file +target_link_libraries(${PROJECT_NAME} PRIVATE librsvg::librsvg) \ No newline at end of file diff --git a/recipes/librsvg/all/test_package/conanfile.py b/recipes/librsvg/all/test_package/conanfile.py index fc4f8c0404d08..222b7b78766c3 100644 --- a/recipes/librsvg/all/test_package/conanfile.py +++ b/recipes/librsvg/all/test_package/conanfile.py @@ -13,7 +13,6 @@ def layout(self): cmake_layout(self) def requirements(self): - print(f"################################{self.tested_reference_str}#######################") self.requires(self.tested_reference_str) def build(self): diff --git a/recipes/librsvg/all/test_package/test_package.c b/recipes/librsvg/all/test_package/test_package.c index ad761c3f07c93..f95bf91ed59a8 100644 --- a/recipes/librsvg/all/test_package/test_package.c +++ b/recipes/librsvg/all/test_package/test_package.c @@ -1,3 +1,5 @@ +#include "zlib.h" +#include "glib-2.0/glib-object.h" #include int main() { From c5f109b558a57c2df47b74ce146d5974659898b0 Mon Sep 17 00:00:00 2001 From: Julianiolo Date: Mon, 13 May 2024 14:25:31 +0200 Subject: [PATCH 6/9] added reqs and fixed fileendings --- recipes/librsvg/all/conandata.yml | 2 +- recipes/librsvg/all/conanfile.py | 31 +++++++++++++++---- .../librsvg/all/test_package/CMakeLists.txt | 2 +- recipes/librsvg/all/test_package/conanfile.py | 2 +- .../librsvg/all/test_package/test_package.c | 2 -- 5 files changed, 28 insertions(+), 11 deletions(-) diff --git a/recipes/librsvg/all/conandata.yml b/recipes/librsvg/all/conandata.yml index 39c19a645e849..bbb5cba94c452 100644 --- a/recipes/librsvg/all/conandata.yml +++ b/recipes/librsvg/all/conandata.yml @@ -1,4 +1,4 @@ sources: "2.58.91": url: "https://download.gnome.org/sources/librsvg/2.58/librsvg-2.58.91.tar.xz" - sha256: "65846ae57c11aba288bf3a6fe517f800f7e38e7fbc79b98c99a8177634ed29f7" \ No newline at end of file + sha256: "65846ae57c11aba288bf3a6fe517f800f7e38e7fbc79b98c99a8177634ed29f7" diff --git a/recipes/librsvg/all/conanfile.py b/recipes/librsvg/all/conanfile.py index 86f0c49ea50b8..629997543594e 100644 --- a/recipes/librsvg/all/conanfile.py +++ b/recipes/librsvg/all/conanfile.py @@ -86,10 +86,11 @@ def requirements(self): self.requires("cairo/1.18.0") self.requires("dav1d/1.3.0") self.requires("freetype/2.13.2") - self.requires("glib/2.78.3") # I think this includes gio? + self.requires("glib/2.78.3") self.requires("harfbuzz/8.3.0") self.requires("libxml2/2.12.6") self.requires("pango/1.51.0") + self.requires("fontconfig/2.15.0") if self.options.with_gdk_pixbuf: self.requires("gdk-pixbuf/2.42.10") @@ -178,13 +179,31 @@ def package(self): fix_msvc_libname(self) def package_info(self): - self.cpp_info.set_property("cmake_find_mode", "both") - self.cpp_info.set_property("cmake_file_name", "librsvg") - self.cpp_info.set_property("cmake_target_name", "librsvg::librsvg") + #self.cpp_info.set_property("cmake_find_mode", "both") + #self.cpp_info.set_property("cmake_file_name", "librsvg") + #self.cpp_info.set_property("cmake_target_name", "librsvg::librsvg") self.cpp_info.libs = ["rsvg-2"] self.cpp_info.includedirs += [ os.path.join("include", "librsvg-2.0"), ] + + # https://gitlab.gnome.org/GNOME/librsvg/-/blob/2.57.0/configure.ac#L161-173 + self.cpp_info.requires = [ + "cairo::cairo_", + "cairo::cairo-png", + "cairo::cairo-gobject", + "fontconfig::fontconfig", + "freetype::freetype", + "glib::gio-2.0", + "glib::glib-2.0", + "glib::gobject-2.0", + "harfbuzz::harfbuzz", + "libxml2::libxml2", + "pango::pangocairo", + "pango::pangoft2", + "dav1d::dav1d", + ] + #self.cpp_info.components["librsvg"].libs = ["rsvg"] # if package provides a pkgconfig file (package.pc, usually installed in /lib/pkgconfig/) self.cpp_info.set_property("pkg_config_name", "librsvg-2.0") @@ -193,7 +212,7 @@ def package_info(self): self.cpp_info.system_libs.extend(["m", "pthread", "dl"]) if self.options.with_gdk_pixbuf: - self.cpp_info.components["librsvg"].requires.append("gdk-pixbuf::gdk-pixbuf") + self.cpp_info.requires += ["gdk-pixbuf::gdk-pixbuf"] if self.options.with_gidocgen: pass if self.options.with_introspection: @@ -217,4 +236,4 @@ def fix_msvc_libname(conanfile, remove_lib_prefix=True): 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")) \ No newline at end of file + rename(conanfile, filepath, os.path.join(os.path.dirname(filepath), f"{libname}.lib")) diff --git a/recipes/librsvg/all/test_package/CMakeLists.txt b/recipes/librsvg/all/test_package/CMakeLists.txt index 5be67bd3d9ad5..ede9534e93c2c 100644 --- a/recipes/librsvg/all/test_package/CMakeLists.txt +++ b/recipes/librsvg/all/test_package/CMakeLists.txt @@ -4,4 +4,4 @@ project(test_package) find_package(librsvg REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} PRIVATE librsvg::librsvg) \ No newline at end of file +target_link_libraries(${PROJECT_NAME} PRIVATE librsvg::librsvg) diff --git a/recipes/librsvg/all/test_package/conanfile.py b/recipes/librsvg/all/test_package/conanfile.py index 222b7b78766c3..fab83972e6b44 100644 --- a/recipes/librsvg/all/test_package/conanfile.py +++ b/recipes/librsvg/all/test_package/conanfile.py @@ -23,4 +23,4 @@ def build(self): def test(self): if can_run(self): bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") - self.run(f"{bin_path}", env="conanrun") \ No newline at end of file + self.run(f"{bin_path}", env="conanrun") diff --git a/recipes/librsvg/all/test_package/test_package.c b/recipes/librsvg/all/test_package/test_package.c index f95bf91ed59a8..ad761c3f07c93 100644 --- a/recipes/librsvg/all/test_package/test_package.c +++ b/recipes/librsvg/all/test_package/test_package.c @@ -1,5 +1,3 @@ -#include "zlib.h" -#include "glib-2.0/glib-object.h" #include int main() { From 43ed68d57f4aa32795b921661277a1c9c7b9ab1c Mon Sep 17 00:00:00 2001 From: Julianiolo Date: Mon, 13 May 2024 16:29:46 +0200 Subject: [PATCH 7/9] fixed everything!? --- recipes/librsvg/all/conanfile.py | 20 +++++++------------ .../librsvg/all/test_package/test_package.c | 2 +- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/recipes/librsvg/all/conanfile.py b/recipes/librsvg/all/conanfile.py index 629997543594e..7b2aefae6dfed 100644 --- a/recipes/librsvg/all/conanfile.py +++ b/recipes/librsvg/all/conanfile.py @@ -79,21 +79,21 @@ def configure(self): def layout(self): # src_folder must use the same source folder name the project - basic_layout(self, src_folder="src") + basic_layout(self, src_folder="rsvg") def requirements(self): # prefer self.requires method instead of requires attribute - self.requires("cairo/1.18.0") + self.requires("cairo/1.18.0", transitive_headers=True, transitive_libs=True) self.requires("dav1d/1.3.0") self.requires("freetype/2.13.2") - self.requires("glib/2.78.3") + self.requires("glib/2.78.3", transitive_headers=True, transitive_libs=True) self.requires("harfbuzz/8.3.0") self.requires("libxml2/2.12.6") self.requires("pango/1.51.0") self.requires("fontconfig/2.15.0") if self.options.with_gdk_pixbuf: - self.requires("gdk-pixbuf/2.42.10") + self.requires("gdk-pixbuf/2.42.10", transitive_headers=True, transitive_libs=True) if self.options.with_gidocgen: pass # self.requires("...") if self.options.with_introspection: @@ -114,27 +114,20 @@ def validate(self): ) def build_requirements(self): - # CCI policy assumes that Meson may not be installed on consumers machine self.tool_requires("meson/[>1.2.0]") - # pkgconf is largely used by Meson, it should be added in build requirement when there are dependencies if not self.conf.get("tools.gnu:pkg_config", default=False, check_type=str): self.tool_requires("pkgconf/2.0.3") + # TODO add rustc def source(self): get(self, **self.conan_data["sources"][self.version], strip_root=True) def generate(self): - # Meson feature options must be set to "enabled" or "disabled" feature = lambda option: "enabled" if option else "disabled" true_false = lambda option: True if option else False - # default_library and b_staticpic are automatically parsed when self.options.shared and self.options.fpic exist - # buildtype is automatically parsed for self.settings tc = MesonToolchain(self) - # Meson features are typically enabled automatically when possible. - # The default behavior can be changed to disable all features by setting "auto_features" to "disabled". - # tc.project_options["auto_features"] = "disabled" tc.project_options["introspection"] = feature(self.options.get_safe("introspection")) tc.project_options["docs"] = feature(self.options.get_safe("docs")) tc.project_options["vala"] = feature(self.options.get_safe("vala")) @@ -187,7 +180,6 @@ def package_info(self): os.path.join("include", "librsvg-2.0"), ] - # https://gitlab.gnome.org/GNOME/librsvg/-/blob/2.57.0/configure.ac#L161-173 self.cpp_info.requires = [ "cairo::cairo_", "cairo::cairo-png", @@ -210,6 +202,8 @@ def package_info(self): # If they are needed on Linux, m, pthread and dl are usually needed on FreeBSD too if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs.extend(["m", "pthread", "dl"]) + if is_msvc(self): + self.cpp_info.system_libs += ["ntdll", "userenv.lib"] if self.options.with_gdk_pixbuf: self.cpp_info.requires += ["gdk-pixbuf::gdk-pixbuf"] diff --git a/recipes/librsvg/all/test_package/test_package.c b/recipes/librsvg/all/test_package/test_package.c index ad761c3f07c93..d67889302ec93 100644 --- a/recipes/librsvg/all/test_package/test_package.c +++ b/recipes/librsvg/all/test_package/test_package.c @@ -3,4 +3,4 @@ int main() { rsvg_set_default_dpi (72.0); return 0; -} \ No newline at end of file +} From a7a451c68154da0d4870cf124124b8d5e1c0f5f0 Mon Sep 17 00:00:00 2001 From: Julianiolo Date: Tue, 14 May 2024 10:23:05 +0200 Subject: [PATCH 8/9] removed comments --- recipes/librsvg/all/conanfile.py | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/recipes/librsvg/all/conanfile.py b/recipes/librsvg/all/conanfile.py index 7b2aefae6dfed..3f83f742c44e6 100644 --- a/recipes/librsvg/all/conanfile.py +++ b/recipes/librsvg/all/conanfile.py @@ -1,23 +1,17 @@ from conan import ConanFile from conan.errors import ConanInvalidConfiguration from conan.tools.apple import fix_apple_shared_install_name -from conan.tools.build import check_min_cppstd from conan.tools.env import VirtualBuildEnv -from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, replace_in_file, rm, rmdir +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rm, rmdir from conan.tools.gnu import PkgConfigDeps from conan.tools.layout import basic_layout from conan.tools.meson import Meson, MesonToolchain from conan.tools.microsoft import is_msvc, is_msvc_static_runtime -from conan.tools.scm import Version import os required_conan_version = ">=1.53.0" -# -# INFO: Please, remove all comments before pushing your PR! -# - # some information taken from https://gitlab.gnome.org/GNOME/librsvg/-/blob/main/Cargo.toml class LibrsvgConan(ConanFile): name = "librsvg" @@ -61,8 +55,6 @@ class LibrsvgConan(ConanFile): "with_vapigen": False, } - # no exports_sources attribute, but export_sources(self) method instead - # this allows finer grain exportation of patches per version def export_sources(self): export_conandata_patches(self) @@ -73,16 +65,13 @@ def config_options(self): def configure(self): if self.options.shared: self.options.rm_safe("fPIC") - # for plain C projects only self.settings.rm_safe("compiler.cppstd") self.settings.rm_safe("compiler.libcxx") def layout(self): - # src_folder must use the same source folder name the project basic_layout(self, src_folder="rsvg") def requirements(self): - # prefer self.requires method instead of requires attribute self.requires("cairo/1.18.0", transitive_headers=True, transitive_libs=True) self.requires("dav1d/1.3.0") self.requires("freetype/2.13.2") @@ -162,7 +151,6 @@ def package(self): meson = Meson(self) meson.install() - # some files extensions and folders are not allowed. Please, read the FAQs to get informed. rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) rmdir(self, os.path.join(self.package_folder, "share")) rm(self, "*.pdb", os.path.join(self.package_folder, "lib")) @@ -172,9 +160,6 @@ def package(self): fix_msvc_libname(self) def package_info(self): - #self.cpp_info.set_property("cmake_find_mode", "both") - #self.cpp_info.set_property("cmake_file_name", "librsvg") - #self.cpp_info.set_property("cmake_target_name", "librsvg::librsvg") self.cpp_info.libs = ["rsvg-2"] self.cpp_info.includedirs += [ os.path.join("include", "librsvg-2.0"), @@ -196,24 +181,24 @@ def package_info(self): "dav1d::dav1d", ] - #self.cpp_info.components["librsvg"].libs = ["rsvg"] - # if package provides a pkgconfig file (package.pc, usually installed in /lib/pkgconfig/) self.cpp_info.set_property("pkg_config_name", "librsvg-2.0") - # If they are needed on Linux, m, pthread and dl are usually needed on FreeBSD too + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs.extend(["m", "pthread", "dl"]) + + # this is a somewhat temporary fix for rust, should probably be handled by a rust recipe if is_msvc(self): self.cpp_info.system_libs += ["ntdll", "userenv.lib"] if self.options.with_gdk_pixbuf: self.cpp_info.requires += ["gdk-pixbuf::gdk-pixbuf"] if self.options.with_gidocgen: - pass + pass # currently not present on conan-center if self.options.with_introspection: - pass # self.cpp_info.components["librsvg"].requires.append() + pass # self.cpp_info.requires.append() # unsure about this, package seems to be broken anyway if self.options.with_vapigen: - pass + pass # currently not present on conan-center # stolen from the libvips recipe def fix_msvc_libname(conanfile, remove_lib_prefix=True): From b80d7505c24bff483d74ff314821ef545849c812 Mon Sep 17 00:00:00 2001 From: Julianiolo Date: Tue, 14 May 2024 10:28:05 +0200 Subject: [PATCH 9/9] changed src_folder back to src --- recipes/librsvg/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/librsvg/all/conanfile.py b/recipes/librsvg/all/conanfile.py index 3f83f742c44e6..2155734745acd 100644 --- a/recipes/librsvg/all/conanfile.py +++ b/recipes/librsvg/all/conanfile.py @@ -69,7 +69,7 @@ def configure(self): self.settings.rm_safe("compiler.libcxx") def layout(self): - basic_layout(self, src_folder="rsvg") + basic_layout(self, src_folder="src") def requirements(self): self.requires("cairo/1.18.0", transitive_headers=True, transitive_libs=True)