Bug fix: rotate plugin
[geeqie.git] / meson.build
index 7838bd5..fbe227e 100644 (file)
@@ -26,7 +26,7 @@
 # gq_bindir     /usr/local/lib/geeqie               *   plugins scripts
 # datadir       /usr/local/share/
 #               /usr/local/share/applications           org.geeqie.Geeqie.desktop
-# [gq_]appdir   /usr/local/share/geeqie/            *   template.desktop
+# [gq_]appdir   /usr/local/share/geeqie/            *   org,geeqie.template.desktop
 # desktopdir    /usr/local/share/geeqie/applications    plugin desktop files
 # appdatadir    /usr/local/share/metainfo               org.geeqie.Geeqie.appdata.xml
 # icondir       /usr/local/share/pixmaps                geeqie.png icon
@@ -34,6 +34,7 @@
 # [gq_]htmldir  /usr/local/share/doc/geeqie/html    *   help files
 # gq_localedir  /usr/locale/share/locale
 # mandir1       /usr/local/share/man/man1               man page
+# completionsdir /usr/local/share/bash-completion/completions bash command line completions
 # podir         project_root/po
 
 # * See meson_options.txt file
@@ -134,7 +135,7 @@ helpdir = join_paths(prefix, gq_helpdir)
 htmldir = join_paths(prefix, gq_htmldir)
 icondir = join_paths(datadir, 'pixmaps')
 mandir1 = join_paths(datadir, 'man', 'man1')
-
+completionsdir = join_paths(datadir, 'bash-completion', 'completions')
 podir = join_paths(meson.project_source_root(), 'po')
 scriptsdir = join_paths(meson.project_source_root(), 'scripts')
 
