diff --git a/.gitlab/cp-plug-in-subfolder.py b/.gitlab/cp-plug-in-subfolder.py new file mode 100644 index 0000000000..007d28aa04 --- /dev/null +++ b/.gitlab/cp-plug-in-subfolder.py @@ -0,0 +1,32 @@ +#!/usr/bin/python3 + +# Equivalent to: +# configure_file(input: src, +# output: name / src, +# copy: true, +# install_dir: gimpplugindir / 'plug-ins' / name, +# install_mode: 'rwxr-xr-x') +# Except that configure_file() does not accept output in a subdirectory. So we +# use this wrapper for now. +# See: https://github.com/mesonbuild/meson/issues/2320 +import os +import shutil +import stat +import sys + +src_file = sys.argv[1] +dir_name = sys.argv[2] +dummy_path = None +if len(sys.argv) > 3: + dummy_path = sys.argv[3] + +os.makedirs(dir_name, exist_ok=True) + +file_name = os.path.basename(src_file) +dst_file = os.path.join(dir_name, file_name) +shutil.copyfile(src_file, dst_file) +os.chmod(dst_file, stat.S_IRWXU | stat.S_IRGRP | stat.S_IXGRP | stat.S_IROTH | stat.S_IXOTH) + +if dummy_path is not None: + # Just touch the dummy file. + open(dummy_path, mode='w').close() diff --git a/build/windows/installer/meson.build b/build/windows/installer/meson.build index a9ee6af838..b3f61fcb4f 100644 --- a/build/windows/installer/meson.build +++ b/build/windows/installer/meson.build @@ -1,6 +1,27 @@ subdir('lang') source_splash=meson.project_source_root() + '/data/images/gimp-splash.png' + +# 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('GI_TYPELIB_PATH', meson.project_build_root() / 'libgimp') +env.append('LD_LIBRARY_PATH', meson.project_build_root() / 'libgimp') +env.append('LD_LIBRARY_PATH', meson.project_build_root() / 'libgimpbase') +env.append('LD_LIBRARY_PATH', meson.project_build_root() / 'libgimpcolor') +env.append('LD_LIBRARY_PATH', meson.project_build_root() / 'libgimpconfig') +env.append('LD_LIBRARY_PATH', meson.project_build_root() / 'libgimpmath') +env.append('LD_LIBRARY_PATH', meson.project_build_root() / 'libgimpmodule') +env.append('LD_LIBRARY_PATH', meson.project_build_root() / 'libgimpthumb') +env.append('LD_LIBRARY_PATH', meson.project_build_root() / 'libgimpwidgets') + installsplash = custom_target('installsplash-devel.bmp', input : [ 'splash2installer.py' ], depend_files: [ source_splash ], @@ -9,5 +30,6 @@ installsplash = custom_target('installsplash-devel.bmp', '--batch-interpreter', 'python-fu-eval', '-b', '-', '--quit'], feed: true, - build_by_default: true + build_by_default: true, + env: env ) diff --git a/plug-ins/common/meson.build b/plug-ins/common/meson.build index f5e637a8fa..da27e601a8 100644 --- a/plug-ins/common/meson.build +++ b/plug-ins/common/meson.build @@ -213,7 +213,7 @@ foreach plugin : common_plugins_list ) endif - executable(plugin_name, + plugin_exe = executable(plugin_name, plugin_sources, include_directories: [ rootInclude, ], link_with : [ @@ -230,4 +230,15 @@ foreach plugin : common_plugins_list install: true, install_dir: gimpplugindir / 'plug-ins' / plugin_name, ) + + # Ugly trick to copy executables into subfolders so that we can run GIMP from + # the build directory without installing it. + custom_target('test-' + plugin_name, + input: [ plugin_exe ], + output: [ plugin_name + '.dummy' ], + command: [ python, meson.project_source_root() / '.gitlab/cp-plug-in-subfolder.py', + plugin_exe, meson.current_build_dir() / 'test-plug-ins' / plugin_name, + meson.current_build_dir() / 'test-plug-ins' / plugin_name + '.dummy' ], + build_by_default: true, + ) endforeach diff --git a/plug-ins/python/meson.build b/plug-ins/python/meson.build index 1b84c01c44..773ef5cce9 100644 --- a/plug-ins/python/meson.build +++ b/plug-ins/python/meson.build @@ -25,10 +25,17 @@ subdir('python-console') foreach plugin : plugins name = plugin.get('name') - srcs = plugin.get('srcs', name + '.py') + srcs = plugin.get('srcs', [name + '.py']) install_data(srcs, install_dir: gimpplugindir / 'plug-ins' / name, install_mode: 'rwxr-xr-x') + + foreach src : srcs + # Ugly trick to copy Python plug-ins into subfolders so that we can run GIMP + # from the build directory without installing it. + run_command(python, meson.project_source_root() / '.gitlab/cp-plug-in-subfolder.py', + meson.current_source_dir() / src, meson.current_build_dir() / name, check: true) + endforeach endforeach diff --git a/plug-ins/python/python-console/meson.build b/plug-ins/python/python-console/meson.build index 2399c14cbf..f6042dfc84 100644 --- a/plug-ins/python/python-console/meson.build +++ b/plug-ins/python/python-console/meson.build @@ -1,5 +1,5 @@ plugins += { 'name': 'python-console', - 'srcs': files('pyconsole.py', 'python-console.py'), + 'srcs': [ 'python-console/pyconsole.py', 'python-console/python-console.py' ], }