[gnome-todo] project: Minor changes to meson port



commit b51737387074356d9447e6aea4bc47e742a2ae6c
Author: Iñigo Martínez <inigomartinez gmail com>
Date:   Sun Aug 6 21:24:50 2017 +0200

    project: Minor changes to meson port
    
    This patch cleans a few things on the meson port which improves
    readibility. The list of changes is as follows:
    
    - Added configuration messages to the meson build file removing it
      from the configure_meson script.
    - Removed C99 as the C standard to be used, so the compiler's
      default will be used.
    - Moved some config.h definitions to an array list, which improves
      readibility.
    - Removed unnecessary array lists and commas.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=785901

 configure_meson                     |   25 -------
 doc/reference/meson.build           |    8 +--
 meson.build                         |  123 ++++++++++++++++++++++++----------
 plugins/background/meson.build      |    4 +-
 plugins/scheduled-panel/meson.build |    2 +-
 plugins/today-panel/meson.build     |    2 +-
 plugins/todoist/meson.build         |    4 +-
 src/meson.build                     |   51 ++++++---------
 8 files changed, 116 insertions(+), 103 deletions(-)
---
diff --git a/configure_meson b/configure_meson
index 724fac9..4f9b4e6 100755
--- a/configure_meson
+++ b/configure_meson
@@ -155,31 +155,6 @@ check:
        ${MESONTEST} ${NINJA_OPT}
 END
 
-echo "
-
-        gnome-todo
-        ==========
-
-        meson:         ${MESON}
-        ninja:         ${NINJA}
-        prefix:        ${prefix}
-        compiler:      ${CC}
-        global flags:  ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}
-        documentation: $(echooption gtk-doc)
-
-    Plugins:
-        Dark theme .............. $(echooption dark-theme-plugin)
-        Run in Background ....... $(echooption background-plugin)
-        Scheduled panel ......... $(echooption scheduled-panel-plugin)
-        Score ................... $(echooption score-plugin)
-        Today panel ............. $(echooption today-panel-plugin)
-        Unscheduled panel ....... $(echooption unscheduled-panel-plugin)
-        Todo.txt ................ $(echooption todo-txt-plugin)
-        Todoist ................. $(echooption todoist-plugin)
-
-        Now type '${NINJA} -C ${builddir}' to build
-"
-
 cmd_options=""
 for key in "${!meson_options[@]}"; do
     cmd_options="$cmd_options -Denable-$key=${meson_options[$key]}"
diff --git a/doc/reference/meson.build b/doc/reference/meson.build
index bdc5bed..2db0bf5 100644
--- a/doc/reference/meson.build
+++ b/doc/reference/meson.build
@@ -29,9 +29,7 @@ private_headers = [
   'gtd-types.h'
 ]
 
-html_images = [
-  'images/notification.png'
-]
+html_images = 'images/notification.png'
 
 version_conf = configuration_data()
 version_conf.set('VERSION', gnome_todo_version)