@@ -147,9 +148,9 @@ summary({'gq_appdir': gq_appdir,
 
 # Create the define constants used in the sources. Set via config.h.in
 conf_data = configuration_data()
-conf_data.set_quoted('VERSION', meson.project_version())
 conf_data.set('DEBUG', debug)
 
+conf_data.set('HAVE_GTK4', 0)
 option = get_option('gtk4')
 if option.enabled()
     gtk_dep = dependency('gtk4', required: true)
@@ -160,6 +161,7 @@ endif
 glib_dep = dependency('glib-2.0', version : '>=2.52', required: true)
 
 # Required only when backward-cpp is used
+conf_data.set('HAVE_DEVELOPER', 0)
 libdw_dep = []
 libunwind_dep = []
 option = get_option('devel')
@@ -181,6 +183,7 @@ else
 endif
 
 # Required only for seg. fault stacktrace and backtrace debugging
+conf_data.set('HAVE_EXECINFO_H', 0)
 option = get_option('execinfo')
 libexecinfo_dep = []
 if not option.disabled()
@@ -197,6 +200,14 @@ else
     summary({'execinfo' : ['stacktrace supported:', false]}, section : 'Debugging', bool_yn : true)
 endif
 
+conf_data.set('ENABLE_UNIT_TESTS', 0)
+option = get_option('unit_tests')
+if not option.disabled()
+    conf_data.set('ENABLE_UNIT_TESTS', 1)
+    # Summary is handled below, where the test() itself is defined.
+endif
+
+conf_data.set('HAVE_ARCHIVE', 0)
 libarchive_dep = []
 req_version = '>=3.4.0'
 option = get_option('archive')
@@ -212,6 +223,8 @@ else
     summary({'archive' : ['disabled - archive files e.g. .zip supported:', false]}, section : 'Configuration', bool_yn : true)
 endif
 
+conf_data.set('HAVE_LCMS', 0)
+conf_data.set('HAVE_LCMS2', 0)
 lcms_dep = []
 req_version = '>=2.0'
 option = get_option('cms')
@@ -233,6 +246,7 @@ else
     summary({'cms' : ['disabled - color management supported:', false]}, section : 'Configuration', bool_yn : true)
 endif
 
+conf_data.set('HAVE_DJVU', 0)
 ddjvuapi_dep = []
 req_version = '>=2.5.27'
 option = get_option('djvu')
@@ -261,6 +275,7 @@ else
 endif
 
 # Required only for seg. fault stacktrace and backtrace debugging
+conf_data.set('HAVE_EXECINFO_H', 0)
 option = get_option('execinfo')
 if not option.disabled()
     result = cc.check_header('execinfo.h')
@@ -274,8 +289,9 @@ else
     summary({'execinfo' : ['stacktrace supported:', false]}, section : 'Configuration', bool_yn : true)
 endif
 
+conf_data.set('HAVE_EXIV2', 0)
 exiv2_dep = []
-req_version = '>=0.11'
+req_version = '>=0.18'
 option = get_option('exiv2')
 if not option.disabled()
     exiv2_dep = dependency('exiv2', version : req_version, required : get_option('exiv2'))
@@ -289,6 +305,9 @@ else
     summary({'exiv2' : ['disabled - image data processed by exiv2:', false]}, section : 'Configuration', bool_yn : true)
 endif
 
+conf_data.set('HAVE_CLUTTER', 0)
+conf_data.set('HAVE_LIBCHAMPLAIN', 0)
+conf_data.set('HAVE_LIBCHAMPLAIN_GTK', 0)
 champlain_dep = []
 champlain_gtk_dep = []
 clutter_dep = []
@@ -329,6 +348,7 @@ else
     summary({'gps-map' : ['disabled - GPS map displayed:', false]}, section : 'Configuration', bool_yn : true)
 endif
 
+conf_data.set('HAVE_HEIF', 0)
 libheif_dep = []
 req_version = '>=1.3.2'
 option = get_option('heif')
@@ -344,6 +364,7 @@ else
     summary({'heif' : ['disabled - heif files supported:', false]}, section : 'Configuration', bool_yn : true)
 endif
 
+conf_data.set('HAVE_J2K', 0)
 libopenjp2_dep = []
 req_version = '>=2.3.0'
 option = get_option('j2k')
@@ -359,10 +380,11 @@ else
     summary({'j2k' : ['disabled - j2k files supported:', false]}, section : 'Configuration', bool_yn : true)
 endif
 
+conf_data.set('HAVE_JPEG', 0)
 libjpeg_dep = []
 option = get_option('jpeg')
 if not option.disabled()
-libjpeg_dep = dependency('libjpeg', required : get_option('jpeg'))
+    libjpeg_dep = dependency('libjpeg', required : get_option('jpeg'))
     if libjpeg_dep.found()
         if cc.has_function('jpeg_destroy_decompress', dependencies : libjpeg_dep)
             conf_data.set('HAVE_JPEG', 1)
@@ -377,6 +399,7 @@ else
     summary({'jpeg' : ['disabled - jpeg files supported:', false]}, section : 'Configuration', bool_yn : true)
 endif
 
+conf_data.set('HAVE_JPEGXL', 0)
 libjxl_dep = []
 req_version = '>=0.3.7'
 option = get_option('jpegxl')
@@ -392,6 +415,7 @@ else
     summary({'jpegxl' : ['disabled - jpegxl files supported:', false]}, section : 'Configuration', bool_yn : true)
 endif
 
+conf_data.set('HAVE_RAW', 0)
 libraw_dep = []
 req_version = '>=0.20'
 option = get_option('libraw')
@@ -407,6 +431,7 @@ else
     summary({'libraw' : ['disabled - .cr3 files supported:', false]}, section : 'Configuration', bool_yn : true)
 endif
 
+conf_data.set('HAVE_LUA', 0)
 lua_dep = []
 req_version = '>=5.3'
 option = get_option('lua')
@@ -444,6 +469,7 @@ else
 endif
 install_data('README.md', 'COPYING', 'TODO', install_dir : helpdir)
 
+conf_data.set('HAVE_PDF', 0)
 poppler_glib_dep = []
 req_version = '>=0.62'
 option = get_option('pdf')
@@ -459,6 +485,7 @@ else
     summary({'pdf' : ['disabled - pdf files supported:', false]}, section : 'Configuration', bool_yn : true)
 endif
 
+conf_data.set('HAVE_SPELL', 0)
 gspell_dep = []
 req_version = '>=1.6'
 option = get_option('spell')
@@ -474,14 +501,7 @@ else
     summary({'spell' : ['disabled - spelling checks enabled', false]}, section : 'Configuration', bool_yn : true)
 endif
 
-# Check for subproject handling
-option = get_option('subprojects')
-if option
-    summary({'subprojects' : ['subprojects enabled:', true]}, section : 'Configuration', bool_yn : true)
-else
-    summary({'subprojects' : ['subprojects enabled:', false]}, section : 'Configuration', bool_yn : true)
-endif
-
+conf_data.set('HAVE_TIFF', 0)
 tiff_dep = []
 option = get_option('tiff')
 if not option.disabled()
@@ -500,6 +520,10 @@ else
     summary({'tiff' : ['disabled - tiff files supported:', false]}, section : 'Configuration', bool_yn : true)
 endif
 
+conf_data.set('HAVE_FFMPEGTHUMBNAILER', 0)
+conf_data.set('HAVE_FFMPEGTHUMBNAILER_METADATA', 0)
+conf_data.set('HAVE_FFMPEGTHUMBNAILER_RGB', 0)
+conf_data.set('HAVE_FFMPEGTHUMBNAILER_WH', 0)
 libffmpegthumbnailer_dep = []
 req_version = '>=2.1.0'
 option = get_option('videothumbnailer')
@@ -536,56 +560,24 @@ else
     summary({'videothumbnailer' : ['disabled -thumbnails of video files supported', false]}, section : 'Configuration', bool_yn : true)
 endif
 
-webp_pixbuf_loader_version = '0.0'
-webp_pixbuf_loader_subproject = 'disabled'
-option = get_option('webp-pixbuf-loader')
+conf_data.set('HAVE_WEBP', 0)
+libwebp_dep = []
+req_version = '>=0.6.1'
+option = get_option('webp')
 if not option.disabled()
-    cmd = find_program('dpkg-query', required: false)
-    if cmd.found()
-        dpkg_res = run_command(cmd, '--show', 'webp-pixbuf-loader', check: false)
-
-        if dpkg_res.returncode() == 0
-            dpkg_list = dpkg_res.stdout().split()
-            webp_pixbuf_loader_version = dpkg_list.get(1)
-        endif
-
-        # Loader version 0.2.1 is OK. Versions 0.2.2 to 0.2.4 need patching via a subproject
-        # In that case if subprojects are disabled the loader is indicated as failing
-        # Anything later than 0.2.4 is assumed to be OK
-        if webp_pixbuf_loader_version.version_compare('==0.0')
-            summary({'webp_pixbuf_loader' : ['webp-pixbuf-loader not found - webp files supported:', false]}, section : 'Configuration', bool_yn : true)
-        else
-            message('webp-pixbuf-loader found: ' + webp_pixbuf_loader_version)
-            if webp_pixbuf_loader_version.version_compare('<0.2.2')
-                summary({'webp_pixbuf_loader' : ['webp files supported:', true]}, section : 'Configuration', bool_yn : true)
-                conf_data.set('HAVE_WEBP', 1)
-            elif webp_pixbuf_loader_version.version_compare('<=0.2.4')
-                if get_option('subprojects')
-                        webp_pixbuf_loader_proj = subproject('webp-pixbuf-loader')
-
-                        if webp_pixbuf_loader_proj.found()
-                            meson.add_install_script('./scripts/update-pixbuf-loaders-cache.sh')
-                            summary({'webp_pixbuf_loader' : ['webp files supported as subproject:', true]}, section : 'Configuration', bool_yn : true)
-                            conf_data.set('HAVE_WEBP', 1)
-                        else
-                            summary({'webp_pixbuf_loader' : ['webp subproject failed - webp files supported:', false]}, section : 'Configuration', bool_yn : true)
-                        endif
-                else
-                    summary({'webp_pixbuf_loader' : ['webp files supported:', false]}, section : 'Configuration', bool_yn : true)
-                endif
-            else
-                summary({'webp_pixbuf_loader' : ['webp files supported:', true]}, section : 'Configuration', bool_yn : true)
-                conf_data.set('HAVE_WEBP', 1)
-            endif
-        endif
+    libwebp_dep = dependency('libwebp', version : req_version, required : get_option('webp'))
+    if libwebp_dep.found()
+        conf_data.set('HAVE_WEBP', 1)
+        summary({'webp' : ['webp files supported:', true]}, section : 'Configuration', bool_yn : true)
     else
-        summary({'webp_pixbuf_loader' : ['dpkg not found - webp files supported:', false]}, section : 'Configuration', bool_yn : true)
+        summary({'webp' : ['libwebp ' + req_version + ' not found - webp files supported:', false]}, section : 'Configuration', bool_yn : true)
     endif
 else
-    summary({'webp_pixbuf_loader' : ['disabled - webp files supported:', false]}, section : 'Configuration', bool_yn : true)
+    summary({'webp' : ['disabled - webp files supported:', false]}, section : 'Configuration', bool_yn : true)
 endif
 
 # Check for nl_langinfo and _NL_TIME_FIRST_WEEKDAY
+conf_data.set('HAVE__NL_TIME_FIRST_WEEKDAY', 0)
 code = '''#include <langinfo.h>
 #include<stdio.h>
 int main (int argc, char ** argv) {
@@ -619,10 +611,6 @@ configure_file(input : 'config.h.in',
                encoding : 'UTF-8',
                configuration : conf_data)
 
-# For shellcheck on scripts
-script_sources = []
-subdir('scripts')
-
 # For gtk builder checks on .ui files
 ui_sources = []
 
@@ -630,12 +618,30 @@ ui_sources = []
 subdir('po')
 subdir('plugins')
 
+conditional_unit_test_deps = []
+if conf_data.get('ENABLE_UNIT_TESTS', 0) == 1
+    system_gtest_dep = dependency('gtest', main : false, required : false)
+    system_gmock_dep = dependency('gmock', required : false)
+    if system_gtest_dep.found() and system_gmock_dep.found()
+        conditional_unit_test_deps += system_gtest_dep
+        conditional_unit_test_deps += system_gmock_dep
+    else
+        # Use the subproject gtest as a fallback.
+        gtest_subproj = subproject('gtest')
+        conditional_unit_test_deps += gtest_subproj.get_variable('gtest_dep')
+        conditional_unit_test_deps += gtest_subproj.get_variable('gmock_dep')
+    endif
+endif
+
 # Generate the executable
 subdir('src')
 
 # Generate the help files
 subdir('doc')
 
+# Generate the command line auto-complete file
+subdir('auto-complete')
+
 # Install other project files
 if running_from_git
     cmd = [find_program('gen_changelog.sh'), meson.current_source_dir(), meson.current_build_dir()]
@@ -674,64 +680,22 @@ i18n.merge_file(
 
 configure_file(input: 'geeqie.spec.in', output: 'geeqie.spec', configuration: conf_data)
 
+isolate_test_sh = find_program('isolate-test.sh', dirs : scriptsdir, required : true)
+
 # Basic test of the executable
-# is_parallel false is to avoid problems with images tests
 xvfb = find_program('xvfb-run', required : false)
 if xvfb.found()
-    test('Basic test', xvfb, args: ['--auto-servernum', geeqie_exe, '--version'], is_parallel : false, timeout: 100)
+    test_cmd = [xvfb.full_path(), '--auto-servernum', geeqie_exe.full_path(), '--version']
+    test('Basic test', isolate_test_sh, args: test_cmd, timeout: 100, suite: 'functional')
     summary({'xvfb' : ['Test runs:', true]}, section : 'Testing', bool_yn : true)
 else
     summary({'xvfb' : ['Test runs:', false]}, section : 'Testing', bool_yn : true)
 endif
 
 # The tests are run on GitHub with all options disabled, and then
-# with all or most options enabled. Shellcheck and GtkBuilder need only
-# be run once when options are disabled. Use option archive as a flag.
 # Image tests use option devel as a flag so that normal users do not
 # download the test image database.
 
-# Shellcheck
-option = get_option('archive')
-if option.disabled()
-    shellcheck_exe = find_program('shellcheck', required : false)
-    script_sources += files('gen_changelog.sh',
-    'geeqie-install-debian.sh',
-    'version.sh')
-
-    if shellcheck_exe.found()
-        foreach script : script_sources
-            script_path = '@0@'.format(script)
-            test('Shellcheck_ ' + script_path, shellcheck_exe, args: ['--norc', '--shell=sh', '--enable=add-default-case,avoid-nullary-conditions,check-unassigned-uppercase,deprecate-which,quote-safe-variables', script], timeout: 100)
-        endforeach
-        summary({'shellcheck' : ['Test runs:', true]}, section : 'Testing', bool_yn : true)
-    else
-        summary({'shellcheck' : ['Test runs:', false]}, section : 'Testing', bool_yn : true)
-    endif
-else
-    summary({'shellcheck' : ['Test runs:', false]}, section : 'Testing', bool_yn : true)
-endif
-
-# GtkBuilder .ui check
-option = get_option('archive')
-if option.disabled()
-    if xvfb.found()
-        gtk_builder_tool = find_program('gtk-builder-tool', required : false)
-        if gtk_builder_tool.found()
-            foreach ui_file : ui_sources
-                ui_path = '@0@'.format(ui_file)
-                test('UI Build_ ' + ui_path, xvfb, args: ['--auto-servernum', gtk_builder_tool.full_path(), 'validate', ui_file], timeout: 100)
-            endforeach
-            summary({'gtk-builder-tool' : ['Test runs:', true]}, section : 'Testing', bool_yn : true)
-        else
-            summary({'gtk-builder-tool' : ['Test runs:', false]}, section : 'Testing', bool_yn : true)
-        endif
-    else
-        summary({'gtk-builder-tool xvfb' : ['Test runs:', false]}, section : 'Testing', bool_yn : true)
-    endif
-else
-    summary({'gtk-builder-tool xvfb' : ['Test runs:', false]}, section : 'Testing', bool_yn : true)
-endif
-
 # Image checks
 option = get_option('devel')
 if option.enabled()
@@ -747,15 +711,12 @@ if option.enabled()
         sources = sources_list.stdout().strip().split('\n')
 
         foreach image : sources
-            image_path = '@0@'.format(image)
-            path_array = image_path.split('/')
+            path_array = image.split('/')
             image_name = path_array[path_array.length() - 1]
 
-            if image_name.startswith('fail')
-                test('Image_ ' + image_name, image_test_sh, args: [geeqie_exe, image], is_parallel : false, should_fail : true, timeout: 100)
-            else
-                test('Image_ ' + image_name, image_test_sh, args: [geeqie_exe, image], is_parallel : false, timeout: 100)
-            endif
+            should_fail = image_name.startswith('fail')
+            test_cmd = [image_test_sh.full_path(), geeqie_exe.full_path(), image]
+            test('Image_ ' + image_name, isolate_test_sh, args: test_cmd, should_fail : should_fail, timeout: 100, suite: ['functional', 'image'])
         endforeach
         summary({'Image tests' : ['Test runs:', true]}, section : 'Testing', bool_yn : true)
     else
@@ -770,17 +731,13 @@ if running_from_git
     clang_tidy_exe = find_program('clang-tidy', required : false)
     if clang_tidy_exe.found()
         git_exe = find_program('git', required : true)
-        modified_file_list = run_command(git_exe, 'diff', '--name-only', check: true)
-        modified_files = modified_file_list.stdout().strip().split('\n')
 
-        foreach modified_file : modified_files
-            if modified_file.endswith('.cc')
-                modified_file_path = '@0@'.format(modified_file)
-                path_array = modified_file_path.split('/')
-                modified_file_name = path_array[path_array.length() - 1]
-                modified_file_full_path = join_paths(meson.project_source_root(), modified_file)
+        foreach source_file : main_sources + pan_view_sources + view_file_sources
+            if fs.name(source_file).endswith('.cc')
+                source_file_name = fs.name(source_file)
+                config_file = join_paths(meson.project_source_root(), '.clang-tidy')
 
-                test('Code Correctness_ ' + modified_file_name, clang_tidy_exe, args : ['-p', './build', '-quiet', modified_file_full_path], timeout : 100)
+                test('Code Correctness_ ' + source_file_name, clang_tidy_exe, args : ['-p', './build', '-quiet', '--config-file', config_file,  source_file], timeout : 100, suite : 'analysis')
             endif
         endforeach
 
@@ -792,13 +749,71 @@ else
     summary({'Code Correctness' : ['Test runs:', false]}, section : 'Testing', bool_yn : true)
 endif
 
+# Single value enum checks
+enum_check_sh = find_program('enum-check.sh', dirs : scriptsdir, required : true)
+if enum_check_sh.found()
+    foreach source_file : main_sources + pan_view_sources + view_file_sources
+        source_file_name = fs.name(source_file)
+        test('Single Value enum_ ' + source_file_name, enum_check_sh, args : [source_file], timeout : 100, suite : 'analysis')
+    endforeach
+
+    summary({'Single Value enum' : ['Test runs:', true]}, section : 'Testing', bool_yn : true)
+else
+    summary({'Single Value enum' : ['Test runs:', false]}, section : 'Testing', bool_yn : true)
+endif
+
+# Debug statement checks
+debug_check_sh = find_program('debug-check.sh', dirs : scriptsdir, required : true)
+if debug_check_sh.found()
+    foreach source_file : main_sources + pan_view_sources + view_file_sources
+        source_file_name = fs.name(source_file)
+        if (source_file_name != 'debug.h')
+            test('Debug Statements_ ' + source_file_name, debug_check_sh, args : [source_file], timeout : 100, suite : 'analysis')
+        endif
+    endforeach
+
+    summary({'Debug Statements' : ['Test runs:', true]}, section : 'Testing', bool_yn : true)
+else
+    summary({'Debug Statements' : ['Test runs:', false]}, section : 'Testing', bool_yn : true)
+endif
+
+# Temporary comments checks
+tmp_comments_check_sh = find_program('temporary-comments-check.sh', dirs : scriptsdir, required : true)
+if tmp_comments_check_sh.found()
+    foreach source_file : main_sources + pan_view_sources + view_file_sources
+        source_file_name = fs.name(source_file)
+        if (source_file_name != 'debug.h')
+            test('Temporary Comments_ ' + source_file_name, tmp_comments_check_sh, args : [source_file], timeout : 100, suite : 'analysis')
+        endif
+    endforeach
+
+    summary({'Temporary Comments' : ['Test runs:', true]}, section : 'Testing', bool_yn : true)
+else
+    summary({'Temporary Comments' : ['Test runs:', false]}, section : 'Testing', bool_yn : true)
+endif
+
+# Untranslated text checks
+untranslated_text_sh = find_program('untranslated-text.sh', dirs : scriptsdir, required : true)
+if untranslated_text_sh.found()
+        foreach source_file : main_sources + pan_view_sources + view_file_sources
+               if fs.name(source_file).endswith('.cc')
+                       source_file_name = fs.name(source_file)
+                       test('Untranslated Text_ ' + source_file_name, untranslated_text_sh, args : [source_file], timeout : 200, suite : 'analysis')
+               endif
+       endforeach
+
+       summary({'Untranslated Text' : ['Test runs:', true]}, section : 'Testing', bool_yn : true)
+else
+       summary({'Untranslated Text' : ['Test runs:', false]}, section : 'Testing', bool_yn : true)
+endif
+
 # Lua test
 option = get_option('lua')
 if not option.disabled()
     if lua_dep.found()
         if xvfb.found()
             lua_test_sh = find_program('lua-test.sh', dirs : scriptsdir, required : true)
-            test('Lua test', lua_test_sh, args: [geeqie_exe], is_parallel : false, timeout: 100)
+            test('Lua test', isolate_test_sh, args: [lua_test_sh.full_path(), geeqie_exe.full_path()], timeout: 100, suite : 'analysis')
 
             summary({'lua' : ['Test runs:', true]}, section : 'Testing', bool_yn : true)
         else
@@ -810,3 +825,17 @@ if not option.disabled()
 else
     summary({'lua' : ['Test runs:', false]}, section : 'Testing', bool_yn : true)
 endif
+
+# Ancillary files test
+test_ancillary_files_sh = find_program('test-ancillary-files.sh', dirs : scriptsdir, required : true)
+test('Ancillary files', test_ancillary_files_sh, args: [meson.current_source_dir()], timeout: 100, suite : 'analysis')
+
+summary({'Ancillary files' : ['Test runs:', true]}, section : 'Testing', bool_yn : true)
+
+# Unit tests
+if conf_data.get('ENABLE_UNIT_TESTS', 0) == 1
+    test('Unit tests', isolate_test_sh, args: [geeqie_exe.full_path(), '--run-unit-tests'], suite : 'unit')
+    summary({'unit_tests' : ['Tests run:', true]}, section : 'Testing', bool_yn : true)
+else
+    summary({'unit_tests' : ['Tests run:', false]}, section : 'Testing', bool_yn : true)
+endif