# -*- Mode: Python -*- vi:si:et:sw=4:sts=4:ts=4:syntax=python from pathlib import Path from cerbero.build.build import modify_environment class Recipe(recipe.Recipe): name = 'librsvg' version = '2.40.20' licenses = [License.LGPLv2Plus] deps = ['libcroco', 'gdk-pixbuf', 'pango', 'cairo'] stype = SourceType.TARBALL url = 'gnome://' tarball_checksum = 'cff4dd3c3b78bfe99d8fcfad3b8ba1eee3289a0823c0e118d78106be6b84c92b' configure_options = ' --disable-always-build-tests --disable-tools ' files_libs = ['librsvg-2'] files_bins = ['rsvg-convert'] licenses_bins = [License.GPLv2Plus] files_loader = ['lib/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-svg%(mext)s'] files_devel = ['include/librsvg-2.0/librsvg/*.h', 'lib/pkgconfig/librsvg-2.0.pc', 'lib/librsvg-2.a', 'lib/librsvg-2.la'] files_typelibs = ['Rsvg-2.0'] patches = ['librsvg/0001-build-Fix-enumtypes-on-MinGW-inside-MSYS-Windows.patch'] def prepare(self): if self.config.target_platform in [Platform.DARWIN, Platform.IOS]: self.configure_options += ' --disable-Bsymbolic' # Fails on cross-ios and cross-win32 if self.config.cross_compiling(): self.configure_options += ' --disable-pixbuf-loader' self.files_loader.clear() if self.config.platform != Platform.WINDOWS: # GTK3 support just builds rsvg-view-3, which is useless for Cerbero self.configure_options += ' --without-gtk3 ' self.autoreconf = True self.autoreconf_sh = 'mkdir -p m4 && autoreconf -fiv' self.patches += [ 'librsvg/option-enable-disable-gtk.patch', 'librsvg/0001-Use-ACLOCAL_FLAGS.patch', ] else: self.autoreconf = False if self.config.platform == Platform.WINDOWS: # MSYS2 does not add . to PATH, so we need to add this ourselves # so that our python3 wrapper script is found" self.prepend_env('PATH', self.make_dir, sep=os.pathsep) @modify_environment async def compile(self): # glib-mkenums has #!/usr/bin/env python3, which looks for `python3`, # but on Windows Python 3 is `python.exe`. Meson already handles this # for us, but Autotools can't. # NOTE: Remove this when the recipe is ported to Meson. if self.config.platform == Platform.WINDOWS: python3 = Path(self.build_dir) / 'python3' with python3.open('w') as f: f.write('#!/bin/sh\n"{}" "$@"'.format(self.config.python_exe)) shell.new_call(['chmod', '+x', str(python3)]) await super().compile()