meson.build
This file
Path
meson.build
286 lines · 9.2 KiB
Last changed by
Merge branch 'releases/1.15'Daniel Eklöfbefore adoptionfa178b8
History of this fileTake it
1project('fuzzel', 'c',2 version: '1.15.0',3 license: 'MIT',4 meson_version: '>=0.58.0',5 default_options: [6 'c_std=c18',7 'warning_level=1',8 'werror=true',9 'b_ndebug=if-release'])1011is_debug_build = get_option('buildtype').startswith('debug')12cc = meson.get_compiler('c')1314add_project_arguments(15 ['-D_GNU_SOURCE'] +16 (is_debug_build17 ? ['-D_DEBUG']18 : [cc.get_supported_arguments('-fno-asynchronous-unwind-tables')]),19 language: 'c',20)2122if cc.has_function('memfd_create',23 args: ['-D_GNU_SOURCE=200809L'],24 prefix: '#include <sys/mman.h>')25 add_project_arguments('-DMEMFD_CREATE', language: 'c')26endif2728# Compute the relative path used by compiler invocations.29source_root = meson.current_source_dir().split('/')30build_root = meson.global_build_root().split('/')31relative_dir_parts = []32i = 033in_prefix = true34foreach p : build_root35 if i >= source_root.length() or not in_prefix or p != source_root[i]36 in_prefix = false37 relative_dir_parts += '..'38 endif39 i += 140endforeach41i = 042in_prefix = true43foreach p : source_root44 if i >= build_root.length() or not in_prefix or build_root[i] != p45 in_prefix = false46 relative_dir_parts += p47 endif48 i += 149endforeach50relative_dir = join_paths(relative_dir_parts) + '/'5152if cc.has_argument('-fmacro-prefix-map=/foo=')53 add_project_arguments('-fmacro-prefix-map=@0@='.format(relative_dir), language: 'c')54endif5556math = cc.find_library('m')57threads = [dependency('threads'), cc.find_library('stdthreads', required: false)]58fontconfig = dependency('fontconfig')59pixman = dependency('pixman-1', version: '>=0.46.0')60# Cairo is required for librsvg but not for resvg/nanosvg61if get_option('svg-backend') == 'resvg' or get_option('svg-backend') == 'nanosvg'62 # For resvg/nanosvg, cairo is optional and disabled by default63 if get_option('enable-cairo').auto()64 cairo = dependency('cairo', required: false)65 else66 cairo = dependency('cairo', required: get_option('enable-cairo'))67 endif68else69 # For librsvg or no SVG backend, respect the enable-cairo option70 cairo = dependency('cairo', required: get_option('enable-cairo'))71endif72libepoll = dependency('epoll-shim', required: false)73wayland_protocols = dependency('wayland-protocols', version: '>=1.41')74wayland_client = dependency('wayland-client')75wayland_cursor = dependency('wayland-cursor')76xkb = dependency('xkbcommon')77system_nanosvg = cc.find_library('nanosvg', required: get_option('system-nanosvg'))78system_nanosvgrast = cc.find_library('nanosvgrast', required: get_option('system-nanosvg'))7980tllist = dependency('tllist', version: '>=1.0.1', fallback: 'tllist')81fcft = dependency('fcft', version: ['>=3.3.1', '<4.0.0'], fallback: 'fcft')8283if cairo.found()84 add_project_arguments('-DFUZZEL_ENABLE_CAIRO=1', language: 'c')85endif8687if get_option('png-backend') == 'libpng'88 libpng = dependency('libpng')89 add_project_arguments('-DFUZZEL_ENABLE_PNG_LIBPNG=1', language: 'c')90else91 libpng = declare_dependency()92endif9394if cairo.found() and get_option('svg-backend') == 'librsvg'95 librsvg = dependency('librsvg-2.0')96 nanosvg = declare_dependency()97 resvg = declare_dependency()98 svg_backend = 'librsvg'99 add_project_arguments('-DFUZZEL_ENABLE_SVG_LIBRSVG=1', language: 'c')100elif get_option('svg-backend') == 'nanosvg'101 if system_nanosvg.found() and system_nanosvgrast.found()102 nanosvg = declare_dependency(103 dependencies: [system_nanosvg, system_nanosvgrast]104 )105 svg_backend = 'nanosvg (system)'106 else107 nanosvg = declare_dependency(108 sources: ['nanosvg.c', '3rd-party/nanosvg/src/nanosvg.h',109 'nanosvgrast.c', '3rd-party/nanosvg/src/nanosvgrast.h'],110 include_directories: '.',111 dependencies: math)112 svg_backend = 'nanosvg (bundled)'113 endif114 add_project_arguments('-DFUZZEL_ENABLE_SVG_NANOSVG=1', language: 'c')115 librsvg = declare_dependency()116 resvg = declare_dependency()117elif get_option('svg-backend') == 'resvg'118 resvg_pc = dependency('resvg', required: false)119 if resvg_pc.found()120 resvg = resvg_pc121 svg_backend = 'resvg'122 add_project_arguments('-DFUZZEL_ENABLE_SVG_RESVG=1', language: 'c')123 else124 # earlier versions of resvg doesn't provide pkg-config, so we need125 # to find it manually126 resvg = cc.find_library('resvg', required: true)127 if cc.has_header('resvg.h')128 svg_backend = 'resvg'129 add_project_arguments('-DFUZZEL_ENABLE_SVG_RESVG=1', language: 'c')130 else131 error('resvg.h not found. Please install resvg development files.')132 endif133 endif134 librsvg = declare_dependency()135 nanosvg = declare_dependency()136else137 svg_backend = 'none'138 librsvg = declare_dependency()139 nanosvg = declare_dependency()140 resvg = declare_dependency()141endif142143wayland_protocols_datadir = wayland_protocols.get_variable('pkgdatadir')144145wscanner = dependency('wayland-scanner', native: true)146wscanner_prog = find_program(147 wscanner.get_variable('wayland_scanner'), native: true)148149wl_proto_headers = []150wl_proto_src = []151152wl_proto_xml = [153 'external/wlr-layer-shell-unstable-v1.xml',154 wayland_protocols_datadir + '/stable/xdg-shell/xdg-shell.xml',155 wayland_protocols_datadir + '/unstable/xdg-output/xdg-output-unstable-v1.xml',156 wayland_protocols_datadir + '/staging/xdg-activation/xdg-activation-v1.xml',157 wayland_protocols_datadir + '/staging/cursor-shape/cursor-shape-v1.xml',158 wayland_protocols_datadir + '/unstable/tablet/tablet-unstable-v2.xml',159 wayland_protocols_datadir + '/stable/viewporter/viewporter.xml',160 wayland_protocols_datadir + '/staging/fractional-scale/fractional-scale-v1.xml',161 wayland_protocols_datadir / 'unstable/primary-selection/primary-selection-unstable-v1.xml',162 wayland_protocols_datadir / 'staging/color-management/color-management-v1.xml',163 wayland_protocols_datadir / 'staging/single-pixel-buffer/single-pixel-buffer-v1.xml',164 wayland_protocols_datadir / 'unstable/text-input/text-input-unstable-v3.xml',165]166167foreach prot : wl_proto_xml168 wl_proto_headers += custom_target(169 prot.underscorify() + '-client-header',170 output: '@BASENAME@.h',171 input: prot,172 command: [wscanner_prog, 'client-header', '@INPUT@', '@OUTPUT@'])173174 wl_proto_src += custom_target(175 prot.underscorify() + '-private-code',176 output: '@BASENAME@.c',177 input: prot,178 command: [wscanner_prog, 'private-code', '@INPUT@', '@OUTPUT@'])179endforeach180181env = find_program('env', native: true)182generate_version_sh = files('generate-version.sh')183version = custom_target(184 'generate_version',185 build_always_stale: true,186 output: 'version.h',187 command: [env, 'LC_ALL=C', generate_version_sh, meson.project_version(), '@CURRENT_SOURCE_DIR@', '@OUTPUT@'])188189python = find_program('python3', native: true)190generate_srgb_funcs = files('srgb.py')191srgb_funcs = custom_target(192 'generate_srgb_funcs',193 output: ['srgb.c', 'srgb.h'],194 command: [python, generate_srgb_funcs, '@OUTPUT0@', '@OUTPUT1@']195)196197fuzzel = executable(198 'fuzzel',199 'application.c', 'application.h',200 'char32.c', 'char32.h',201 'clipboard.c', 'clipboard.h',202 'column.c', 'column.h',203 'config.c', 'config.h',204 'debug.c', 'debug.h',205 'dmenu.c', 'dmenu.h',206 'event.c', 'event.h',207 'fdm.c', 'fdm.h',208 'icon.c', 'icon.h',209 'key-binding.c', 'key-binding.h',210 'log.c', 'log.h',211 'macros.h',212 'main.c',213 'match.c', 'match.h',214 'path.c', 'path.h',215 'png.c', 'png-fuzzel.h',216 'prompt.c', 'prompt.h',217 'render.c', 'render.h',218 'shm.c', 'shm.h',219 'stride.h',220 'uri.c', 'uri.h',221 'wayland.c', 'wayland.h',222 'xdg.c', 'xdg.h',223 'xmalloc.c', 'xmalloc.h',224 'xsnprintf.c', 'xsnprintf.h',225 'timing.c', 'timing.h',226 wl_proto_src + wl_proto_headers, version, srgb_funcs,227 dependencies: [math,228 threads,229 pixman,230 fontconfig,231 cairo,232 libepoll,233 libpng,234 librsvg,235 nanosvg,236 resvg,237 wayland_client,238 wayland_cursor,239 xkb,240 tllist,241 fcft],242 install: true)243244fish = find_program('fish', required: false)245wtype = find_program('wtype', required: false)246if fish.found() and wtype.found()247 if run_command(fish, '-c fishtape -v', check: false).returncode() == 0248 foreach test_case : [249 'accept-nth',250 'auto-select',251 'execute',252 'match-mode-fzf',253 'match-nth',254 ]255 test(test_case, fish,256 args: ['-c',257 'fishtape @0@/test/@1@.fish'.format(meson.current_source_dir(),258 test_case)],259 env: {'FUZZEL_TEST_BIN': fuzzel.full_path(),260 'MALLOC_PERTURB_': '0',261 'ASAN_OPTIONS': 'non-empty-invalid-value=0',262 'UBSAN_OPTIONS': 'non-empty-invalid-value=0',263 'MSAN_OPTIONS': 'non-empty-invalid-value=0'},264 is_parallel : false)265 endforeach266 endif267endif268269install_data(270 'fuzzel.ini',271 install_dir: join_paths(get_option('sysconfdir'), 'xdg', 'fuzzel'))272install_data(273 'LICENSE', 'README.md', 'CHANGELOG.md',274 install_dir: join_paths(get_option('datadir'), 'doc', 'fuzzel'))275276subdir('completions')277subdir('doc')278279summary(280 {281 'Cairo': cairo.found(),282 'PNG icons': get_option('png-backend'),283 'SVG icons': svg_backend,284 },285 bool_yn: true286)