diff --git a/gimp-data b/gimp-data index 4d84513963..500f16b4b4 160000 --- a/gimp-data +++ b/gimp-data @@ -1 +1 @@ -Subproject commit 4d84513963d43acf40965667a7beff449540fb73 +Subproject commit 500f16b4b4c7d62804a2617be34d74e11706e236 diff --git a/libgimp/tests/meson.build b/libgimp/tests/meson.build index e2fd3844a2..227e1b1d81 100644 --- a/libgimp/tests/meson.build +++ b/libgimp/tests/meson.build @@ -1,38 +1,23 @@ # XXX: we have a bunch of (manually run?) tests inside libgimp/test/. # These should either be deleted or transformed into real unit tests. +if not meson.can_run_host_binaries() + warning('libgimp unit testing disabled in cross-building or similar environments.') + subdir_done() +endif + tests = [ 'palette', ] -# make GIMP runnable without being installed. -env=environment() - -menu_paths=meson.project_build_root() / 'menus:' + meson.project_source_root() / 'menus' -env.set('GIMP_TESTING_MENUS_PATH', menu_paths) - -env.set('GIMP_TESTING_PLUGINDIRS', meson.project_build_root() / 'plug-ins:') -env.append('GIMP_TESTING_PLUGINDIRS', meson.project_build_root() / 'plug-ins/python') -env.append('GIMP_TESTING_PLUGINDIRS', meson.project_build_root() / 'plug-ins/common/test-plug-ins/') -env.append('GIMP_TESTING_PLUGINDIRS', meson.project_build_root() / 'libgimp/tests/c-tests/') - -env.prepend('GI_TYPELIB_PATH', meson.project_build_root() / 'libgimp') -env.prepend('LD_LIBRARY_PATH', meson.project_build_root() / 'libgimp') -env.prepend('LD_LIBRARY_PATH', meson.project_build_root() / 'libgimpbase') -env.prepend('LD_LIBRARY_PATH', meson.project_build_root() / 'libgimpcolor') -env.prepend('LD_LIBRARY_PATH', meson.project_build_root() / 'libgimpconfig') -env.prepend('LD_LIBRARY_PATH', meson.project_build_root() / 'libgimpmath') -env.prepend('LD_LIBRARY_PATH', meson.project_build_root() / 'libgimpmodule') -env.prepend('LD_LIBRARY_PATH', meson.project_build_root() / 'libgimpthumb') -env.prepend('LD_LIBRARY_PATH', meson.project_build_root() / 'libgimpwidgets') - -env.set('GIMP_TESTING_ABS_TOP_SRCDIR', meson.project_source_root()) - -if enable_console_bin - gimp_exe=gimpconsole_exe -else - gimp_exe=gimpmain_exe -endif +# Unit testing environment is based on gimp_run_env with additional environment +# variables and added temporary test plug-ins. Ideally I should copy +# gimp_run_env, but meson doesn't have such function to create an env variable +# from another. So I just modify the main one instead (fortunately here it's not +# a big problem). +# See: https://github.com/mesonbuild/meson/issues/13045 +gimp_run_env.append('GIMP_TESTING_PLUGINDIRS', meson.project_build_root() / 'libgimp/tests/c-tests/') +gimp_run_env.set('GIMP_TESTING_ABS_TOP_SRCDIR', meson.project_source_root()) run_python_test = find_program('./libgimp-run-python-test.sh') run_c_test = find_program('./libgimp-run-c-test.sh') @@ -43,7 +28,7 @@ foreach test_name : tests py_test = meson.current_source_dir() / basename + '.py' test(test_name, run_python_test, args: [ gimp_exe, py_test ], - env: env, + env: gimp_run_env, suite: ['libgimp', 'python3'], timeout: 60) @@ -72,7 +57,7 @@ foreach test_name : tests test(test_name, run_c_test, args: [ gimp_exe, meson.current_source_dir() / c_test_name, basename ], - env: env, + env: gimp_run_env, suite: ['libgimp', 'C'], timeout: 60) endforeach diff --git a/meson.build b/meson.build index 88575cb16e..bcb3838e7b 100644 --- a/meson.build +++ b/meson.build @@ -1790,10 +1790,8 @@ meson.add_dist_script('meson_dist_script.sh', generate_version_h ? gitversion_h.full_path() : gitversion_h, meson.project_source_root(), meson.project_build_root()) - ################################################################################ -# Subdirs - +# Subdirs: part 1 rootInclude = include_directories('.') appInclude = include_directories('app') @@ -1840,6 +1838,88 @@ subdir('plug-ins') subdir('app') subdir('app-tools') +################################################################################ +# Make GIMP runnable without being installed for unit-testing or as a build +# tool. + +gimp_run_env=environment() + +if meson.can_run_host_binaries() + if enable_console_bin + gimp_exe=gimpconsole_exe + else + gimp_exe=gimpmain_exe + endif + + menu_paths=meson.global_build_root() / 'menus:' + meson.global_source_root() / 'menus' + gimp_run_env.set('GIMP_TESTING_MENUS_PATH', menu_paths) + + gimp_run_env.set('GIMP_TESTING_PLUGINDIRS', meson.global_build_root() / 'plug-ins') + gimp_run_env.append('GIMP_TESTING_PLUGINDIRS', meson.global_build_root() / 'plug-ins/python') + gimp_run_env.append('GIMP_TESTING_PLUGINDIRS', meson.global_build_root() / 'plug-ins/common/test-plug-ins/') + + gimp_run_env.set('GIMP_TESTING_INTERPRETER_DIRS', meson.global_build_root() / 'plug-ins/python/') + gimp_run_env.set('GIMP_TESTING_ENVIRON_DIRS', meson.global_source_root() / 'data/environ/') + + gimp_run_env.prepend('GI_TYPELIB_PATH', prefix / 'lib/girepository-1.0/') + gimp_run_env.prepend('GI_TYPELIB_PATH', meson.global_build_root() / 'libgimp') + + gimp_run_env.prepend('LD_LIBRARY_PATH', meson.global_build_root() / 'libgimp') + gimp_run_env.prepend('LD_LIBRARY_PATH', meson.global_build_root() / 'libgimpbase') + gimp_run_env.prepend('LD_LIBRARY_PATH', meson.global_build_root() / 'libgimpcolor') + gimp_run_env.prepend('LD_LIBRARY_PATH', meson.global_build_root() / 'libgimpconfig') + gimp_run_env.prepend('LD_LIBRARY_PATH', meson.global_build_root() / 'libgimpmath') + gimp_run_env.prepend('LD_LIBRARY_PATH', meson.global_build_root() / 'libgimpmodule') + gimp_run_env.prepend('LD_LIBRARY_PATH', meson.global_build_root() / 'libgimpthumb') + gimp_run_env.prepend('LD_LIBRARY_PATH', meson.global_build_root() / 'libgimpwidgets') + + if platform_windows + # On Windows, DLL are found through PATH rather than LD_LIBRARY_PATH. + gimp_run_env.prepend('PATH', meson.global_build_root() / 'libgimp') + gimp_run_env.prepend('PATH', meson.global_build_root() / 'libgimpbase') + gimp_run_env.prepend('PATH', meson.global_build_root() / 'libgimpcolor') + gimp_run_env.prepend('PATH', meson.global_build_root() / 'libgimpconfig') + gimp_run_env.prepend('PATH', meson.global_build_root() / 'libgimpmath') + gimp_run_env.prepend('PATH', meson.global_build_root() / 'libgimpmodule') + gimp_run_env.prepend('PATH', meson.global_build_root() / 'libgimpthumb') + gimp_run_env.prepend('PATH', meson.global_build_root() / 'libgimpwidgets') + elif platform_osx + gimp_run_env.prepend('DYLD_LIBRARY_PATH', meson.global_build_root() / 'libgimp') + gimp_run_env.prepend('DYLD_LIBRARY_PATH', meson.global_build_root() / 'libgimpbase') + gimp_run_env.prepend('DYLD_LIBRARY_PATH', meson.global_build_root() / 'libgimpcolor') + gimp_run_env.prepend('DYLD_LIBRARY_PATH', meson.global_build_root() / 'libgimpconfig') + gimp_run_env.prepend('DYLD_LIBRARY_PATH', meson.global_build_root() / 'libgimpmath') + gimp_run_env.prepend('DYLD_LIBRARY_PATH', meson.global_build_root() / 'libgimpmodule') + gimp_run_env.prepend('DYLD_LIBRARY_PATH', meson.global_build_root() / 'libgimpthumb') + gimp_run_env.prepend('DYLD_LIBRARY_PATH', meson.global_build_root() / 'libgimpwidgets') + endif +else + # Cross-builds require an existing native GIMP installed, unless we + # can run target binaries. + gimp_exe = find_program([gimpconsole_exe_name, gimpmain_exe_name], + native: true, required: false) + + if not gimp_exe.found() + error('When cross-compiling, the build requires either an exe_wrapper or a native GIMP installed (@0@ or @1@).'.format(gimpconsole_exe_name, gimpmain_exe_name)) + endif +endif + +# Use a temporary config directory in the top build root for 2 reasons: first +# because we don't want to pollute any existing user config folder; second +# because the default directory may not be writable (we have the case in macOS +# CI), but the build dir always is. +# XXX We might also want to delete this directory before every use, especially +# when using the binary for testing (ensuring we always start from a fresh +# config). But for now, let's keep it as-is. +gimp_exe_config_dir = custom_target('gimp_exe_config_dir', + output: [ '.tmp-config' ], + command: [ 'mkdir', '-p', '@OUTDIR@' + '/.tmp-config' ], + build_by_default: true) +gimp_run_env.set('GIMP3_DIRECTORY', gimp_exe_config_dir.full_path()) + +################################################################################ +# Subdirs: part 2 + # gimp-data submodule part 2 subdir('gimp-data/images/')