diff options
| author | Colomban Wendling <[email protected]> | 2025-11-06 14:41:43 +0100 |
|---|---|---|
| committer | Colomban Wendling <[email protected]> | 2025-11-06 14:41:43 +0100 |
| commit | f1a68c30ae822f82b3aad2e40c626e3260e8db2b (patch) | |
| tree | 2ea2dc0090bf5eae8b7b434b8158042987e7d62b | |
| parent | 216ac0dcf24cd20a35e81ac24031ccbe87f43ed2 (diff) | |
| download | atril-f1a68c30ae822f82b3aad2e40c626e3260e8db2b.tar.bz2 atril-f1a68c30ae822f82b3aad2e40c626e3260e8db2b.tar.xz | |
meson: Clean up tests for EPub
* Properly require WebKit for the EPub backend, instead of it being an
optional dependency.
* Merge EPub tests together to simplify things.
* Make MathJax optional, as it always has been. If missing, MathML will
likely not display properly, but it's probably not that big of a deal
as it's not the only use case for the EPub backend. If not found at
setup time, use the historical default as fallback, in case it gets
installed later.
Note that all this MathJax stuff is currently unused, because the code
has not been adjusted to make use of this check's results.
| -rw-r--r-- | libview/meson.build | 2 | ||||
| -rw-r--r-- | meson.build | 56 |
2 files changed, 31 insertions, 27 deletions
diff --git a/libview/meson.build b/libview/meson.build index 0f56f9c4..a8b7067d 100644 --- a/libview/meson.build +++ b/libview/meson.build @@ -80,7 +80,7 @@ libview_deps = [ math, ] -if not get_option('epub').disabled() +if webkit.found() libview_deps += webkit endif diff --git a/meson.build b/meson.build index b5c41123..8a02b91c 100644 --- a/meson.build +++ b/meson.build @@ -148,10 +148,38 @@ endif thumbnailer_mime_types = atril_mime_types # EPUB backend -if not get_option('epub').disabled() - webkit = dependency('webkit2gtk-4.1', version: '>= 2.4.3', required: false) +webkit = dependency('webkit2gtk-4.1', version: '>= 2.4.3', required: get_option('epub')) +if webkit.found() backend_subdirs += 'epub' atril_mime_types += 'application/epub+zip;' + + # MathJax configuration + mathjax_directory = get_option('mathjax-directory') + if mathjax_directory == '' + mathjax_directories = [ + '/usr/share/javascript/mathjax', + '/usr/share/mathjax' + ] + + fs = import('fs') + foreach dir: mathjax_directories + if fs.exists(join_paths(dir, 'MathJax.js')) + mathjax_directory = dir + break + endif + endforeach + + if mathjax_directory == '' + # default to the first directory, just in case, and because that's what + # we used to do in the code, which just means MathML might not work properly + mathjax_directory = mathjax_directories[0] + warning(('mathjax not found, using @0@ as fallback, but MathML might not work. ' + + 'Install mathjax or set "mathjax-directory" as needed.').format(mathjax_directory)) + endif + endif + + atril_conf.set10('ENABLE_EPUB', true) + atril_conf.set_quoted('MATHJAX_DIRECTORY', mathjax_directory) endif atril_conf.set_quoted('SUPPORTED_MIMETYPES', atril_mime_types) @@ -159,25 +187,6 @@ atril_conf.set_quoted('SUPPORTED_MIMETYPES', atril_mime_types) # Math library math = cc.find_library('m', required: false) -# MathJax configuration -mathjax_directory = get_option('mathjax-directory') -if mathjax_directory == '' - foreach dir: [ - '/usr/share/mathjax', - '/usr/share/javascript/mathjax' - ] - if run_command('test', ['-f', join_paths(dir, 'MathJax.js')], check: false).returncode() == 0 - mathjax_directory = dir - endif - endforeach -endif - -if mathjax_directory != '' - atril_conf.set_quoted('MATHJAX_DIRECTORY', mathjax_directory) -elif get_option('epub').enabled() - error('"mathjax-directory" is undefined and could not be autodetected') -endif - mate_submodules_dep = dependency('mate-submodules', version: '1.24.0', fallback: ['mate-submodules', 'mate_submodules_dep']) @@ -248,11 +257,6 @@ if get_option('enable_debug') cpp_args += '-DEV_ENABLE_DEBUG' endif -if not get_option('epub').disabled() - c_args += '-DENABLE_EPUB' - cpp_args += '-DENABLE_EPUB' -endif - # Add compiler arguments add_project_arguments(c_args, language: 'c') add_project_arguments(cpp_args, language: 'cpp') |
