diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b2d2e151..21d850be 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -365,11 +365,5 @@ your commit(s). - `libglib2.0-dev-bin` (IIRC that one is to compress the `.ui` files and the icons into a `.gresource` file) -Aside of this, **since 0.6.0**, the main `meson.build` script will try to check -if your system does have **the dependencies to run the app**. - -The tag 0.6.0 can't be built if `appstream-util` is on the system, the other -tags should be fine. - ---- diff --git a/data/meson.build b/data/meson.build index bba5243c..0548d626 100644 --- a/data/meson.build +++ b/data/meson.build @@ -1,38 +1,59 @@ -desktop_file = i18n.merge_file( - input: app_uuid + '.desktop.in', - output: app_uuid + '.desktop', - type: 'desktop', - po_dir: '../po', - install: true, - install_dir: join_paths(get_option('datadir'), 'applications') -) +################################################################################ +# Installation and validation of the .desktop file ############################# + +desktop_files_dir = join_paths(get_option('datadir'), 'applications') +if get_option('enable-translations-and-appdata') + desktop_file = i18n.merge_file( + input: app_uuid + '.desktop.in', + output: app_uuid + '.desktop', + type: 'desktop', + po_dir: '../po', + install: true, + install_dir: desktop_files_dir + ) +else + install_data( + app_uuid + '.desktop.in', + install_rename: app_uuid + '.desktop', + install_dir: desktop_files_dir + ) + desktop_file = desktop_files_dir / app_uuid + '.desktop' +endif desktop_utils = find_program('desktop-file-validate', required: false) if desktop_utils.found() test('Validate desktop file', desktop_utils, args: [desktop_file]) endif -appstream_file = i18n.merge_file( - input: app_uuid + '.appdata.xml.in', - output: app_uuid + '.appdata.xml', - po_dir: '../po', - install: true, - install_dir: join_paths(get_option('datadir'), 'metainfo') -) +################################################################################ +# Installation and validation of the appstream file ############################ -appstream_util = find_program('appstream-util', required: false) -if appstream_util.found() - test( - 'Validate appstream file', - appstream_util, - args: ['validate', appstream_file] +if get_option('enable-translations-and-appdata') + appstream_file = i18n.merge_file( + input: app_uuid + '.appdata.xml.in', + output: app_uuid + '.appdata.xml', + po_dir: '../po', + install: true, + install_dir: join_paths(get_option('datadir'), 'metainfo') ) - # The app will never pass "validate-strict" because appstream-util wants - # pictures with a 16:9 ratio, while i use pictures of the default window - # size, which is approximating the objectively better golden ratio. + + appstream_util = find_program('appstream-util', required: false) + if appstream_util.found() + test( + 'Validate appstream file', + appstream_util, + args: ['validate', appstream_file] + ) + # The app will never pass "validate-strict" because appstream-util wants + # pictures with a 16:9 ratio, while i use pictures of the default window + # size, which is approximating the objectively better golden ratio. + endif endif +################################################################################ +# Installation and validation of the .gschema file ############################# + install_data( app_uuid + '.gschema.xml', install_dir: join_paths(get_option('datadir'), 'glib-2.0/schemas') diff --git a/meson.build b/meson.build index 3f970e26..3d8461d6 100644 --- a/meson.build +++ b/meson.build @@ -8,47 +8,16 @@ app_uuid = 'com.github.maoschanz.drawing' # Dependencies ################################################################# -# XXX the proper way to check python3 libs dependencies is this: +# TODO the proper way to check python3 libs dependencies is this: # https://mesonbuild.com/Python-module.html#dependency but the doc is quite bad # so i've no idea how to make it work -python3 = find_program('python3') -python3_tested_modules = { - 'cairo': '', - 'gi': '3.30', -} - -# You can comment the following loop if you're using an old distro to build a -# package for a recent distro. These modules are required to run the app, but -# not to build the package -foreach module, required_version : python3_tested_modules - if run_command(python3, '-c', 'import @0@'.format(module)).returncode() != 0 - error('python3 module \'' + module + '\' not found') - else - test_module = run_command( - python3, - '-c', - 'import @0@, sys; print (sys.modules["@0@"].__version__)'.format(module) - ) - actual_version = test_module.stdout().strip() - endif - if required_version > actual_version - error( - 'python3 module "' + module + '" found with version "' + actual_version - + '", the version "' + required_version + '" is required.' - ) - else - message('python3 module "' + module + '" looks fine.') - endif -endforeach - -# TODO options to build it without gettext. If gettext, validate the dep is here -# TODO options to build it without appdata. If appdata, validate the dep is here - ################################################################################ # Will be used in po and data -i18n = import('i18n') +if get_option('enable-translations-and-appdata') + i18n = import('i18n') +endif # Will be used in help and src gnome = import('gnome') diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 00000000..f66d21d0 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,2 @@ +option('enable-translations-and-appdata', type: 'boolean', value: true) + diff --git a/po/meson.build b/po/meson.build index 39f45e67..860a73fe 100644 --- a/po/meson.build +++ b/po/meson.build @@ -1,3 +1,5 @@ -i18n.gettext('drawing', args: '--add-location=file', preset: 'glib') +if get_option('enable-translations-and-appdata') + i18n.gettext('drawing', args: '--add-location=file', preset: 'glib') +endif