Skip to content

Commit

Permalink
add the meson option suggested in #153
Browse files Browse the repository at this point in the history
  • Loading branch information
maoschanz committed May 1, 2021
1 parent 09845d0 commit d966cba
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 66 deletions.
6 changes: 0 additions & 6 deletions CONTRIBUTING.md
Expand Up @@ -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.

----

69 changes: 45 additions & 24 deletions 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')
Expand Down
39 changes: 4 additions & 35 deletions meson.build
Expand Up @@ -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')
Expand Down
2 changes: 2 additions & 0 deletions meson_options.txt
@@ -0,0 +1,2 @@
option('enable-translations-and-appdata', type: 'boolean', value: true)

4 changes: 3 additions & 1 deletion 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

0 comments on commit d966cba

Please sign in to comment.