Skip to content
Myr

meson/nanosvg: add support for linking against system's nanosvg

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Nanosvg upstream is header only, and does not support/provide a library, neither shared nor static. However, most distributions still provide a nanosvg package with either a static library, or shared. Arch does the latter. So, let's support building against a system provided nanosvg library. The default is still to use bundled version, but this can be changed with -Dsystem-nanosvg=enabled when configuring the build tree. Closes #275

authored by Daniel Eklöf · committed by Daniel Eklöf · parent 84df019 · Browse files · 10 files+29 added−13 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

10 files+29 added−13 removed

  • other:+29 added−13 removed

10 files+29 added−13 removed

added:nanosvg/nanosvg.h+1 added
1#include <3rd-party/nanosvg/src/nanosvg.h>
added:nanosvg/nanosvgrast.h+1 added
1#include <3rd-party/nanosvg/src/nanosvgrast.h>
modified:application.h+1 added-1 removed
6 unmodified lines
7 #include <librsvg/rsvg.h>8#endif910#if defined(FUZZEL_ENABLE_SVG_NANOSVG)11 #include <nanosvg.h>11 #include <nanosvg/nanosvg.h>12#endif1314#include <fcft/fcft.h>15#include <tllist.h>
70 unmodified lines
modified:CHANGELOG.md+3 added
37 unmodified lines
38 environment variable.39* Rounded corners without cairo. With this, the **only** time cairo is40 needed is when you want to use the librsvg SVG backend. For nanosvg41 builds, there is no longer any need to link against cairo.42* Support for linking against a system provided nanosvg library. See43 the new `-Dsystem-nanosvg` meson option. Default's to `disabled`44 (i.e. use the bundled version).4546[344]: https://codeberg.org/dnkl/fuzzel/issues/3444748
680 unmodified lines
modified:icon.c+1 added-1 removed
18 unmodified lines
19 #include <librsvg/rsvg.h>20#endif2122#if defined(FUZZEL_ENABLE_SVG_NANOSVG)23 #include <nanosvg.h>23 #include <nanosvg/nanosvg.h>24#endif2526#include <tllist.h>27
751 unmodified lines
modified:meson_options.txt+2 added
1option('enable-cairo', type: 'feature', description: 'use cairo; required by the librsvg SVG icon backend')2option('png-backend', type: 'combo', choices: ['none', 'libpng'], value: 'libpng', description: 'enable support for PNG icons')3option('svg-backend', type: 'combo', choices: ['none', 'librsvg', 'nanosvg'], value: 'nanosvg', description: 'enables support for SVG icons (librsvg: also requires cairo, nanosvg: bundled)')4option('system-nanosvg', type: 'feature', value: 'disabled',5 description: 'use system\'s nanosvg instead of the bundled version')
modified:meson.build+16 added-7 removed
58 unmodified lines
59wayland_protocols = dependency('wayland-protocols', version: '>=1.32')60wayland_client = dependency('wayland-client')61wayland_cursor = dependency('wayland-cursor')62xkb = dependency('xkbcommon')63system_nanosvg = cc.find_library('nanosvg', required: get_option('system-nanosvg'))64system_nanosvgrast = cc.find_library('nanosvgrast', required: get_option('system-nanosvg'))6566tllist = dependency('tllist', version: '>=1.0.1', fallback: 'tllist')67fcft = dependency('fcft', version: ['>=3.0.0', '<4.0.0'], fallback: 'fcft')68
13 unmodified lines
82 nanosvg = declare_dependency()83 svg_backend = 'librsvg'84 add_project_arguments('-DFUZZEL_ENABLE_SVG_LIBRSVG=1', language: 'c')85elif get_option('svg-backend') == 'nanosvg'86 if system_nanosvg.found() and system_nanosvgrast.found()87 nanosvg = declare_dependency(88 dependencies: [system_nanosvg, system_nanosvgrast]89 )90 svg_backend = 'nanosvg (system)'84 librsvg = declare_dependency()85 nanosvg = declare_dependency(86 sources: ['nanosvg.c', '3rd-party/nanosvg/src/nanosvg.h',87 'nanosvgrast.c', '3rd-party/nanosvg/src/nanosvgrast.h'],88 include_directories: '3rd-party/nanosvg/src',89 dependencies: math)90 svg_backend = 'nanosvg'91 else92 nanosvg = declare_dependency(93 sources: ['nanosvg.c', '3rd-party/nanosvg/src/nanosvg.h',94 'nanosvgrast.c', '3rd-party/nanosvg/src/nanosvgrast.h'],95 include_directories: '.',96 dependencies: math)97 svg_backend = 'nanosvg (bundled)'98 endif99 add_project_arguments('-DFUZZEL_ENABLE_SVG_NANOSVG=1', language: 'c')100 librsvg = declare_dependency()101else102 svg_backend = 'none'103 librsvg = declare_dependency()104 nanosvg = declare_dependency()
99 unmodified lines
modified:nanosvg.c+1 added-1 removed
1 unmodified line
2#include <string.h>3#include <math.h>4#define NANOSVG_ALL_COLOR_KEYWORDS5#define NANOSVG_IMPLEMENTATION6#include <nanosvg.h>6#include <3rd-party/nanosvg/src//nanosvg.h>
modified:nanosvgrast.c+2 added-2 removed
1#include <stdlib.h>2#include <string.h>34#include <nanosvg.h>4#include <3rd-party/nanosvg/src/nanosvg.h>5#define NANOSVGRAST_IMPLEMENTATION6#include <nanosvgrast.h>6#include <3rd-party/nanosvg/src/nanosvgrast.h>
modified:render.c+1 added-1 removed
5 unmodified lines
67#include <fcft/fcft.h>89#if defined(FUZZEL_ENABLE_SVG_NANOSVG)10 #include <nanosvgrast.h>10 #include <nanosvg/nanosvgrast.h>11#endif1213#define LOG_MODULE "render"14#define LOG_ENABLE_DBG 0
861 unmodified lines