@@ -59,7 +57,7 @@ gnome.gtkdoc(
   dependencies: libgtd_dep,
   scan_args: [
     '--rebuild-types',
-    '--ignore-headers=' + ' '.join(private_headers),
+    '--ignore-headers=' + ' '.join(private_headers)
   ],
   mkdb_args: [
     '--sgml-mode',
@@ -73,7 +71,7 @@ gnome.gtkdoc(
     '--extra-dir=@0@'.format(join_paths(glib_doc_path, 'gio')),
     '--extra-dir=@0@'.format(join_paths(gtk_doc_path, 'gdk')),
     '--extra-dir=@0@'.format(join_paths(gtk_doc_path, 'gtk')),
-    '--extra-dir=@0@'.format(join_paths(gtk_doc_path, 'gtksourceview-3.0')),
+    '--extra-dir=@0@'.format(join_paths(gtk_doc_path, 'gtksourceview-3.0'))
   ],
   html_assets: html_images,
   install: true,
diff --git a/meson.build b/meson.build
index 2ce10ac..91102a6 100644
--- a/meson.build
+++ b/meson.build
@@ -4,7 +4,6 @@ project(
   license: 'GPL3+',
   default_options: [
     'buildtype=debugoptimized',
-    'c_std=gnu99',
     'warning_level=1'
   ],
   meson_version: '>= 0.41.0'
@@ -21,14 +20,15 @@ gnome_todo_gir_version = '1.0'
 
 gnome_todo_prefix = get_option('prefix')
 gnome_todo_bindir = join_paths(gnome_todo_prefix, get_option('bindir'))
-gnome_todo_libdir = join_paths(gnome_todo_prefix, get_option('libdir'))
-gnome_todo_localedir = join_paths(gnome_todo_prefix, get_option('localedir'))
 gnome_todo_datadir = join_paths(gnome_todo_prefix, get_option('datadir'))
 gnome_todo_includedir = join_paths(gnome_todo_prefix, get_option('includedir'))
+gnome_todo_libdir = join_paths(gnome_todo_prefix, get_option('libdir'))
+gnome_todo_libexecdir = join_paths(gnome_todo_prefix, get_option('libexecdir'))
+gnome_todo_localedir = join_paths(gnome_todo_prefix, get_option('localedir'))
 
-gnome_todo_pkglibdir = join_paths(gnome_todo_libdir, meson.project_name())
 gnome_todo_pkgdatadir = join_paths(gnome_todo_datadir, meson.project_name())
 gnome_todo_pkgincludedir = join_paths(gnome_todo_includedir, meson.project_name())
+gnome_todo_pkglibdir = join_paths(gnome_todo_libdir, meson.project_name())
 
 gnome_todo_pluginsdir = join_paths(gnome_todo_pkglibdir, 'plugins')
 gnome_todo_schemadir = join_paths(gnome_todo_datadir, 'glib-2.0', 'schemas')
@@ -38,6 +38,8 @@ current = 0
 revision = 0
 libversion = '@0@.@1@.@2@'.format(soversion, current, revision)
 
+gnome_todo_debug = get_option('buildtype').contains('debug')
+
 cc = meson.get_compiler('c')
 
 config_h = configuration_data()
@@ -45,42 +47,70 @@ config_h = configuration_data()
 config_h.set_quoted('GETTEXT_PACKAGE', meson.project_name())
 
 # debug options
-config_h.set('GNOME_TODO_ENABLE_DEBUG', get_option('buildtype') != 'release')
-config_h.set('NDEBUG', get_option('buildtype') == 'release')
+config_h.set('GNOME_TODO_ENABLE_DEBUG', gnome_todo_debug)
+config_h.set('NDEBUG', not gnome_todo_debug)
 
 # package
-config_h.set_quoted('PACKAGE', meson.project_name())
-config_h.set_quoted('PACKAGE_BUGREPORT', 'https://bugzilla.gnome.org/enter_bug.cgi?product=gnome-todo')
-config_h.set_quoted('PACKAGE_NAME', meson.project_name())
-config_h.set_quoted('PACKAGE_STRING', '@0@ @1@'.format(meson.project_name(), gnome_todo_version))
-config_h.set_quoted('PACKAGE_TARNAME', gnome_todo_version)
-config_h.set_quoted('PACKAGE_URL', 'https://wiki.gnome.org/Apps/Todo')
-config_h.set_quoted('PACKAGE_VERSION', gnome_todo_version)
-config_h.set_quoted('VERSION', gnome_todo_version)
+set_defines = [
+  ['PACKAGE', meson.project_name()],
+  ['PACKAGE_BUGREPORT', 'http://bugzilla.gnome.org/enter_bug.cgi?product=' + meson.project_name()],
+  ['PACKAGE_NAME', meson.project_name()],
+  ['PACKAGE_STRING', '@0@ @1@'.format(meson.project_name(), gnome_todo_version)],
+  ['PACKAGE_TARNAME', meson.project_name()],
+  ['PACKAGE_URL', 'https://wiki.gnome.org/Apps/Todo'],
+  ['PACKAGE_VERSION', gnome_todo_version],
+  ['VERSION', gnome_todo_version],
+  # i18n
+  ['GETTEXT_PACKAGE', meson.project_name()]
+]
+
+foreach define: set_defines
+  config_h.set_quoted(define[0], define[1])
+endforeach
 
 # headers
-config_h.set('HAVE_DLFCN_H', cc.has_header('dlfcn.h'))
-config_h.set('HAVE_INTTYPES_H', cc.has_header('inttypes.h'))
-config_h.set('HAVE_MATH_H', cc.has_header('math.h'))
-config_h.set('HAVE_MEMORY_H', cc.has_header('memory.h'))
-config_h.set('HAVE_STDINT_H', cc.has_header('stdint.h'))
-config_h.set('HAVE_STDLIB_H', cc.has_header('stdlib.h'))
-config_h.set('HAVE_STRINGS_H', cc.has_header('strings.h'))
-config_h.set('HAVE_STRING_H', cc.has_header('string.h'))
-config_h.set('HAVE_SYS_STAT_H', cc.has_header('sys/stat.h'))
-config_h.set('HAVE_SYS_TYPES_H', cc.has_header('sys/types.h'))
-config_h.set('HAVE_UNISTD_H', cc.has_header('unistd.h'))
+check_headers = [
+  ['HAVE_DLFCN_H', 'dlfcn.h'],
+  ['HAVE_INTTYPES_H', 'inttypes.h'],
+  ['HAVE_LOCALE_H', 'locale.h'],
+  ['HAVE_MEMORY_H', 'memory.h'],
+  ['HAVE_STDINT_H', 'stdint.h'],
+  ['HAVE_STDLIB_H', 'stdlib.h'],
+  ['HAVE_STRINGS_H', 'strings.h'],
+  ['HAVE_STRING_H', 'string.h'],
+  ['HAVE_SYS_STAT_H', 'sys/stat.h'],
+  ['HAVE_SYS_TYPES_H', 'sys/types.h'],
+  ['HAVE_UNISTD_H', 'unistd.h']
+]
+
+foreach header: check_headers
+  config_h.set(header[0], cc.has_header(header[1]))
+endforeach
 
 # functions
-config_h.set('HAVE_DCGETTEXT', cc.has_function('dcgettext'))
-config_h.set('HAVE_GETTEXT', cc.has_function('gettext'))
-config_h.set('HAVE_ICONV', cc.has_function('iconv'))
+check_functions = [
+  # i18n
+  ['HAVE_DCGETTEXT', 'dcgettext'],
+  ['HAVE_GETTEXT', 'gettext'],
+  ['HAVE_ICONV', 'iconv']
+]
+
+if host_machine.system().contains('darwin')
+  check_functions += [
+    ['HAVE_CFLOCALECOPYCURRENT', 'CFLocaleCopyCurrent'],
+    ['HAVE_CFPREFERENCESCOPYAPPVALUE', 'CFPreferencesCopyAppValue']
+  ]
+endif
+
+foreach func: check_functions
+  config_h.set(func[0], cc.has_function(func[1]))
+endforeach
 
 # compiler flags
 common_flags = ['-DHAVE_CONFIG_H']
+compiler_flags = []
 
-buildtype = get_option('buildtype')
-if buildtype == 'debug' or buildtype == 'debugoptimized'
+if gnome_todo_debug
   test_cflags = [
     '-fno-strict-aliasing',
     '-Wcast-align',
@@ -111,22 +141,22 @@ if buildtype == 'debug' or buildtype == 'debugoptimized'
 
   foreach cflag: test_cflags
     if cc.has_argument(cflag)
-      common_flags += [cflag]
+      compiler_flags += [cflag]
     endif
   endforeach
 endif
 
-add_project_arguments(common_flags, language: 'c')
+add_project_arguments(common_flags + compiler_flags, language: 'c')
 
 glib_dep = dependency('glib-2.0', version: '>= 2.43.4')
 gtk_dep = dependency('gtk+-3.0', version: '>= 3.22.0')
 
 gnome_todo_deps = [
-  dependency('gmodule-export-2.0'),
-  dependency('gio-2.0', version: '>= 2.43.4'),
   glib_dep,
-  dependency('goa-1.0', version: '>= 3.2.0'),
   gtk_dep,
+  dependency('gio-2.0', version: '>= 2.43.4'),
+  dependency('gmodule-export-2.0'),
+  dependency('goa-1.0', version: '>= 3.2.0'),
   dependency('libecal-1.2', version: '>= 3.13.90'),
   dependency('libedataserver-1.2', version: '>= 3.17.1'),
   dependency('libedataserverui-1.2', version: '>= 3.17.1'),
@@ -147,6 +177,7 @@ pkg = import('pkgconfig')
 top_inc = include_directories('.')
 src_inc = include_directories('src')
 
+data_dir = join_paths(meson.source_root(), 'data')
 po_dir = join_paths(meson.source_root(), 'po')
 
 subdir('plugins')
@@ -154,8 +185,28 @@ subdir('src')
 subdir('data')
 subdir('po')
 
-if get_option('enable-gtk-doc')
+enable_gtk_doc = get_option('enable-gtk-doc')
+if enable_gtk_doc
   subdir('doc/reference')
 endif
 
 meson.add_install_script('meson_post_install.py')
+
+output = '\n        gnome-todo ' + gnome_todo_version + '\n'
+output += '        ==================\n\n'
+output += '        prefix:        ' + gnome_todo_prefix + '\n'
+output += '        compiler:      ' + cc.get_id() + '\n'
+output += '        global flags:  ' + ' '.join(compiler_flags) + ' '.join(get_option('c_link_args')) + '\n'
+output += '        release:       ' + (not gnome_todo_debug).to_string() + '\n'
+output += '        documentation: ' + enable_gtk_doc.to_string() + '\n'
+output += '    Plugins:\n\n'
+output += '        Dark theme .............. ' + get_option('enable-dark-theme-plugin').to_string() + '\n'
+output += '        Run in Background ....... ' + get_option('enable-background-plugin').to_string() + '\n'
+output += '        Scheduled panel ......... ' + get_option('enable-scheduled-panel-plugin').to_string() + 
'\n'
+output += '        Score ................... ' + get_option('enable-score-plugin').to_string() + '\n'
+output += '        Today panel ............. ' + get_option('enable-today-panel-plugin').to_string() + '\n'
+output += '        Unscheduled panel ....... ' + get_option('enable-unscheduled-panel-plugin').to_string() + 
'\n'
+output += '        Todo.txt ................ ' + get_option('enable-todo-txt-plugin').to_string() + '\n'
+output += '        Todoist ................. ' + get_option('enable-todoist-plugin').to_string() + '\n'
+output += '        Now type \'ninja -C ' + meson.build_root() + '\' to build ' + meson.project_name()
+message(output)
diff --git a/plugins/background/meson.build b/plugins/background/meson.build
index c6bf445..599c2cb 100644
--- a/plugins/background/meson.build
+++ b/plugins/background/meson.build
@@ -7,9 +7,7 @@ plugins_libs += static_library(
   sources: 'gtd-plugin-' + plugin_name + '.c',
   include_directories: plugins_incs,
   dependencies: gnome_todo_deps,
-  c_args: [
-    '-DPACKAGE_DATA_DIR="@0@"'.format(gnome_todo_pkgdatadir)
-  ]
+  c_args: '-DPACKAGE_DATA_DIR="@0@"'.format(gnome_todo_pkgdatadir)
 )
 
 install_data(
diff --git a/plugins/scheduled-panel/meson.build b/plugins/scheduled-panel/meson.build
index 7c322b0..5cd16ce 100644
--- a/plugins/scheduled-panel/meson.build
+++ b/plugins/scheduled-panel/meson.build
@@ -11,7 +11,7 @@ plugins_libs += static_library(
   'scheduledpanel',
   sources: sources,
   include_directories: plugins_incs,
-  dependencies: gnome_todo_deps,
+  dependencies: gnome_todo_deps
 )
 
 plugin_data = plugin_name + '.plugin'
diff --git a/plugins/today-panel/meson.build b/plugins/today-panel/meson.build
index c504bd9..da1a0bd 100644
--- a/plugins/today-panel/meson.build
+++ b/plugins/today-panel/meson.build
@@ -11,7 +11,7 @@ plugins_libs += static_library(
   'todaypanel',
   sources: sources,
   include_directories: plugins_incs,
-  dependencies: gnome_todo_deps,
+  dependencies: gnome_todo_deps
 )
 
 plugin_data = plugin_name + '.plugin'
diff --git a/plugins/todoist/meson.build b/plugins/todoist/meson.build
index 95496d0..84d0d45 100644
--- a/plugins/todoist/meson.build
+++ b/plugins/todoist/meson.build
@@ -8,7 +8,7 @@ sources = files(
   'gtd-' + plugin_name + '-preferences-panel.c'
 )
 
-todoist_deps = [
+todoist_deps = gnome_todo_deps + [
   dependency('rest-0.7'),
   dependency('json-glib-1.0')
 ]
@@ -17,7 +17,7 @@ plugins_libs += static_library(
   plugin_name,
   sources: sources,
   include_directories: plugins_incs,
-  dependencies: [gnome_todo_deps, todoist_deps]
+  dependencies: todoist_deps
 )
 
 plugin_data = plugin_name + '.plugin'
diff --git a/src/meson.build b/src/meson.build
index aa39529..179c508 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -1,5 +1,3 @@
-src_inc = include_directories('.')
-
 install_headers(
   'engine/gtd-manager.h',
   subdir: join_paths(meson.project_name(), 'engine')
@@ -21,9 +19,7 @@ install_headers(
   subdir: join_paths(meson.project_name(), 'notification')
 )
 
-enum_headers = files(
-  'gtd-enums.h'
-)
+enum_headers = files('gtd-enums.h')
 
 headers = enum_headers + files(
   'gtd-object.h',
@@ -78,18 +74,16 @@ sources = files(
   'main.c'
 )
 
-data_dir = join_paths(meson.source_root(), 'data')
-
 sources += gnome.compile_resources(
   'gtd-resources',
   join_paths(data_dir, 'todo.gresource.xml'),
-  dependencies: plugins_confs,
-  export: true,
   source_dir: [
     data_dir,
     join_paths(meson.build_root(), 'plugins')
   ],
   c_name: 'todo',
+  dependencies: plugins_confs,
+  export: true
 )
 
 enum = 'gtd-enum-types'
@@ -101,7 +95,7 @@ sources += gnome.mkenums(
   h_template: enum + '.h.template'
 )
 
-gnome_todo_incs = [
+incs = [
   top_inc,
   include_directories(
     'engine',
@@ -112,19 +106,20 @@ gnome_todo_incs = [
   )
 ]
 
-gnome_todo_cflags = [
-  '-DPACKAGE_LOCALE_DIR="@0@"'.format(gnome_todo_localedir),
+cflags = [
   '-DPACKAGE_DATA_DIR="@0@"'.format(gnome_todo_pkgdatadir),
   '-DPACKAGE_LIB_DIR="@0@"'.format(gnome_todo_pkglibdir),
+  '-DPACKAGE_LOCALE_DIR="@0@"'.format(gnome_todo_localedir),
+  '-DPACKAGE_SRC_DIR="@0@"'.format(meson.current_source_dir()),
   '-DUI_DATA_DIR="@0@"'.format(join_paths(gnome_todo_pkgdatadir, 'style'))
 ]
 
-gnome_todo_ldflags = []
+ldflags = []
 
 if host_machine.system().contains('linux')
   foreach ldflag: plugins_ldflags
     if cc.has_argument(ldflag)
-      gnome_todo_ldflags += ldflag
+      ldflags += ldflag
     endif
   endforeach
 endif
@@ -132,11 +127,11 @@ endif
 gnome_todo = executable(
   meson.project_name(),
   sources,
-  include_directories: gnome_todo_incs,
+  include_directories: incs,
   dependencies: gnome_todo_deps,
-  c_args: gnome_todo_cflags,
+  c_args: cflags,
   link_with: plugins_libs,
-  link_args: gnome_todo_ldflags,
+  link_args: ldflags,
   install: true,
   install_dir: gnome_todo_bindir
 )
@@ -146,9 +141,9 @@ libgtd = shared_library(
   sources: sources,
   version: libversion,
   soversion: soversion,
-  include_directories: gnome_todo_incs,
+  include_directories: incs,
   dependencies: gnome_todo_deps,
-  c_args: gnome_todo_cflags
+  c_args: cflags
 )
 
 libgtd_dep = declare_dependency(
@@ -164,9 +159,7 @@ pkg.generate(
   description: 'Header and path for Gnome Todo Plugins',
   filebase: meson.project_name(),
   subdirs: meson.project_name(),
-  variables: [
-    'exec_prefix=${prefix}'
-  ],
+  variables: 'exec_prefix=' + gnome_todo_libexecdir,
   install_dir: join_paths(gnome_todo_libdir, 'pkgconfig')
 )
 
@@ -193,9 +186,9 @@ if get_option('enable-introspection')
     'gtd-task-list-view.h',
     'gtd-timer.c',
     'gtd-timer.h',
+    'gtd-types.h',
     'gtd-window.c',
-    'gtd-window.h',
-    'gtd-types.h'
+    'gtd-window.h'
   )
 
   gir_incs = [
@@ -204,9 +197,7 @@ if get_option('enable-introspection')
     'Gtk-3.0'
   ]
 
-  gir_extra_args = [
-    '--warn-all'
-  ]
+  gir_extra_args = '--warn-all'
 
   gir_dir = join_paths(gnome_todo_datadir, '@0@-@1@'.format('gir', gnome_todo_gir_version))
   typelib_dir = join_paths(gnome_todo_libdir, '@0@-@1@'.format('girepository', gnome_todo_gir_version))
@@ -219,10 +210,10 @@ if get_option('enable-introspection')
     identifier_prefix: gnome_todo_gir_namespace,
     symbol_prefix: gnome_todo_gir_namespace.to_lower(),
     includes: gir_incs,
-    include_directories: gnome_todo_incs,
+    include_directories: incs,
+    extra_args: gir_extra_args,
     install: true,
     install_dir_gir: gir_dir,
-    install_dir_typelib: typelib_dir,
-    extra_args: gir_extra_args
+    install_dir_typelib: typelib_dir
   )
 endif


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]